Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use matrix-sdk-ui , To fetch room list service #4615

Open
PrathivDev opened this issue Feb 4, 2025 · 3 comments
Open

How to use matrix-sdk-ui , To fetch room list service #4615

PrathivDev opened this issue Feb 4, 2025 · 3 comments

Comments

@PrathivDev
Copy link

PrathivDev commented Feb 4, 2025

      let room_list_service = RoomListService::new(client.clone()).await?;

      let all_rooms = room_list_service.all_rooms().await?;
      let (entries, _) = all_rooms.entries_with_dynamic_adapters(5);
      pin_mut!(entries);
      let mut rooms = Vec::new();

        while let Some(diff) = entries.next().await {
            for entry in diff {
                match entry {
                    VectorDiff::Append { values } => {
                        rooms.extend(values);
                    }
                    _ => {}
                }
            }
            println!("{:?}", rooms);
        }
        sync_client(&client).await;

but I don't know what mistakes I have been doing and it's unclear how to use the RoomListService ,

Can someone help how to structure and use Matrix-sdk-UI , whether the API will give info to only show the room list to use and with the room_id we have to listen to timeline and update the conversation .

entries.next().await() returning vec<VectorDiff<Room>> does I need to store this and use it for every individual room conversation ?

for 1st step how to get the Information from this vec<VectorDiff>

Can we we this as discussion thread.

@PrathivDev PrathivDev changed the title How to use matrix-sdk-ui , To fetch room list service , How to use matrix-sdk-ui , To fetch room list service Feb 4, 2025
@Hywan
Copy link
Member

Hywan commented Feb 4, 2025

Hello,

You've a bunch of question, and I'm not sure I understand everything. Let's start with RoomList::entries_with_dynamic_adapters. The documentation says:

The returned stream will only start yielding diffs once a filter is set through the returned RoomListDynamicEntriesController. For every call to RoomListDynamicEntriesController::set_filter, the stream will yield a VectorDiff::Reset followed by any updates of the room list under that filter (until the next reset).

So, you've to do something like:

let (entries, controller) = all_rooms.entries_with_dynamic_adapters(5);
controller.set_filter();

You can pick a filter from matrix_sdk_ui::room_list_service::filters.

does I need to store this and use it for every individual room conversation ?

Well, I don't know, it depends what you're trying to do.

@PrathivDev
Copy link
Author

PrathivDev commented Feb 4, 2025

thanks for info and it's work fine now but does this stream yield automatically when new rooms are added (changes related to rooms) or only will yield when it's called with set_filter

add when new set_filter is called new stream is emitted and it's stay's ideal after that, does it wait for future changes related to filter is set and yield it .

@Hywan
Copy link
Member

Hywan commented Feb 5, 2025

thanks for info and it's work fine now but does this stream yield automatically when new rooms are added (changes related to rooms) or only will yield when it's called with set_filter

Once a filter is set, the stream gives you continuously updates for the room in the list, be updates of the room info, new rooms etc.

add when new set_filter is called new stream is emitted and it's stay's ideal after that, does it wait for future changes related to filter is set and yield it .

It waits for updates. You've nothing to do rather than waiting for updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants