From aae7f746a503dc3344126a58568967476c6d50ee Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 16 Sep 2024 11:49:02 +0200 Subject: [PATCH 1/3] feat(rust): Replace `Entries` by `EntriesWithDynamicAdapters`. This `Entries` method is being removed from the FFI API, so I'm updating this project. --- internal/api/rust/rust.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/api/rust/rust.go b/internal/api/rust/rust.go index a712d58..f1da92b 100644 --- a/internal/api/rust/rust.go +++ b/internal/api/rust/rust.go @@ -397,7 +397,9 @@ func (c *RustClient) StartSyncing(t ct.TestLike) (stopSyncing func(), err error) } } }() - c.allRooms.Entries(allRoomsListener) + entriesAdapters := c.allRooms.EntriesWithDynamicAdapters(1000, allRoomsListener) + entriesAdapters.Controller().SetFilter(matrix_sdk_ffi.RoomListEntriesDynamicFilterKindNonLeft{}) + // TODO: what to do with `entriesAdapters`? isSyncing := false From 9ef5dccdc0e04ceeca681735c91c1ec874003849 Mon Sep 17 00:00:00 2001 From: Kegan Dougal <7190048+kegsay@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:37:31 +0100 Subject: [PATCH 2/3] Destroy intermediate values --- internal/api/rust/rust.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/api/rust/rust.go b/internal/api/rust/rust.go index f1da92b..18a8546 100644 --- a/internal/api/rust/rust.go +++ b/internal/api/rust/rust.go @@ -398,8 +398,10 @@ func (c *RustClient) StartSyncing(t ct.TestLike) (stopSyncing func(), err error) } }() entriesAdapters := c.allRooms.EntriesWithDynamicAdapters(1000, allRoomsListener) - entriesAdapters.Controller().SetFilter(matrix_sdk_ffi.RoomListEntriesDynamicFilterKindNonLeft{}) - // TODO: what to do with `entriesAdapters`? + entriesController := entriesAdapters.Controller() + entriesController.SetFilter(matrix_sdk_ffi.RoomListEntriesDynamicFilterKindNonLeft{}) + entriesController.Destroy() + entriesAdapters.Destroy() isSyncing := false From 7b6f9252d75b3c0789b7c30a47c284486cd5ec6d Mon Sep 17 00:00:00 2001 From: Kegan Dougal <7190048+kegsay@users.noreply.github.com> Date: Thu, 26 Sep 2024 09:33:02 +0100 Subject: [PATCH 3/3] Keep onto intermediate values until the client is destroyed --- internal/api/rust/rust.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/api/rust/rust.go b/internal/api/rust/rust.go index 18a8546..431ad62 100644 --- a/internal/api/rust/rust.go +++ b/internal/api/rust/rust.go @@ -50,6 +50,8 @@ type RustRoomInfo struct { type RustClient struct { FFIClient *matrix_sdk_ffi.Client roomsListener *RoomsListener + entriesController *matrix_sdk_ffi.RoomListDynamicEntriesController + entriesAdapters *matrix_sdk_ffi.RoomListEntriesWithDynamicAdaptersResult allRooms *matrix_sdk_ffi.RoomList rooms map[string]*RustRoomInfo roomsMu *sync.RWMutex @@ -287,6 +289,14 @@ func (c *RustClient) Close(t ct.TestLike) { } } c.roomsMu.Unlock() + if c.entriesController != nil { + c.entriesController.Destroy() + c.entriesController = nil + } + if c.entriesAdapters != nil { + c.entriesAdapters.Destroy() + c.entriesAdapters = nil + } c.FFIClient.Destroy() c.FFIClient = nil if c.notifClient != nil { @@ -400,8 +410,8 @@ func (c *RustClient) StartSyncing(t ct.TestLike) (stopSyncing func(), err error) entriesAdapters := c.allRooms.EntriesWithDynamicAdapters(1000, allRoomsListener) entriesController := entriesAdapters.Controller() entriesController.SetFilter(matrix_sdk_ffi.RoomListEntriesDynamicFilterKindNonLeft{}) - entriesController.Destroy() - entriesAdapters.Destroy() + c.entriesController = entriesController + c.entriesAdapters = entriesAdapters isSyncing := false