Open rlinoz opened 2 weeks ago
Need to stop highlighting report mentions in non policy rooms.
As of now, mentionReport is always using theme.mentionText
and theme.mentionBG
in the markdown style which leads to the highlighting.
We'll add a new argument to useMarkdownStyle
.
function useMarkdownStyle(message: string | null = null, shouldUseMentionReport = true)
Updated logic for styles of mentionReport
:
mentionReport: {
color: shouldUseMentionReport ? theme.mentionText : null,
backgroundColor: shouldUseMentionReport ? theme.mentionBG : null,
},
Pass isGroupPolicyReport
as a prop to Composer via ComposerWithSuggestions
.
isGroupPolicyReport={isGroupPolicyReport}
We'll update Composer function signature in both index.tsx and index.native.tsx.
Now, we can pass the same to useMarkdownStyle as the value of shouldUseMentionReport
by updating this code: Link.
const markdownStyle = useMarkdownStyle(value, isGroupPolicyReport);
We'll do the same in index.native.tsx also:
Hi @rlinoz! I'll look into it
mentionReport
style without checking if the report belongs to policy or not, that leads to 2 bug:
AddComment
is successful.
For example, assume that the suggestedMentions
contains a few options: [announce, admin, room-1, room-2, room-3]
then if user types #room-1
, the typed text is highlighted.
If user types room-4
, the typed text is not highlighted because there is no option is room-4
.
Here is the implementation:
function doesRoomExisted(roomName: string, listRoomName: string[]) {
return listRoomName.includes(roomName);
}
which its inputs are the roomName
and listRoomName
, and return the boolean value to know if the given room named belongs to the current policy or not . In there above example, doesRoomExisted('room-1', ['announce', 'admin', 'room-1', 'room-2', 'room-3'])
returns true
Then update this to:
mentionReport: doesRoomExisted(message, listRoomName) ? {
color: theme.mentionText,
backgroundColor: theme.mentionBG,
}: {},
this step is straightforward so I do not implement the details. The main idea of this step is we will check if the typed text exists in the list room that can be mentioned. If true, apply the highlight style.
Also, we need to apply the change in .native.ts
file
Now our main bug is fixed. But there is another issue that I mentioned in the RCA section. For example in the above example is room-4
, that message is highlighted for a while before the AddComment
is called successfully. It is because in here, we apply the mention-report
tag in case of isGroupPolicyReport
. We should use doesRoomExisted
along with doesRoomExisted
I updated the proposal
Sorry we aligned on Slack that this one should go to Robert since he was the one adding the styling to report mentions.
@rlinoz I found another related bug: In policy room chat, when typing any room name that does not belong to the policy, the typed text is still highlighted. Then send a message. That message is still highlighted until the API AddComment is successful.
Can you confirm if it is a bug? Thanks
Hi @nkdengineer I think it's not actually a bug - If there is no rrom with such a name, we will send actionable whisper with an option to create it. Checking for the room existance is not a valid one in this case. CMIIW
we will send actionable whisper with an option to create it
@robertKozik This feature is not implemented in staging, right? (So I think It will be handled in the future).
Thanks for your information!
I believe frontend implementation is already merged, only backend part is not yet in staging. But I'm not so up-to-date on it 😄
@rlinoz I've created draft PR for this one. I went with more general solution and implement the rule excluding mechanism. Feel free to test and comment - I'll add the remaining screenshots and the rest later today.
Triggered auto assignment to @thienlnam, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
Problem: While typing a report mention in the composer in a DM or group chat the mention is highlighted, even though it is not possible to mention a report in this types o chats.
Solution: We need to stop applying the markdown style to report mentions in reports that don't belong to a group policy.