Page MenuHomePhabricator

[lib] Update the replies count
ClosedPublic

Authored by tomek on Aug 13 2024, 5:44 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Sep 16, 3:18 AM
Unknown Object (File)
Sun, Sep 15, 9:07 AM
Unknown Object (File)
Sun, Sep 15, 9:06 AM
Unknown Object (File)
Tue, Sep 10, 1:31 PM
Unknown Object (File)
Tue, Sep 10, 12:10 PM
Unknown Object (File)
Mon, Sep 9, 5:05 AM
Unknown Object (File)
Mon, Sep 9, 3:42 AM
Unknown Object (File)
Thu, Sep 5, 2:35 PM
Subscribers

Details

Summary
  1. Get all the updated threads from the updates.
  2. Group the threads and get the most recent one - some specs can generate multiple thread updates, and we want to have the thread from the last update, because this thread is the most recent and will end up being put into Redux and DB.
  3. Count the messages.
  4. Generate a new update with an updated thread by increasing its replies count.

https://linear.app/comm/issue/ENG-8930/unify-the-approach-to-replies-count-and-unread-status-updates

Depends on D13058

Test Plan

Tested change thread setting and send text message operations. Verified that only send text message operation bums the replies count.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

tomek requested review of this revision.Aug 13 2024, 6:05 AM
This revision is now accepted and ready to land.Aug 19 2024, 6:11 AM
inka requested changes to this revision.Aug 19 2024, 6:18 AM

We tested sidebar creation and replies count is incorrect - after creating a sidebar and adding one message to it, the count was 2 instead of 1

This revision now requires changes to proceed.Aug 19 2024, 6:18 AM
tomek requested review of this revision.Aug 20 2024, 4:40 AM
In D13059#369998, @inka wrote:

We tested sidebar creation and replies count is incorrect - after creating a sidebar and adding one message to it, the count was 2 instead of 1

Tested it a couple more times and was unable to reproduce this bug. I guess that something was wrong with the operations we were processing.
I tested it using following operations:

const tid = uuid.v4();
      await this.props.processDMOps({
        type: 'create_thread',
        threadID: tid,
        creatorID: viewerID,
        time: Date.now(),
        threadType: threadTypes.LOCAL,
        memberIDs: [],
        roleID: uuid.v4(),
        newMessageID: uuid.v4(),
      });
      const mid = uuid.v4();
      await this.props.processDMOps({
        type: 'send_text_message',
        threadID: tid,
        creatorID: viewerID,
        time: Date.now(),
        messageID: mid,
        text: `${text}-parent`,
      });
      await sleep(100);
      const sid = uuid.v4();
      await this.props.processDMOps({
        type: 'create_sidebar',
        threadID: sid,
        creatorID: viewerID,
        time: Date.now(),
        parentThreadID: tid,
        memberIDs: [],
        sourceMessageID: mid,
        roleID: uuid.v4(),
        newSidebarSourceMessageID: uuid.v4(),
        newCreateSidebarMessageID: uuid.v4(),
      });
      await this.props.processDMOps({
        type: 'send_text_message',
        threadID: sid,
        creatorID: viewerID,
        time: Date.now(),
        messageID: uuid.v4(),
        text: `${text}-sidebar`,
      });
This revision is now accepted and ready to land.Aug 20 2024, 8:32 AM
This revision was automatically updated to reflect the committed changes.