From b2792639aa037fe358643c5e0d12220c387985e1 Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Thu, 13 Oct 2022 12:14:50 -0400 Subject: [PATCH] DOE stories when they are part of deleted lists --- _locales/en/messages.json | 2 +- ts/components/SendStoryModal.tsx | 23 +-- ts/components/StoriesSettingsModal.tsx | 24 +-- ts/state/ducks/stories.ts | 174 +--------------------- ts/state/ducks/storyDistributionLists.ts | 11 +- ts/util/deleteStoryForEveryone.ts | 181 +++++++++++++++++++++++ 6 files changed, 226 insertions(+), 189 deletions(-) create mode 100644 ts/util/deleteStoryForEveryone.ts diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 12e346c913fe..8965353e4684 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -5516,7 +5516,7 @@ "description": "Button label to delete a private distribution list" }, "StoriesSettings__delete-list--confirm": { - "message": "Delete private story?", + "message": "Are you sure you want to delete \"$name$\"? Updates shared to this story will also be deleted.", "description": "Confirmation text to delete a private distribution list" }, "StoriesSettings__choose-viewers": { diff --git a/ts/components/SendStoryModal.tsx b/ts/components/SendStoryModal.tsx index e98af7281791..d496d829d7a1 100644 --- a/ts/components/SendStoryModal.tsx +++ b/ts/components/SendStoryModal.tsx @@ -214,8 +214,8 @@ export const SendStoryModal = ({ const [confirmRemoveGroupId, setConfirmRemoveGroupId] = useState< string | undefined >(); - const [confirmDeleteListId, setConfirmDeleteListId] = useState< - string | undefined + const [confirmDeleteList, setConfirmDeleteList] = useState< + { id: string; name: string } | undefined >(); const [listIdToEdit, setListIdToEdit] = useState(); @@ -397,7 +397,7 @@ export const SendStoryModal = ({ listToEdit={listToEdit} onRemoveMember={onRemoveMember} onRepliesNReactionsChanged={onRepliesNReactionsChanged} - setConfirmDeleteListId={setConfirmDeleteListId} + setConfirmDeleteList={setConfirmDeleteList} setMyStoriesToAllSignalConnections={setMyStoriesToAllSignalConnections} setPage={setPage} setSelectedContacts={setSelectedContacts} @@ -719,7 +719,7 @@ export const SendStoryModal = ({ { label: i18n('SendStoryModal__delete-story'), icon: 'SendStoryModal__icon--delete', - onClick: () => setConfirmDeleteListId(list.id), + onClick: () => setConfirmDeleteList(list), }, ] } @@ -897,19 +897,19 @@ export const SendStoryModal = ({ onClose={() => { setConfirmRemoveGroupId(undefined); }} + theme={Theme.Dark} > {i18n('SendStoryModal__confirm-remove-group')} )} - {confirmDeleteListId && ( + {confirmDeleteList && ( { - onDeleteList(confirmDeleteListId); - setConfirmDeleteListId(undefined); - // setListToEditId(undefined); + onDeleteList(confirmDeleteList.id); + setConfirmDeleteList(undefined); }, style: 'negative', text: i18n('delete'), @@ -917,10 +917,13 @@ export const SendStoryModal = ({ ]} i18n={i18n} onClose={() => { - setConfirmDeleteListId(undefined); + setConfirmDeleteList(undefined); }} + theme={Theme.Dark} > - {i18n('StoriesSettings__delete-list--confirm')} + {i18n('StoriesSettings__delete-list--confirm', [ + confirmDeleteList.name, + ])} )} {confirmDiscardModal} diff --git a/ts/components/StoriesSettingsModal.tsx b/ts/components/StoriesSettingsModal.tsx index 73bd0af586cd..788b57b63e75 100644 --- a/ts/components/StoriesSettingsModal.tsx +++ b/ts/components/StoriesSettingsModal.tsx @@ -126,8 +126,8 @@ export const StoriesSettingsModal = ({ setPage(Page.DistributionLists); }, []); - const [confirmDeleteListId, setConfirmDeleteListId] = useState< - string | undefined + const [confirmDeleteList, setConfirmDeleteList] = useState< + { id: string; name: string } | undefined >(); let modal: RenderModalPage | null; @@ -188,7 +188,7 @@ export const StoriesSettingsModal = ({ listToEdit={listToEdit} onRemoveMember={onRemoveMember} onRepliesNReactionsChanged={onRepliesNReactionsChanged} - setConfirmDeleteListId={setConfirmDeleteListId} + setConfirmDeleteList={setConfirmDeleteList} setMyStoriesToAllSignalConnections={setMyStoriesToAllSignalConnections} setPage={setPage} setSelectedContacts={setSelectedContacts} @@ -297,13 +297,13 @@ export const StoriesSettingsModal = ({ {modal} )} - {confirmDeleteListId && ( + {confirmDeleteList && ( { - onDeleteList(confirmDeleteListId); + onDeleteList(confirmDeleteList.id); setListToEditId(undefined); }, style: 'negative', @@ -312,10 +312,13 @@ export const StoriesSettingsModal = ({ ]} i18n={i18n} onClose={() => { - setConfirmDeleteListId(undefined); + setConfirmDeleteList(undefined); }} + theme={Theme.Dark} > - {i18n('StoriesSettings__delete-list--confirm')} + {i18n('StoriesSettings__delete-list--confirm', [ + confirmDeleteList.name, + ])} )} {confirmDiscardModal} @@ -326,7 +329,7 @@ export const StoriesSettingsModal = ({ type DistributionListSettingsModalPropsType = { i18n: LocalizerType; listToEdit: StoryDistributionListWithMembersDataType; - setConfirmDeleteListId: (id: string) => unknown; + setConfirmDeleteList: (_: { id: string; name: string }) => unknown; setPage: (page: Page) => unknown; setSelectedContacts: (contacts: Array) => unknown; onBackButtonClick: (() => void) | undefined; @@ -348,7 +351,7 @@ export const DistributionListSettingsModal = ({ onRepliesNReactionsChanged, onBackButtonClick, onClose, - setConfirmDeleteListId, + setConfirmDeleteList, setMyStoriesToAllSignalConnections, setPage, setSelectedContacts, @@ -504,7 +507,7 @@ export const DistributionListSettingsModal = ({