HomePhabricator
Diffusion Comm 63656c7ad703

[lib] Fix pinned messages not working

Description

[lib] Fix pinned messages not working

Summary:
There is an issue with the recently introduced canBeRenderedIndependently code in message specs where I didn't properly account for message specs that do not define this property since its optional.

Right now:

  • if canBeRenderedIndependently is true, then isUnableToBeRenderedIndependently returns false (0 cases)
  • if canBeRenderedIndependently is false, then isUnableToBeRenderedIndependently returns true (2 cases --> edit-message-spec and reaction-message-spec)
  • if canBeRenderedIndependently is undefined, then isUnableToBeRenderedIndependently returns true` (all other cases, i.e. text-message-spec)

This causes a problem since we skip rendering TEXT messages and MULTIMEDIA messages in the pinned messages modal

This diff changes the check so that now:

  • if canBeRenderedIndependently is true, then isUnableToBeRenderedIndependently returns false (0 cases)
  • if canBeRenderedIndependently is false, then isUnableToBeRenderedIndependently returns true (2 cases --> edit-message-spec and reaction-message-spec)
  • if canBeRenderedIndependently is undefined, then isUnableToBeRenderedIndependently returns false` (all other cases, i.e. text-message-spec)

We now only class a message as being unable to rendered independently if its message spec explicitly defines it as false

Test Plan:
Tested across web and native:

  1. Pinned a message
  2. Sent enough messages so the message is not automatically loaded when the chat is opened and the user would have to scroll up to load it
  3. Closed the app and re-opened it
  4. Made sure I could see the pinned message in the pinned messages modal/screen

Besides this, I ran yarn workspace lib test to make sure my existing unit tests for this code didn't break. I can alternatively add more unit tests in message-utils.test.js if needed for other message types

Also made sure to do this testing on the current state of master to repro the issue

Addresses ENG-6009

Reviewers: inka, atul, ginsu

Reviewed By: ginsu

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D10172

Details

Provenance
rohanAuthored on Dec 4 2023, 1:08 PM
Reviewer
ginsu
Differential Revision
D10172: [lib] Fix pinned messages not working
Parents
rCOMM608cc2e82423: [keyserver] Fix error when changing thread description
Branches
Unknown
Tags
Unknown