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"
|
"description": "Label in confirmation modal to disable stories"
|
||||||
},
|
},
|
||||||
"Preferences__turn-stories-off--body": {
|
"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"
|
"description": "Confirmation modal body for disabling stories"
|
||||||
},
|
},
|
||||||
"DialogUpdate--version-available": {
|
"DialogUpdate--version-available": {
|
||||||
|
|
|
@ -57,6 +57,7 @@ export class SettingsChannel extends EventEmitter {
|
||||||
this.installCallback('getDefaultConversationColor');
|
this.installCallback('getDefaultConversationColor');
|
||||||
|
|
||||||
// Various callbacks
|
// Various callbacks
|
||||||
|
this.installCallback('deleteAllMyStories');
|
||||||
this.installCallback('getAvailableIODevices');
|
this.installCallback('getAvailableIODevices');
|
||||||
this.installCallback('isPrimary');
|
this.installCallback('isPrimary');
|
||||||
this.installCallback('syncRequest');
|
this.installCallback('syncRequest');
|
||||||
|
|
|
@ -41,6 +41,7 @@ import {
|
||||||
} from './sgnlHref';
|
} from './sgnlHref';
|
||||||
import { lookupConversationWithoutUuid } from './lookupConversationWithoutUuid';
|
import { lookupConversationWithoutUuid } from './lookupConversationWithoutUuid';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
|
import { deleteAllMyStories } from './deleteAllMyStories';
|
||||||
|
|
||||||
type ThemeType = 'light' | 'dark' | 'system';
|
type ThemeType = 'light' | 'dark' | 'system';
|
||||||
type NotificationSettingType = 'message' | 'name' | 'count' | 'off';
|
type NotificationSettingType = 'message' | 'name' | 'count' | 'off';
|
||||||
|
@ -94,6 +95,7 @@ export type IPCEventsCallbacksType = {
|
||||||
addCustomColor: (customColor: CustomColorType) => void;
|
addCustomColor: (customColor: CustomColorType) => void;
|
||||||
addDarkOverlay: () => void;
|
addDarkOverlay: () => void;
|
||||||
deleteAllData: () => Promise<void>;
|
deleteAllData: () => Promise<void>;
|
||||||
|
deleteAllMyStories: () => Promise<void>;
|
||||||
closeDB: () => Promise<void>;
|
closeDB: () => Promise<void>;
|
||||||
editCustomColor: (colorId: string, customColor: CustomColorType) => void;
|
editCustomColor: (colorId: string, customColor: CustomColorType) => void;
|
||||||
getConversationsWithCustomColor: (x: string) => Array<ConversationType>;
|
getConversationsWithCustomColor: (x: string) => Array<ConversationType>;
|
||||||
|
@ -205,6 +207,10 @@ export function createIPCEvents(
|
||||||
setPreferredVideoInputDevice: device =>
|
setPreferredVideoInputDevice: device =>
|
||||||
window.storage.put('preferred-video-input-device', device),
|
window.storage.put('preferred-video-input-device', device),
|
||||||
|
|
||||||
|
deleteAllMyStories: async () => {
|
||||||
|
await deleteAllMyStories();
|
||||||
|
},
|
||||||
|
|
||||||
// Chat Color redux hookups
|
// Chat Color redux hookups
|
||||||
getCustomColors: () => {
|
getCustomColors: () => {
|
||||||
return getCustomColors(window.reduxStore.getState()) || {};
|
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,
|
setter: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
installCallback('deleteAllMyStories');
|
||||||
installCallback('isPhoneNumberSharingEnabled');
|
installCallback('isPhoneNumberSharingEnabled');
|
||||||
installCallback('isPrimary');
|
installCallback('isPrimary');
|
||||||
installCallback('shouldShowStoriesSettings');
|
installCallback('shouldShowStoriesSettings');
|
||||||
|
|
|
@ -88,6 +88,7 @@ const ipcPNP = createCallback('isPhoneNumberSharingEnabled');
|
||||||
const ipcShouldShowStoriesSettings = createCallback(
|
const ipcShouldShowStoriesSettings = createCallback(
|
||||||
'shouldShowStoriesSettings'
|
'shouldShowStoriesSettings'
|
||||||
);
|
);
|
||||||
|
const ipcDeleteAllMyStories = createCallback('deleteAllMyStories');
|
||||||
|
|
||||||
// ChatColorPicker redux hookups
|
// ChatColorPicker redux hookups
|
||||||
// The redux actions update over IPC through a preferences re-render
|
// The redux actions update over IPC through a preferences re-render
|
||||||
|
@ -301,7 +302,13 @@ const renderPreferences = async () => {
|
||||||
onCountMutedConversationsChange: reRender(
|
onCountMutedConversationsChange: reRender(
|
||||||
settingCountMutedConversations.setValue
|
settingCountMutedConversations.setValue
|
||||||
),
|
),
|
||||||
onHasStoriesDisabledChanged: reRender(settingHasStoriesDisabled.setValue),
|
onHasStoriesDisabledChanged: reRender(async (value: boolean) => {
|
||||||
|
await settingHasStoriesDisabled.setValue(value);
|
||||||
|
if (!value) {
|
||||||
|
ipcDeleteAllMyStories();
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}),
|
||||||
onHideMenuBarChange: reRender(settingHideMenuBar.setValue),
|
onHideMenuBarChange: reRender(settingHideMenuBar.setValue),
|
||||||
onIncomingCallNotificationsChange: reRender(
|
onIncomingCallNotificationsChange: reRender(
|
||||||
settingIncomingCallNotification.setValue
|
settingIncomingCallNotification.setValue
|
||||||
|
|
Loading…
Add table
Reference in a new issue