Skip to content

WIP: Seed chat data to the chatCollection

Tomas Vik requested to merge 2276-seed-data-for-chats into develop

Closes #2276

This is an early draft of how we could seed chat data to the chat collection. The issues in this code that would need to be solved before there is a chance of merging:

https://gitlab.com/gitlab-org/gitter/realtime-client/-/blob/master/lib/live-collection.js#L180

handleSnapshot: function(snapshot) {
    /**
     * Don't remove items from the collections, as there is a greater
     * chance that they've been added on the client than that they've
     * been removed from the server. One day we may want to handle the
     * case that the server object has been removed, but it's not that
     * likely and doesn't warrant the extra complexity
     */
    var options = {
      parse: true,    /* parse the items */
      remove: true,
      add: true,      /* add new items */
      merge: true     /* merge into items that already exist */
    };

    if(this.length > 0) {
      debug('Performing merge on snapshot (current length is %s)', this.length);
      this.set(snapshot, options);
    } else {
      debug('Performing reset on snapshot');
      // trash it and add all in one go
      this.reset(snapshot, options);
    }

    this.trigger('sync');
    this.trigger('snapshot');
  },
  • create a generic "seed data" object on the window, instead of reusing troupeContext
  • add the seed data to messageMap because otherwise we won't have parents to open TMF

As expected this fixes the #2276 But I still have no idea what is the root cause.

Edited by 🤖 GitLab Bot 🤖

Merge request reports