fix(threads): confirm before leaving a private thread (#3299)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-08 17:44:00 +02:00
1 parent 170e12595b
commit 269d33cab2
37 files changed
+2315 -1940

No files matched your search

@@ -88,6 +88,21 @@ export function confirmDeleteThread(i18n: I18n, thread: Channel): void {
);
}
function confirmLeavePrivateThread(i18n: I18n, thread: Channel): void {
ModalCommands.push(
modal(() => (
<ConfirmModal
title={i18n._(D.LEAVE_PRIVATE_THREAD_TITLE_DESCRIPTOR)}
description={i18n._(D.LEAVE_PRIVATE_THREAD_CONFIRM_DESCRIPTOR, {threadName: thread.name ?? ''})}
primaryText={i18n._(D.LEAVE_THREAD_DESCRIPTOR)}
primaryVariant="danger"
onPrimary={() => run(i18n, () => ThreadCommands.leaveThread(thread))}
data-flx="threads.use-thread-menu-data.confirm-leave-private-thread"
/>
)),
);
}
export function buildThreadNotificationItems(i18n: I18n, thread: Channel): Array<MenuSheetItem> {
const current = getThreadNotificationSetting(thread.id);
const options: Array<[ThreadNotificationSetting, string]> = [
@@ -216,10 +231,14 @@ export function useThreadMenuData(thread: Channel, {onClose}: {onClose: () => vo
manageItems.push({
icon: <LeaveIcon size={20} data-flx="threads.use-thread-menu-data.leave-icon" />,
label: i18n._(D.LEAVE_THREAD_DESCRIPTOR),
danger: true,
danger: thread.isPrivateThread(),
onClick: () => {
run(i18n, () => ThreadCommands.leaveThread(thread));
onClose();
if (thread.isPrivateThread()) {
confirmLeavePrivateThread(i18n, thread);
return;
}
run(i18n, () => ThreadCommands.leaveThread(thread));
},
});
}
@@ -58,6 +58,14 @@ export const LEAVE_THREAD_DESCRIPTOR = msg({
message: 'Leave thread',
comment: 'Action that removes the current user from a thread.',
});
export const LEAVE_PRIVATE_THREAD_TITLE_DESCRIPTOR = msg({
message: 'Leave private thread',
comment: 'Title of the confirmation dialog shown before leaving a private thread.',
});
export const LEAVE_PRIVATE_THREAD_CONFIRM_DESCRIPTOR = msg({
message: "Leave {threadName}? It's private, so you can only come back if someone adds you again.",
comment: 'Confirmation text before leaving a private thread. threadName is the thread name.',
});
export const REMOVE_FROM_THREAD_DESCRIPTOR = msg({
message: 'Remove from thread',
comment: 'Moderation action that removes the selected member from a thread.',