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

feat(ui): Propagate RoomEventCache's VectorDiff to Timeline #3512

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from

Commits on Jun 14, 2024

  1. feat(sdk): EventsOrigin has a new variant: Pagination.

    This patch adds the `EventsOrigin::Pagination` variant. It does nothing
    more than that. This variant is going to be used in the following
    patches.
    Hywan committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    917a248 View commit details
    Browse the repository at this point in the history
  2. feat(sdk) Add RoomEvents::updates_as_vector_diffs.

    This patch adds the `RoomEvents::chunks_updates_as_vector` field,
    and the `updates_as_vector_diffs` method. Let's use
    `linked_chunk::AsVector` inside `EventCache`.
    Hywan committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    f76a8bb View commit details
    Browse the repository at this point in the history
  3. feat(ui): Implement Add for HandleManyEventsResult.

    This patch implements `Add` for `HandleManyEventsResult` so that it's
    easier to accumulate many of them.
    Hywan committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    db6977d View commit details
    Browse the repository at this point in the history
  4. feat(sdk): RoomEventCacheUpdate::AddTimelineEvents now holds a `Vec…

    …<VectorDiff<_>>`.
    
    The type of `RoomEventCacheUpdate::AddTimelineEvents::events` is updated
    from `Vec<SyncTimelineEvent>` to `Vec<VectorDiff<SyncTimelineEvent>>`.
    So far, only `VectorDiff::Append` is supported, but more will come in
    the next patches.
    
    A new `TimelineInner::add_events_with_diffs` method is added.
    It's pretty similar to `add_events_at`, except that it receives
    `VectorDiff`s.
    Hywan committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    5a720f7 View commit details
    Browse the repository at this point in the history
  5. feat(ui): TimelineInnerState(Transaction)::add_remote_events_at acc…

    …ept an iterator of events.
    
    This patch updates `TimelineInnerStateTransaction::add_remote_events_at`
    to accept a generic parameter for `events`, it must implement
    `IntoIterator::Item: Into<SyncTimelineEvent>`. At an upper level,
    `TimelineStateInner::add_events_at` at the same constraint except
    `IntoIterator::IntoIter: ExactSizeIterator>`.
    
    This modification propagates up to `TimelineInner::add_remote_events_at`
    and `TimelineInner::add_events_with_diffs`. It removes the need to clone
    the `VectorDiff` values which are inside a `Vector` to get a `Vec`.
    Basically, it saves memory and computations!
    Hywan committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    b1ce3bc View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    8f43bf6 View commit details
    Browse the repository at this point in the history
  7. feat(ui) Rename TimelineEnd into TimelineNewItemPosition.

    This patch renames `TimelineEnd` into `TimelineNewItemPosition` for
    2 reasons:
    
    1. In the following patch, we will introduce a new variant to insert at
       a specific index, so the suffix `End` would no longer make sense.
    
    2. It's exactly like `TimelineItemPosition` except that it's used
       only and strictly only to add **new** items, which is why we can't use
       `TimelineItemPosition` because it contains the `Update` variant. This
       renaming reflects it's only about **new** items.
    Hywan committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    14baf46 View commit details
    Browse the repository at this point in the history
  8. chore(ui): TimelineItemPosition::Update has now one field.

    This patch updates `TimelineItemPosition::Update` from a tuple to a
    struct with an `index`, i.e. from `Update(usize)` to `Update { index:
    usize }`, for the sake of consistency with the other variants.
    Hywan committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    ac9a433 View commit details
    Browse the repository at this point in the history
  9. feat(ui): Add TimelineItemPosition::At.

    This patch adds the `TimelineItemPosition::At` variant that allows to
    insert an event at any position.
    Hywan committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    cd6ea8a View commit details
    Browse the repository at this point in the history
  10. chore(ui): Try to clear confusion between event index and timeline it…

    …em index.
    
    This patch tries to clear confusion between event index and timeline
    item index in `TimelineItemPosition`.
    Hywan committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    bd199cd View commit details
    Browse the repository at this point in the history
  11. feat(sdk): Detect event duplication in `TimelineInnerState::add_or_up…

    …date_event`.
    
    This patch applies event duplication detection in
    `TimelineInnerState::add_or_update_event` when the the position is
    `TimelineItemPosition::At`.
    Hywan committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    10fb880 View commit details
    Browse the repository at this point in the history
  12. chore(ui): Have a single code for all kind of timeline item insertions.

    This patch tries to unify the code to insert timeline item at position
    `Start` and `End` (plus `At`, but with a `todo` for the moment). We can
    clearly have the same code for these `TimelineItemPosition`s. It doesn't
    make sense to have separate implementations, especially knowing that
    `End` had duplicated events check while `Start` had not.
    
    This code only and strictly code moving, modulo the `position` handling,
    but nothing has changed apart from that.
    Hywan committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    b4f1575 View commit details
    Browse the repository at this point in the history

Commits on Jun 17, 2024

  1. feat(ui): !the algorithm

    Hywan committed Jun 17, 2024
    Configuration menu
    Copy the full SHA
    d5ccfdc View commit details
    Browse the repository at this point in the history
  2. feat(ui): TimelineInner::add_events_with_diffs supports more `Vecto…

    …rDiff`.
    
    This patch updates `TimelineInner::add_events_with_diffs` to
    support more `VectorDiff` variant, notably `Insert` which uses
    `TimelineNewItemPosition::At`.
    Hywan committed Jun 17, 2024
    Configuration menu
    Copy the full SHA
    d6bfff8 View commit details
    Browse the repository at this point in the history
  3. feat(sdk,ui): Timeline receives backpaginated events via `RoomEvent…

    …CacheUpdate`!
    
    Prior to this patch, when the `Timeline` was doing a pagination, the
    new events were inside the `EventCache` and also added directly onto
    the timeline. However, we already have a mechanism to receive new events
    in the `Timeline`, and it's a task run by the `Timeline` builder. New
    events are received via `RoomEventCacheUpdate`. The problem is: we have
    two entry points to add events: one with `RoomEventCacheUpdate`, and one
    with paginations.
    
    This patch removes the second entry point! Now the `Timeline` receives
    **all** its events via `RoomEventCacheUpdate`.
    
    This patch updates all the appropriate tests accordingly.
    Hywan committed Jun 17, 2024
    Configuration menu
    Copy the full SHA
    091d83d View commit details
    Browse the repository at this point in the history
  4. chore(ui): Remove impl Add for HandleManyEventsResult.

    This patch inlines the `Add` implementation for `HandleManyEventsResult`
    since it's used only once.
    Hywan committed Jun 17, 2024
    Configuration menu
    Copy the full SHA
    e8c8136 View commit details
    Browse the repository at this point in the history
  5. chore(ui): Move the RoomEventCacheUpdate code block into its own fu…

    …nction.
    
    This patch is a refactoring. It moves the code block responsible to
    handle the `RoomEventCacheUpdate`s into its own function for the sake
    of clarity.
    Hywan committed Jun 17, 2024
    Configuration menu
    Copy the full SHA
    a8e4dd6 View commit details
    Browse the repository at this point in the history
  6. test(ui): Add more tests.

    Hywan committed Jun 17, 2024
    Configuration menu
    Copy the full SHA
    049de27 View commit details
    Browse the repository at this point in the history

Commits on Jun 19, 2024

  1. Configuration menu
    Copy the full SHA
    40ab000 View commit details
    Browse the repository at this point in the history