Commit graph

90 commits

Author SHA1 Message Date
Bruno Windels 3de3481765 prefer optional syntax over '| null' 2021-10-01 10:05:56 +02:00
Bruno Windels 6b50a63e95 missing space 2021-10-01 10:02:32 +02:00
Bruno Windels 393e2f809e make subscription handle return undefined, so we can reassign optional members in one statement 2021-10-01 10:01:52 +02:00
Bruno Windels a0f443ccc3
Merge pull request #521 from DanilaFe/typescript-observable
Start migrating Observable code to TypeScript.
2021-10-01 09:54:29 +02:00
Bruno Windels e42739ec81 scroll room list to top when entering query first 2021-09-30 17:19:42 +02:00
Danila Fedorin c80dfb10a2 Add type annotations to BaseMappedList 2021-09-29 18:41:30 -07:00
Danila Fedorin 99164eb0d8 Rename BaseMappedList to TypeScript 2021-09-29 18:17:38 -07:00
Danila Fedorin bf53449f66 Add type annotations to common 2021-09-29 18:13:49 -07:00
Danila Fedorin e53f3d23d5 Rename common to TypeScript 2021-09-29 18:10:09 -07:00
Danila Fedorin 414280ada9 Add type annotations to BaseObservableList 2021-09-29 18:05:30 -07:00
Danila Fedorin 3952c3b969 Rename BaseObservableList to TypeScript 2021-09-29 17:46:51 -07:00
Danila Fedorin ab6ce62551 Add type annotations to ObservableValue 2021-09-29 17:43:17 -07:00
Danila Fedorin a7360f409e Rename ObservableValue to TypeScript 2021-09-29 17:42:57 -07:00
Danila Fedorin 319027e2e3 Add type annotations to BaseObservable 2021-09-29 17:42:57 -07:00
Danila Fedorin d73dea797a Rename BaseObservable to TypeScript 2021-09-29 17:18:22 -07:00
Bruno Windels e105bc4237 fix lint warnings 2021-08-24 15:31:18 +02:00
RMidhunSuresh d1f465e6cc Replace slice with iterator
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
2021-07-16 17:08:18 +05:30
RMidhunSuresh 35f6043d06 Support slice
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
2021-07-16 17:08:18 +05:30
RMidhunSuresh dea0cad252 Fix bug in FilteredMap
Caused multiple updates to be triggered.

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
2021-07-16 17:08:18 +05:30
RMidhunSuresh f41c835e91 Support updater in MappedMap
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
2021-07-16 17:08:18 +05:30
RMidhunSuresh 2e8c4563aa Implement set method to support update from value
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
2021-07-16 17:08:18 +05:30
Bruno Windels e125599a47 prevent decryption result getting lost after reaction updates entry 2021-06-23 17:38:52 +02:00
Bruno Windels 81f06f565e write tests for AsyncMappedList 2021-06-21 17:26:08 +02:00
Bruno Windels 757e08c62c WIP 4 2021-06-10 18:29:10 +02:00
Bruno Windels 2152d5e833 expose reactions on base message tile as vm with observable list 2021-06-03 19:15:49 +02:00
Bruno Windels addddf1f26 remove need for transferLocalEchoState, just add local relations again 2021-05-31 16:33:05 +02:00
Bruno Windels 0596ca06b1 emit remove before linking up sibling tiles
otherwise emitting the update from updatePreviousSibling has
the wrong idx
2021-05-31 11:56:41 +02:00
Bruno Windels 63b371b6ef support findAndUpdate with same predicate semantics in SortedArray too 2021-05-31 10:47:32 +02:00
Bruno Windels fa37e8fedb findAndUpdate uses predicate, just add callback to update method 2021-05-31 10:46:16 +02:00
Bruno Windels c6e2607f1f guard against updates emitted while populating during first subscription
This came up now because Timeline uses a MappedList to map PendingEvents
to PendingEventEntries. In the map function, we setup links between
entries to support local echo for relations. When opening a timeline
that has unsent relations, the initial populating of the MappedList
will try to emit an update for the target entry in remoteEntries.
This all happens while the ListView of the timeline is calling subscribe
and all collections in the chain are populating themselves based on
their sources.

This usually entails calling subscribe on the source,
and now you are subscribed, iterate over the source (as you're not
allowed to query an unsubscribed observable collection, as it might not
be populated yet, and even if it did, it wouldn't be guaranteed to be
up to date as events aren't flowing yet).

So in this concrete example, TilesCollection hadn't populated its tiles
yet and when the update to the target of the unsent relation reached
TilesCollection, the tiles array was still null and it crashed.

I thought what would be the best way to fix this and have a solid model
for observable collections to ensure they are always compatible with
each other. I considered splitting up the subscription process in two
steps where you'd first populate the source and then explicitly start
events flowing.

I didn't go with this way because it's really only updates that
make sense to be emitted during setup.
A missed update wouldn't usually bring the collections out of sync
like a missed add or remove would. It would just mean the UI isn't
updated (or any subsequent filtered collections are not updated),
but this should be fine to ignore during setup, as you can rely
on the subscribing collections down the chain picking up the update
while populating. If we ever want to support add or remove events
during setup, we would have to explicitly support them, but for now
they are correct to throw.

So for now, just ignore update events that happen during setup
where needed.
2021-05-27 10:02:05 +02:00
Bruno Windels da02b5fe2d transfer local echo state when replacing event entry
e.g. after decryption or remote echo of other relation comes in
2021-05-26 13:10:19 +02:00
Bruno Windels a5d5c55835 MappedList.findAndUpdate 2021-05-26 13:08:33 +02:00
Bruno Windels 4ce66fc8a1 allow concurrent removals when iterating pending events
so we can remove failed events in the next commit
2021-05-20 14:51:04 +02:00
Bruno Windels 6c58c61da9 move switching room view models to a dedicated observable
based on the observing the room status
2021-05-07 13:10:35 +02:00
Bruno Windels 3143f2a791 also make an observable version of a retained value 2021-05-07 13:06:20 +02:00
Bruno Windels 025320b83e fix filtered map 2021-04-27 16:15:20 +02:00
Bruno Windels ff4abbc5ba make dispose not fail 2021-04-22 17:18:07 +02:00
Bruno Windels 4e3127c4cf handle key collisions in JoinedMap 2021-04-22 13:28:14 +02:00
Bruno Windels f596b34cac add very basic join observable map, joining several maps into one
will be used to join invites and rooms into one map
2021-04-21 17:25:37 +02:00
Bruno Windels 1d3a2aca0e add 'get' method to common observable map api 2021-04-21 17:23:49 +02:00
Bruno Windels f976eeaf13 rename SortedArray.replace to update 2021-04-08 18:36:09 +02:00
Bruno Windels b27f6a067f implement .size for all observable maps
as SortedMapList uses it, putting undefined in its list
initially when missing, creating a crash in
the TemplateView that renders it
2020-11-05 12:00:17 +01:00
Bruno Windels 137264edcb implement subscribing to a single event 2020-10-30 15:19:51 +01:00
Bruno Windels 4e8e9eae26 first round of fixes 2020-10-12 18:31:55 +02:00
Bruno Windels 514095da7a move waitFor and get to BaseObservableValue 2020-10-06 18:04:34 +02:00
Bruno Windels e3fdd3a4fd ApplyMap, your observable map collection for applying side-effects 2020-10-06 12:20:28 +02:00
Bruno Windels 9a3734e5ba this is a NOP, but in the future might not be 2020-10-06 12:20:03 +02:00
Bruno Windels 84425fad5c more work on FilteredMap (not done yet though)
I ended up not using this, but at some point we'll need it,
so commit this work
2020-10-06 12:19:08 +02:00
Bruno Windels 943467cf67 actually implemented filtered map 2020-10-05 18:18:44 +02:00
Bruno Windels 4875095ea3 fix event tiles not updating when event is decrypted when room keys come 2020-09-11 17:47:35 +02:00