This is what's happening in /ui in the RoomList component behind the scenes. Render rooms and invites however you'd like. inviteList is a list of rooms you are not a part of yet, but have been invited to.
updateLists is a function which refreshes the lists, usually in the event of an invite rejection / acceptance.
Using UI
The RoomList component will show a simple inbox. However, you can override what it looks like by using the prop renderListItem. Read more at RoomList.
Join room
Be sure to update the lists after joinRoom resolves.
Reject room invite
Be sure to update the lists after leaveRoom resolves.
updates is an array of messages that are deleted, edited, etc and therefore should be re-rendered in the view. Using this, you can memoize your MessageItem, reducing the number of useless re-renders on your screen.
To see an implementation of this including fetching previous messages, handling touches on the screen, rendering a typing indicator, etc, you can see that in the example app.
Using UI
View the docs on MessageList to see what you can do for handling touches (onPress, onLongPress).
import { useMatrix, useRoomList } from '@rn-matrix/core'
...
// within your component
const { isReady, isSynced } = useMatrix();
const { roomList, inviteList, updateLists } = useRoomList();
if (!isReady || !isSynced) // return a loader
return (
<FlatList data={roomList} renderItem={...} />
)
import { RoomList } from '@rn-matrix/ui'
...
function RoomListView() {
const { isReady, isSynced } = useMatrix(); // you should still wait for these
const onRowPress = (item) => {}
if (!isReady || !isSynced) // return a loader
return <RoomList onRowPress={onRowPress} />
}
import { useTimeline } from '@rn-matrix/core'
...
export default function MessageView() {
// Get "room" from navigation params, from clicking on it in the inbox
return <MessageList room={room} />
}