Commit graph

67 commits

Author SHA1 Message Date
Bruno Windels 6d7c983e8e convert (Base)ObservableMap to typescript 2022-03-09 11:33:49 +01:00
Bruno Windels 8c3ae57497 fix Iterator vs IterableIterator confusion 2021-11-30 17:05:39 +01:00
Bruno Windels 581ef47c78 fix conflicting sortedIndex declaration 2021-11-30 16:53:59 +01:00
Bruno Windels fc3eb7f57f Merge branch 'master' into bwindels/typescript-observable-2 2021-11-30 16:37:43 +01:00
Bruno Windels ef712b16f5
Merge pull request #584 from vector-im/ts-conversion-utils
Convert /utils to typescript
2021-11-30 14:13:09 +01:00
Bruno Windels c22718811f more tests for queryMove 2021-11-23 08:56:33 +01:00
Bruno Windels cf9f43ab9e WIP2 2021-11-22 20:35:57 +01:00
RMidhunSuresh 8a169d5ddc Convert sortedIndex.js to ts 2021-11-17 20:28:44 +05:30
Danila Fedorin 3d2c74a760 Add type annotations to SortedArray 2021-10-03 22:19:46 -07:00
Danila Fedorin 7b2e452cd5 Rename SortedArray to TypeScript 2021-10-03 22:19:46 -07:00
Danila Fedorin 1363af24a7 Add type annotations to MappedList 2021-10-03 22:19:46 -07:00
Danila Fedorin 84187ce109 Make updater optional in BaseObservableList 2021-10-03 22:19:44 -07:00
Danila Fedorin 0466b49520 Rename MappedList to TypeScript 2021-10-03 22:18:12 -07:00
Danila Fedorin 3b131f2db6 Add type annotations to ConcatList 2021-10-03 22:18:12 -07:00
Danila Fedorin 588da9b719 Relax types on BaseObservableList and add helper for tests 2021-10-03 22:18:12 -07:00
Danila Fedorin ddca467e30 Rename ConcatList to TypeScript 2021-10-03 22:18:12 -07:00
Danila Fedorin 8466a910da Add type annotations to AsyncMappedList 2021-10-03 22:18:12 -07:00
Danila Fedorin 0e6c59983f Generalize BaseMappedList to allow mappers to promises 2021-10-03 22:18:10 -07:00
Danila Fedorin e6de873b6e Rename AsyncMappedList to TypeScript 2021-10-03 22:16:46 -07:00
Danila Fedorin b148f3ca9e Add type annotations to ObservableArray 2021-10-03 22:16:46 -07:00
Danila Fedorin 348a9c83f5 Rename ObservableArray to TypeScript 2021-10-03 22:16:46 -07:00
Bruno Windels 3de3481765 prefer optional syntax over '| null' 2021-10-01 10:05:56 +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 d73dea797a Rename BaseObservable to TypeScript 2021-09-29 17:18:22 -07:00
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 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 f976eeaf13 rename SortedArray.replace to update 2021-04-08 18:36:09 +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
Bruno Windels 62bcb27784 implement decryption retrying and decrypting of gap/load entries
turns out we do have to always check for replay attacks because
failing to decrypt doesn't prevent an item from being stored,
so if you reload and then load you might be decrypting it
for the first time
2020-09-04 15:29:58 +02:00
Bruno Windels 00a85697ab add license header in all source files 2020-08-05 18:38:55 +02:00
Bruno Windels c379caf4c0 remove obsolete ifdef comments 2020-04-20 21:31:27 +02:00
Bruno Windels 001dbefbcf stop using default exports
because it becomes hard to remember where you used them and where not
2020-04-20 21:26:39 +02:00
Bruno Windels 8c5411cb7d moar WIP 2020-04-19 19:02:10 +02:00
Bruno Windels de35df10d8 fix test + bug in ConcatList update 2019-07-29 20:03:22 +02:00
Bruno Windels b723ab4cef add failing test for ConcatList update 2019-07-29 20:03:06 +02:00
Bruno Windels 3b7ab8f1c8 fix MappedList test after passing params as well to updater 2019-07-29 20:02:42 +02:00