Delete sent stories when you turn off stories
This commit is contained in:
parent
622f61903b
commit
3e57899006
6 changed files with 32 additions and 2 deletions
|
@ -5244,7 +5244,7 @@
|
|||
"description": "Label in confirmation modal to disable stories"
|
||||
},
|
||||
"Preferences__turn-stories-off--body": {
|
||||
"message": "You will no longer be able to share or view stories.",
|
||||
"message": "You will no longer be able to share or view stories. Story updates you have recently shared will also be deleted.",
|
||||
"description": "Confirmation modal body for disabling stories"
|
||||
},
|
||||
"DialogUpdate--version-available": {
|
||||
|
|
|
@ -57,6 +57,7 @@ export class SettingsChannel extends EventEmitter {
|
|||
this.installCallback('getDefaultConversationColor');
|
||||
|
||||
// Various callbacks
|
||||
this.installCallback('deleteAllMyStories');
|
||||
this.installCallback('getAvailableIODevices');
|
||||
this.installCallback('isPrimary');
|
||||
this.installCallback('syncRequest');
|
||||
|
|
|
@ -41,6 +41,7 @@ import {
|
|||
} from './sgnlHref';
|
||||
import { lookupConversationWithoutUuid } from './lookupConversationWithoutUuid';
|
||||
import * as log from '../logging/log';
|
||||
import { deleteAllMyStories } from './deleteAllMyStories';
|
||||
|
||||
type ThemeType = 'light' | 'dark' | 'system';
|
||||
type NotificationSettingType = 'message' | 'name' | 'count' | 'off';
|
||||
|
@ -94,6 +95,7 @@ export type IPCEventsCallbacksType = {
|
|||
addCustomColor: (customColor: CustomColorType) => void;
|
||||
addDarkOverlay: () => void;
|
||||
deleteAllData: () => Promise<void>;
|
||||
deleteAllMyStories: () => Promise<void>;
|
||||
closeDB: () => Promise<void>;
|
||||
editCustomColor: (colorId: string, customColor: CustomColorType) => void;
|
||||
getConversationsWithCustomColor: (x: string) => Array<ConversationType>;
|
||||
|
@ -205,6 +207,10 @@ export function createIPCEvents(
|
|||
setPreferredVideoInputDevice: device =>
|
||||
window.storage.put('preferred-video-input-device', device),
|
||||
|
||||
deleteAllMyStories: async () => {
|
||||
await deleteAllMyStories();
|
||||
},
|
||||
|
||||
// Chat Color redux hookups
|
||||
getCustomColors: () => {
|
||||
return getCustomColors(window.reduxStore.getState()) || {};
|
||||
|
|
15
ts/util/deleteAllMyStories.ts
Normal file
15
ts/util/deleteAllMyStories.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { deleteStoryForEveryone } from './deleteStoryForEveryone';
|
||||
|
||||
export async function deleteAllMyStories(): Promise<void> {
|
||||
const { stories } = window.reduxStore.getState().stories;
|
||||
const myStories = stories.filter(story =>
|
||||
Boolean(story.sendStateByConversationId)
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
myStories.map(story => deleteStoryForEveryone(stories, story))
|
||||
);
|
||||
}
|
|
@ -39,6 +39,7 @@ installSetting('typingIndicatorSetting', {
|
|||
setter: false,
|
||||
});
|
||||
|
||||
installCallback('deleteAllMyStories');
|
||||
installCallback('isPhoneNumberSharingEnabled');
|
||||
installCallback('isPrimary');
|
||||
installCallback('shouldShowStoriesSettings');
|
||||
|
|
|
@ -88,6 +88,7 @@ const ipcPNP = createCallback('isPhoneNumberSharingEnabled');
|
|||
const ipcShouldShowStoriesSettings = createCallback(
|
||||
'shouldShowStoriesSettings'
|
||||
);
|
||||
const ipcDeleteAllMyStories = createCallback('deleteAllMyStories');
|
||||
|
||||
// ChatColorPicker redux hookups
|
||||
// The redux actions update over IPC through a preferences re-render
|
||||
|
@ -301,7 +302,13 @@ const renderPreferences = async () => {
|
|||
onCountMutedConversationsChange: reRender(
|
||||
settingCountMutedConversations.setValue
|
||||
),
|
||||
onHasStoriesDisabledChanged: reRender(settingHasStoriesDisabled.setValue),
|
||||
onHasStoriesDisabledChanged: reRender(async (value: boolean) => {
|
||||
await settingHasStoriesDisabled.setValue(value);
|
||||
if (!value) {
|
||||
ipcDeleteAllMyStories();
|
||||
}
|
||||
return value;
|
||||
}),
|
||||
onHideMenuBarChange: reRender(settingHideMenuBar.setValue),
|
||||
onIncomingCallNotificationsChange: reRender(
|
||||
settingIncomingCallNotification.setValue
|
||||
|
|
Loading…
Reference in a new issue