fix(chat): gate store-team grouping behind viewer_is_store
The team-side logic (teamUserIds → right-aligned + coworker username label) was applied for every viewer, so a CUSTOMER saw the store's staff messages on their own side and with the staff's username/phone shown. Gate all team grouping on viewerIsStore (from the thread): customers now see store/staff messages on the left with no staff identity; the store inbox keeps the team-grouped view. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
0360780411
commit
f8bf002b39
@ -23,6 +23,7 @@ const MessageList = forwardRef(
|
|||||||
isFetching,
|
isFetching,
|
||||||
userId,
|
userId,
|
||||||
teamUserIds,
|
teamUserIds,
|
||||||
|
viewerIsStore = false,
|
||||||
onReply,
|
onReply,
|
||||||
onDelete,
|
onDelete,
|
||||||
onScroll,
|
onScroll,
|
||||||
@ -32,10 +33,13 @@ const MessageList = forwardRef(
|
|||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
isFetching: boolean;
|
isFetching: boolean;
|
||||||
userId: string | undefined;
|
userId: string | undefined;
|
||||||
// When present, any message sender in this set is treated as "our side"
|
// Senders on the store team. Only treated as "our side" when the VIEWER
|
||||||
// (right-aligned, blue). Lets staff see coworkers' messages on the team
|
// is store-side (viewerIsStore) — otherwise a customer would wrongly see
|
||||||
// side of the store inbox instead of confusing them with customer messages.
|
// the store's staff messages on their own (right) side.
|
||||||
teamUserIds?: readonly string[];
|
teamUserIds?: readonly string[];
|
||||||
|
// True when the current viewer is on this thread's store team. Gates all
|
||||||
|
// team-grouping so the customer view stays "my messages right, store left".
|
||||||
|
viewerIsStore?: boolean;
|
||||||
onReply: (message: MessageListType) => void;
|
onReply: (message: MessageListType) => void;
|
||||||
onDelete?: (messageId: string) => void;
|
onDelete?: (messageId: string) => void;
|
||||||
onScroll?: (event: React.UIEvent<HTMLDivElement>) => void;
|
onScroll?: (event: React.UIEvent<HTMLDivElement>) => void;
|
||||||
@ -170,9 +174,12 @@ const MessageList = forwardRef(
|
|||||||
message={message}
|
message={message}
|
||||||
isCurrentUser={
|
isCurrentUser={
|
||||||
message.sender === userId ||
|
message.sender === userId ||
|
||||||
(!!message.sender && !!teamUserIds?.includes(message.sender))
|
(viewerIsStore &&
|
||||||
|
!!message.sender &&
|
||||||
|
!!teamUserIds?.includes(message.sender))
|
||||||
}
|
}
|
||||||
isCoworker={
|
isCoworker={
|
||||||
|
viewerIsStore &&
|
||||||
message.sender !== userId &&
|
message.sender !== userId &&
|
||||||
!!message.sender &&
|
!!message.sender &&
|
||||||
!!teamUserIds?.includes(message.sender)
|
!!teamUserIds?.includes(message.sender)
|
||||||
|
|||||||
@ -286,6 +286,7 @@ export default function ThreadChatPage({ threadId }: ThreadChatPageProps) {
|
|||||||
isFetching={isFetchingNextPage}
|
isFetching={isFetchingNextPage}
|
||||||
userId={user?.id}
|
userId={user?.id}
|
||||||
teamUserIds={threadDetails?.teamUserIds}
|
teamUserIds={threadDetails?.teamUserIds}
|
||||||
|
viewerIsStore={threadDetails?.viewerIsStore}
|
||||||
onReply={handleReplyClick}
|
onReply={handleReplyClick}
|
||||||
onDelete={handleDeleteMessage}
|
onDelete={handleDeleteMessage}
|
||||||
onScroll={handleScroll}
|
onScroll={handleScroll}
|
||||||
|
|||||||
@ -6587,6 +6587,12 @@ export interface ThreadDetail {
|
|||||||
* @memberof ThreadDetail
|
* @memberof ThreadDetail
|
||||||
*/
|
*/
|
||||||
readonly teamUserIds?: Array<string>;
|
readonly teamUserIds?: Array<string>;
|
||||||
|
/**
|
||||||
|
* True when the viewer is on this thread's store team (owner/staff).
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof ThreadDetail
|
||||||
|
*/
|
||||||
|
readonly viewerIsStore?: boolean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user