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)
Wed, Nov 20, 9:25 PM
Unknown Object (File)
Wed, Nov 20, 9:24 PM
Unknown Object (File)
Sun, Nov 10, 2:35 AM
Unknown Object (File)
Sat, Nov 9, 3:56 PM
Unknown Object (File)
Sat, Nov 9, 9:40 AM
Unknown Object (File)
Sat, Nov 9, 4:03 AM
Unknown Object (File)
Sat, Nov 9, 3:51 AM
Unknown Object (File)
Sat, Nov 9, 3:41 AM
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.