HomePhabricator
Diffusion Comm 4d82efb73b23

[lib/web/native] Unify logic to check canTogglePins in web and native tooltips

Description

[lib/web/native] Unify logic to check canTogglePins in web and native tooltips

Summary:
This diff unifies the logic for checking whether a client can toggle a pin. Previously, there was a hacky check in two places (threadInfo.sourceMessageID === messageInfo.id), as well as duplicated checking logic across web and native.

This diff achieves a few things to clean this code up:

  • For native, it moves the call to check whether the client can toggle pins up to message.react.js so it can be passed in as a prop to both TextMessage and MultimediaMessage. This is better than duplicating the call in the individual components.
  • Updated isInvalidPinSource to take in an optional parameter threadInfo, and if defined we can do the aforementioned check here in one place.
    • In my opinion, this is better than doing this in all of the individual message specs since that’s going to result in a ton of copy and pasted hacky checks.
    • This optional parameter will not be provided from callsites to isInvalidPinSource from the server
  • Creates a helper function canToggleMessagePin that is used for the client tooltips. This will check both isInvalidSidebarSource and also whether the client thread has permission to manage pins.

Resolves ENG-5619

Depends on D9634

Test Plan: Verified that the tooltip option to pin messages still appears on both web and native when it should/shouldn't

Reviewers: atul, ginsu, ashoat

Reviewed By: ashoat

Subscribers: ashoat, tomek, wyilio

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

Details

Provenance
rohanAuthored on Oct 30 2023, 9:22 AM
Reviewer
ashoat
Differential Revision
D9638: [lib/web/native] Unify logic to check canTogglePins in web and native tooltips
Parents
rCOMM594eeb632361: [native] Check isInvalidPinSource on native
Branches
Unknown
Tags
Unknown