Commit Graph

13223 Commits

Author SHA1 Message Date
Ivan Enderlin b34a2cdfc9 Merge pull request #3559 from matrix-org/feat-sdk-sliding-sync-get-room-id
chore(sdk): Remove the useless `SlidingSyncList::get_room_id` method
2024-06-17 13:02:28 +02:00
Ivan Enderlin 304c225c8f chore(sdk): Remove the useless SlidingSyncList::get_room_id method.
This patch removes the useless `SlidingSyncList::get_room_id` method as
I don't see how it can be useful for anybody. It's mostly dead public
code, let's clean that up.
2024-06-17 12:13:26 +02:00
Benjamin Bouvier 72adaf4119 sdk: slightly better doc for HttpError 2024-06-17 10:50:06 +02:00
Benjamin Bouvier c656ad4068 sdk: prefer direct use of IntoHttp ctor instead of implicit #[from] conversions 2024-06-17 10:50:06 +02:00
Benjamin Bouvier c33a7b77e1 sdk: prefer direct use of RefreshToken ctor instead of implicit #[from] conversions
This might be controversial, but I do strongly prefer explicit over
implicit, in this case: it helps looking at the use cases, when using
the LSP's goto_references().
2024-06-17 10:50:06 +02:00
Benjamin Bouvier 7f64580ce2 sdk: use Error::AuthenticationRequired instead of HttpError::AuthenticationRequired
The HttpError variant was misplaced, as it was always used when the
`user_id()` is missing, which is causing `Error::AuthenticationRequired`
errors everywhere else in the code base. This patch streamlines usage of
`Error::AuthenticationRequired`, and gets rid of the `HttpError`
variant.
2024-06-17 10:50:06 +02:00
Benjamin Bouvier 08d7bd0cee sdk: get rid of the UnableToCloneRequest error which is absolutely unused 2024-06-17 10:50:06 +02:00
Ivan Enderlin 6ecefd6bc7 Merge pull request #3554 from Hywan/chore-sdk-remove-get-prefix 2024-06-13 23:59:52 +02:00
Ivan Enderlin b21b8c4a53 doc(base): Update the CHANGELOG.md file. 2024-06-13 16:52:37 +02:00
Ivan Enderlin 771ddcb91e chore(base): Remove the get_ of some Client's methods.
This patch renames `Client::get_rooms`, `::get_rooms_filtered` and
`::get_room` to respectively `::rooms`, `::rooms_filtered` and `::room`.
This `get_` prefix isn't really Rust idiomatic.
2024-06-13 16:51:20 +02:00
Ivan Enderlin 408c12fc66 doc(base): Update the CHANGELOG.md file. 2024-06-13 16:44:54 +02:00
Ivan Enderlin adff893835 feat(base): Faster Store::rooms_filtered.
Just like in https://github.com/matrix-org/matrix-rust-sdk/pull/3552,
this patch updates `Store::rooms_filtered` to not call `Store::room` so
that it doesn't lock `rooms` for each item, thus making it way faster.
2024-06-13 16:44:54 +02:00
Ivan Enderlin 81e328d090 chore: Remove the get_ of some Store's methods.
This patch renames `Store::get_rooms`, `::get_rooms_filtered` and
`::get_room` to respectively `::rooms`, `::rooms_filtered` and `::room`.
This `get_` prefix isn't really Rust idiomatic.
2024-06-13 16:40:32 +02:00
Benjamin Bouvier b1c09ed61b ffi: get rid of Timeline::latest_event()
It's unlikely to be useful as per the `Timeline` object: rather, callers
should make use of `Room::latest_event()`.
2024-06-13 16:28:40 +02:00
Ivan Enderlin 9ccf94dc3c Merge pull request #3552 from Hywan/fix-base-store-get-rooms-fast
feat(base): Make `Store::get_rooms` wayyy faster
2024-06-13 16:21:46 +02:00
Ivan Enderlin 15ab77629f feat(base): Make Store::get_rooms wayyy faster.
`Store::get_rooms` worked as follows: For each room ID, call

* Take the read lock for `rooms`,
* For each entry in `rooms`, take the room ID (the key), then call `Store::get_room`, which…
* Take the read lock for `rooms`,
* Based on the room ID (the key), read the room (the value) from `rooms`.

So calling `get_rooms` calls `get_room` for each room, which takes the lock every time.

This patch modifies that by fetching the values (the rooms) directly
from `rooms`, without calling `get_room`.

In my benchmark, it took 1.2ms to read 10'000 rooms. Now it takes 542µs.
Performance time has improved by -55.8%.
2024-06-13 16:03:25 +02:00
Ivan Enderlin 5178cbbfc7 Merge pull request #3551 from Hywan/fix-ui-roomlist-slidingsyncroom
feat(ui): `RoomListService::room` is no longer async!
2024-06-13 15:20:47 +02:00
Ivan Enderlin a7ff0587a6 fix(ui): Replace the RwLock by a Mutex in RoomListService::rooms.
This patch replaces the `RwLock` by a `Mutex` in
`RoomListService::rooms` because:

1. it removes a race condition,
2. `RwLock` was used because the lock could have been taken for a long
   time due to the previous `.await` point. It's no longer the case, so we
   can blindly use a `Mutex` here.
2024-06-13 15:03:59 +02:00
Ivan Enderlin edec6e7558 feat(ui): RoomListService::room is no longer async.
This patch makes `RoomListService::room` synchronous. It no longer reads
a `SlidingSyncRoom` from `SlidingSync`, then it not needs to be async
anymore. This patch replaces the `RwLock` of `RoomListService::rooms`
from `tokio::sync` to `std::sync`.

The patch updates all calls to `RoomListService::room` to remove the
`.await` point.
2024-06-13 14:47:43 +02:00
Ivan Enderlin 868e821427 Merge pull request #3550 from Hywan/fix-ui-timeline-duplicated-events
fix(ui): Change the behaviour when a duplicated event is received by the `Timeline`
2024-06-13 14:43:44 +02:00
Ivan Enderlin de5d80547b Merge pull request #3541 from Hywan/chore-ffi-roominfo-latest-event
chore(ffi): Remove `RoomInfo::latest_event`
2024-06-13 14:40:38 +02:00
Ivan Enderlin 5e755c5d51 fix(ui): room_list_service::Room::new no longer receives a SlidingSyncRoom.
This patch updates `room_list_service::Room::new` to take a `&Client`
and a `&RoomId` instead of a `SlidingSyncRoom`. The `SlidingSyncRoom` is
only used in `Room::default_room_timeline_builder` and is fetched there
from the `SlidingSync` instance lazily. It confines the
`SlidingSyncRoom` to one single method for `Room` now.
2024-06-13 14:39:39 +02:00
Ivan Enderlin d46e65805a chore(ui): Rename TimelineInnerState::add_event to add_or_update_event.
This patch renames `add_event` to `add_or_update_event` because it is
what it does.
2024-06-13 14:21:17 +02:00
Damir Jelić 9b05d0d822 crypto: Use the server name in the QR code login data (#3537)
Using the resolved homeserver URL causes problems if we need to inspect
the well-known configuration of the homeserver, for example, if the
server name is matrix.org, but the homeserver URL is server.matrix.org,
the well-known might be only available for the former.

This is why we also need to receive the former, i.e. the server name in
the QR code data.
2024-06-13 14:16:48 +02:00
Ivan Enderlin 01a36c90c3 chore(ffi): Remove RoomInfo::latest_event.
This patch removes `RoomInfo::latest_event`. To get the latest event,
one has to use `RoomListItem::latest_event` because it supports
local events and remote events. It was supposed to be the case of
`Room::room_info` too, but only when the method was called: Once the
`RoomInfo` was created, the latest event inside `RoomInfo`
was static, not dynamic. Also, this code wasn't tested
contrary to `RoomListItem::latest_event` which uses
`matrix_sdk_ui::room_list_service::Room::latest_event` which is itself
tested.
2024-06-13 14:13:48 +02:00
Ivan Enderlin 6da17b3f02 Merge pull request #3540 from Hywan/fix-ui-roomlist-latest-event
chore(ui): `room_list_service::Room::latest_event` no longer uses `SlidingSyncRoom` (+ drop `SlidingSyncRoomExt`)
2024-06-13 14:08:27 +02:00
Ivan Enderlin 15ed91e047 fix(ui): Change the behaviour when a duplicated event is received by Timeline.
This patch changes the behaviour of the `Timeline` when a duplicated
event is received. Prior to this patch, the old event was removed, and
the one was added. With this patch, the old event is kept, and the new
one is skipped.

This is important for https://github.com/matrix-org/matrix-rust-sdk/pull/3512
where events are mapped to the timeline item indices. When an event is
removed, it becomes difficult to keep the mapping correct.

This patch also adds duplication detection for pagination (with
`TimelineItemPosition::Start`).
2024-06-13 14:05:22 +02:00
Ivan Enderlin 6d1289482a chore(ui): Remove SlidingSyncRoomExt.
This patch removes the `matrix_sdk_ui::timeline::SlidingSyncRoomExt`
trait as it's no longer necessary since `room_list::Room::latest_event`
no longer uses `SlidingSyncRoom` to fetch the latest event.
2024-06-13 13:47:42 +02:00
Ivan Enderlin 8021d72389 feat(ui): Fetch the latest event from Room instead of SlidingSyncRoom in room_list::Room.
This patch updates `matrix_sdk_ui::room_list::Room::latest_event`
to fetch the latest event from `matrix_sdk::Room` instead of
`matrix_sdk::sliding_sync::SlidingSyncRoom`. It removes one dependency
to `SlidingSyncRoom` and it simplifies the code.
2024-06-13 12:00:22 +02:00
Johannes Marbach f770248b24 fix(bindings): use the same library name for all platforms in the xcframework
Fixes: #3528
Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
2024-06-12 17:17:36 +02:00
Benjamin Bouvier 2a79956caa ffi: call the initial events in the same task that listens to updates
This avoids a race condition where the caller hasn't set up the initial
items or the listener, and the listener is called *before* the initial
items have been used.
2024-06-12 16:16:41 +02:00
Mauro 871116eee9 feat (bindings): added an API to retrieve a loaded reply (#3534)
second part of the #3439 breakdown

The context for this API, is for the composer preview an reply without the need of it being actively in the timeline.
2024-06-12 14:00:50 +00:00
Benjamin Bouvier 03c16cb9f6 deduplicating handler: rename NotFinishedYet to Cancelled and add a few comments around the code future 2024-06-12 15:39:21 +02:00
Benjamin Bouvier 34a9289978 deduplicating handler: add a regression test for cancellation of a deduplicated query 2024-06-12 15:39:21 +02:00
Benjamin Bouvier ad63d28cfa deduplicating handler: use a new QueryState data structure 2024-06-12 15:39:21 +02:00
Benjamin Bouvier ac0992953e deduplicating handler: repeat request until it's performed at least once 2024-06-12 15:39:21 +02:00
Mauro d035eb1d90 feat (bindings): added APIs to save and load composer drafts (#3531)
This PR is the first piece of the breakdown of the following PR: https://github.com/matrix-org/matrix-rust-sdk/pull/3439 where only the core functionalities of the feature are implemented, without addressing the issue of editing and replying to events that have not yet been paginated.
2024-06-11 15:32:07 +00:00
Benjamin Bouvier 0ec90c23da base: move the initial filling of the display name cache into the sync methods
It's not perfect, but it's honest work.
2024-06-11 15:44:53 +02:00
Benjamin Bouvier c72384f7d4 base: don't regenerate the display name when creating a room, store the cached display name in RoomInfo
So revert a few changes to make some functions async, etc.
2024-06-11 15:44:53 +02:00
Benjamin Bouvier 5a5a5797e9 ci: fix flakeyness of test_room_notification_count in an innovative way
The test looks at updates of `RoomInfo`s, but these depends on external
factors like the server sending them in one part or multiple ones.

Instead of trying to figure out which partial updates the server sent,
wait for the stream of `RoomInfo`s to stabilize by trying to get the
latest item from the stream, then wait up to N seconds for another item
to show up, and continue as long as items come in.

This should allow us to get rid of some code that was required to
prevent flakey updates.
2024-06-11 15:44:53 +02:00
Benjamin Bouvier e22162a23a base: rename computed_display_name to compute_display_name and remove computed_ in the cached one 2024-06-11 15:44:53 +02:00
Benjamin Bouvier 73f977986e sdk: use the cached computed display name in more places 2024-06-11 15:44:53 +02:00
Benjamin Bouvier 2d444284cc base: rename calculate_room_name to compute_display_name_from_heroes 2024-06-11 15:44:53 +02:00
Benjamin Bouvier c0c9d16412 ui: make use of the cached computed display name in the room name matchers 2024-06-11 15:44:53 +02:00
Benjamin Bouvier 78a1634341 base: add a cache to the computed display name 2024-06-11 15:44:53 +02:00
Benjamin Bouvier 78e2ab9d99 base: make get_or_create_room async
Since this is a good place where to recompute the cached display name at
start.
2024-06-11 15:44:53 +02:00
Benjamin Bouvier f1553ae7f8 sliding sync: add some simple positive tests for room names too 2024-06-11 15:44:53 +02:00
Benjamin Bouvier 9a1a3e67c3 base(code motion): move calculate_room_name into the one file where it's used 2024-06-11 15:44:53 +02:00
Benjamin Bouvier 82ae74fee9 base: get rid of intermediate calculate_name() function 2024-06-11 15:44:53 +02:00
Benjamin Bouvier 8d66d1bab0 base: fix guessed number of members as it should relate to joined users, not joined+invited
The previous code would use `ACTIVE` which means "either joined or
invited" members, but the code thereafter considered this to be the
number of joined members.

Also replaced a call to `self.members()` (which does a lot of work under
the hood) with a call to `self.joined_user_ids()`, since we only
retrieve the `.len()` of the resulting vector.
2024-06-11 15:44:53 +02:00