Sync storiesDisabled
flag on AccountRecord
This commit is contained in:
parent
3e57cb8549
commit
8b705d3b55
11 changed files with 42 additions and 35 deletions
|
@ -155,6 +155,8 @@ message AccountRecord {
|
||||||
optional bool displayBadgesOnProfile = 23;
|
optional bool displayBadgesOnProfile = 23;
|
||||||
optional bool keepMutedChatsArchived = 25;
|
optional bool keepMutedChatsArchived = 25;
|
||||||
optional bool hasSetMyStoriesPrivacy = 26;
|
optional bool hasSetMyStoriesPrivacy = 26;
|
||||||
|
reserved /* hasViewedOnboardingStory */ 27;
|
||||||
|
optional bool storiesDisabled = 28;
|
||||||
}
|
}
|
||||||
|
|
||||||
message StoryDistributionListRecord {
|
message StoryDistributionListRecord {
|
||||||
|
|
|
@ -87,7 +87,7 @@ const getDefaultArgs = (): PropsDataType => ({
|
||||||
hasReadReceipts: true,
|
hasReadReceipts: true,
|
||||||
hasRelayCalls: false,
|
hasRelayCalls: false,
|
||||||
hasSpellCheck: true,
|
hasSpellCheck: true,
|
||||||
hasStoriesEnabled: true,
|
hasStoriesDisabled: false,
|
||||||
hasTypingIndicators: true,
|
hasTypingIndicators: true,
|
||||||
initialSpellCheckSetting: true,
|
initialSpellCheckSetting: true,
|
||||||
isAudioNotificationsSupported: true,
|
isAudioNotificationsSupported: true,
|
||||||
|
@ -142,7 +142,7 @@ export default {
|
||||||
onCallNotificationsChange: { action: true },
|
onCallNotificationsChange: { action: true },
|
||||||
onCallRingtoneNotificationChange: { action: true },
|
onCallRingtoneNotificationChange: { action: true },
|
||||||
onCountMutedConversationsChange: { action: true },
|
onCountMutedConversationsChange: { action: true },
|
||||||
onHasStoriesEnabledChanged: { action: true },
|
onHasStoriesDisabledChanged: { action: true },
|
||||||
onHideMenuBarChange: { action: true },
|
onHideMenuBarChange: { action: true },
|
||||||
onIncomingCallNotificationsChange: { action: true },
|
onIncomingCallNotificationsChange: { action: true },
|
||||||
onLastSyncTimeChange: { action: true },
|
onLastSyncTimeChange: { action: true },
|
||||||
|
|
|
@ -68,7 +68,7 @@ export type PropsDataType = {
|
||||||
hasReadReceipts: boolean;
|
hasReadReceipts: boolean;
|
||||||
hasRelayCalls?: boolean;
|
hasRelayCalls?: boolean;
|
||||||
hasSpellCheck: boolean;
|
hasSpellCheck: boolean;
|
||||||
hasStoriesEnabled: boolean;
|
hasStoriesDisabled: boolean;
|
||||||
hasTypingIndicators: boolean;
|
hasTypingIndicators: boolean;
|
||||||
lastSyncTime?: number;
|
lastSyncTime?: number;
|
||||||
notificationContent: NotificationSettingType;
|
notificationContent: NotificationSettingType;
|
||||||
|
@ -133,7 +133,7 @@ type PropsFunctionType = {
|
||||||
onCallNotificationsChange: CheckboxChangeHandlerType;
|
onCallNotificationsChange: CheckboxChangeHandlerType;
|
||||||
onCallRingtoneNotificationChange: CheckboxChangeHandlerType;
|
onCallRingtoneNotificationChange: CheckboxChangeHandlerType;
|
||||||
onCountMutedConversationsChange: CheckboxChangeHandlerType;
|
onCountMutedConversationsChange: CheckboxChangeHandlerType;
|
||||||
onHasStoriesEnabledChanged: SelectChangeHandlerType<boolean>;
|
onHasStoriesDisabledChanged: SelectChangeHandlerType<boolean>;
|
||||||
onHideMenuBarChange: CheckboxChangeHandlerType;
|
onHideMenuBarChange: CheckboxChangeHandlerType;
|
||||||
onIncomingCallNotificationsChange: CheckboxChangeHandlerType;
|
onIncomingCallNotificationsChange: CheckboxChangeHandlerType;
|
||||||
onLastSyncTimeChange: (time: number) => unknown;
|
onLastSyncTimeChange: (time: number) => unknown;
|
||||||
|
@ -228,7 +228,7 @@ export const Preferences = ({
|
||||||
hasReadReceipts,
|
hasReadReceipts,
|
||||||
hasRelayCalls,
|
hasRelayCalls,
|
||||||
hasSpellCheck,
|
hasSpellCheck,
|
||||||
hasStoriesEnabled,
|
hasStoriesDisabled,
|
||||||
hasTypingIndicators,
|
hasTypingIndicators,
|
||||||
i18n,
|
i18n,
|
||||||
initialSpellCheckSetting,
|
initialSpellCheckSetting,
|
||||||
|
@ -251,7 +251,7 @@ export const Preferences = ({
|
||||||
onCallNotificationsChange,
|
onCallNotificationsChange,
|
||||||
onCallRingtoneNotificationChange,
|
onCallRingtoneNotificationChange,
|
||||||
onCountMutedConversationsChange,
|
onCountMutedConversationsChange,
|
||||||
onHasStoriesEnabledChanged,
|
onHasStoriesDisabledChanged,
|
||||||
onHideMenuBarChange,
|
onHideMenuBarChange,
|
||||||
onIncomingCallNotificationsChange,
|
onIncomingCallNotificationsChange,
|
||||||
onLastSyncTimeChange,
|
onLastSyncTimeChange,
|
||||||
|
@ -977,7 +977,14 @@ export const Preferences = ({
|
||||||
</label>
|
</label>
|
||||||
}
|
}
|
||||||
right={
|
right={
|
||||||
hasStoriesEnabled ? (
|
hasStoriesDisabled ? (
|
||||||
|
<Button
|
||||||
|
onClick={() => onHasStoriesDisabledChanged(false)}
|
||||||
|
variant={ButtonVariant.Secondary}
|
||||||
|
>
|
||||||
|
{i18n('Preferences__turn-stories-on')}
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
<Button
|
<Button
|
||||||
className="Preferences__stories-off"
|
className="Preferences__stories-off"
|
||||||
onClick={() => setConfirmStoriesOff(true)}
|
onClick={() => setConfirmStoriesOff(true)}
|
||||||
|
@ -985,13 +992,6 @@ export const Preferences = ({
|
||||||
>
|
>
|
||||||
{i18n('Preferences__turn-stories-off')}
|
{i18n('Preferences__turn-stories-off')}
|
||||||
</Button>
|
</Button>
|
||||||
) : (
|
|
||||||
<Button
|
|
||||||
onClick={() => onHasStoriesEnabledChanged(true)}
|
|
||||||
variant={ButtonVariant.Secondary}
|
|
||||||
>
|
|
||||||
{i18n('Preferences__turn-stories-on')}
|
|
||||||
</Button>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -1043,7 +1043,7 @@ export const Preferences = ({
|
||||||
dialogName="Preference.turnStoriesOff"
|
dialogName="Preference.turnStoriesOff"
|
||||||
actions={[
|
actions={[
|
||||||
{
|
{
|
||||||
action: () => onHasStoriesEnabledChanged(false),
|
action: () => onHasStoriesDisabledChanged(true),
|
||||||
style: 'negative',
|
style: 'negative',
|
||||||
text: i18n('Preferences__turn-stories-off--action'),
|
text: i18n('Preferences__turn-stories-off--action'),
|
||||||
},
|
},
|
||||||
|
|
|
@ -104,7 +104,7 @@ export class SettingsChannel extends EventEmitter {
|
||||||
this.installSetting('lastSyncTime');
|
this.installSetting('lastSyncTime');
|
||||||
this.installSetting('universalExpireTimer');
|
this.installSetting('universalExpireTimer');
|
||||||
|
|
||||||
this.installSetting('hasStoriesEnabled');
|
this.installSetting('hasStoriesDisabled');
|
||||||
this.installSetting('zoomFactor');
|
this.installSetting('zoomFactor');
|
||||||
|
|
||||||
installPermissionsHandler({ session, userConfig });
|
installPermissionsHandler({ session, userConfig });
|
||||||
|
|
|
@ -359,6 +359,9 @@ export function toAccountRecord(
|
||||||
accountRecord.hasSetMyStoriesPrivacy = hasSetMyStoriesPrivacy;
|
accountRecord.hasSetMyStoriesPrivacy = hasSetMyStoriesPrivacy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hasStoriesDisabled = window.storage.get('hasStoriesDisabled');
|
||||||
|
accountRecord.storiesDisabled = hasStoriesDisabled === true;
|
||||||
|
|
||||||
applyUnknownFields(accountRecord, conversation);
|
applyUnknownFields(accountRecord, conversation);
|
||||||
|
|
||||||
return accountRecord;
|
return accountRecord;
|
||||||
|
@ -1059,6 +1062,7 @@ export async function mergeAccountRecord(
|
||||||
displayBadgesOnProfile,
|
displayBadgesOnProfile,
|
||||||
keepMutedChatsArchived,
|
keepMutedChatsArchived,
|
||||||
hasSetMyStoriesPrivacy,
|
hasSetMyStoriesPrivacy,
|
||||||
|
storiesDisabled,
|
||||||
} = accountRecord;
|
} = accountRecord;
|
||||||
|
|
||||||
const updatedConversations = new Array<ConversationModel>();
|
const updatedConversations = new Array<ConversationModel>();
|
||||||
|
@ -1252,6 +1256,7 @@ export async function mergeAccountRecord(
|
||||||
window.storage.put('displayBadgesOnProfile', Boolean(displayBadgesOnProfile));
|
window.storage.put('displayBadgesOnProfile', Boolean(displayBadgesOnProfile));
|
||||||
window.storage.put('keepMutedChatsArchived', Boolean(keepMutedChatsArchived));
|
window.storage.put('keepMutedChatsArchived', Boolean(keepMutedChatsArchived));
|
||||||
window.storage.put('hasSetMyStoriesPrivacy', Boolean(hasSetMyStoriesPrivacy));
|
window.storage.put('hasSetMyStoriesPrivacy', Boolean(hasSetMyStoriesPrivacy));
|
||||||
|
window.storage.put('hasStoriesDisabled', Boolean(storiesDisabled));
|
||||||
|
|
||||||
const ourID = window.ConversationController.getOurConversationId();
|
const ourID = window.ConversationController.getOurConversationId();
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ export const getStoriesEnabled = createSelector(
|
||||||
getItems,
|
getItems,
|
||||||
getRemoteConfig,
|
getRemoteConfig,
|
||||||
(state: ItemsStateType, remoteConfig: ConfigMapType): boolean =>
|
(state: ItemsStateType, remoteConfig: ConfigMapType): boolean =>
|
||||||
state.hasStoriesEnabled !== false &&
|
!state.hasStoriesDisabled &&
|
||||||
(isRemoteConfigFlagEnabled(remoteConfig, 'desktop.internalUser') ||
|
(isRemoteConfigFlagEnabled(remoteConfig, 'desktop.internalUser') ||
|
||||||
isRemoteConfigFlagEnabled(remoteConfig, 'desktop.stories'))
|
isRemoteConfigFlagEnabled(remoteConfig, 'desktop.stories'))
|
||||||
);
|
);
|
||||||
|
|
|
@ -1904,7 +1904,7 @@ export default class MessageReceiver
|
||||||
|
|
||||||
const attachments: Array<ProcessedAttachment> = [];
|
const attachments: Array<ProcessedAttachment> = [];
|
||||||
|
|
||||||
if (!window.Events.getHasStoriesEnabled()) {
|
if (window.Events.getHasStoriesDisabled()) {
|
||||||
log.info('MessageReceiver.handleStoryMessage: dropping', logId);
|
log.info('MessageReceiver.handleStoryMessage: dropping', logId);
|
||||||
this.removeFromCache(envelope);
|
this.removeFromCache(envelope);
|
||||||
return;
|
return;
|
||||||
|
@ -2697,7 +2697,7 @@ export default class MessageReceiver
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sentMessage.storyMessageRecipients && sentMessage.isRecipientUpdate) {
|
if (sentMessage.storyMessageRecipients && sentMessage.isRecipientUpdate) {
|
||||||
if (!window.Events.getHasStoriesEnabled()) {
|
if (window.Events.getHasStoriesDisabled()) {
|
||||||
log.info(
|
log.info(
|
||||||
'MessageReceiver.handleSyncMessage: dropping story recipients update'
|
'MessageReceiver.handleSyncMessage: dropping story recipients update'
|
||||||
);
|
);
|
||||||
|
|
2
ts/types/Storage.d.ts
vendored
2
ts/types/Storage.d.ts
vendored
|
@ -67,7 +67,7 @@ export type StorageAccessType = {
|
||||||
device_name: string;
|
device_name: string;
|
||||||
hasRegisterSupportForUnauthenticatedDelivery: boolean;
|
hasRegisterSupportForUnauthenticatedDelivery: boolean;
|
||||||
hasSetMyStoriesPrivacy: boolean;
|
hasSetMyStoriesPrivacy: boolean;
|
||||||
hasStoriesEnabled: boolean;
|
hasStoriesDisabled: boolean;
|
||||||
identityKeyMap: IdentityKeyMap;
|
identityKeyMap: IdentityKeyMap;
|
||||||
lastHeartbeat: number;
|
lastHeartbeat: number;
|
||||||
lastStartup: number;
|
lastStartup: number;
|
||||||
|
|
|
@ -48,7 +48,7 @@ export type IPCEventsValuesType = {
|
||||||
callRingtoneNotification: boolean;
|
callRingtoneNotification: boolean;
|
||||||
callSystemNotification: boolean;
|
callSystemNotification: boolean;
|
||||||
countMutedConversations: boolean;
|
countMutedConversations: boolean;
|
||||||
hasStoriesEnabled: boolean;
|
hasStoriesDisabled: boolean;
|
||||||
hideMenuBar: boolean | undefined;
|
hideMenuBar: boolean | undefined;
|
||||||
incomingCallNotification: boolean;
|
incomingCallNotification: boolean;
|
||||||
lastSyncTime: number | undefined;
|
lastSyncTime: number | undefined;
|
||||||
|
@ -178,9 +178,13 @@ export function createIPCEvents(
|
||||||
webFrame.setZoomFactor(zoomFactor);
|
webFrame.setZoomFactor(zoomFactor);
|
||||||
},
|
},
|
||||||
|
|
||||||
getHasStoriesEnabled: () => window.storage.get('hasStoriesEnabled', true),
|
getHasStoriesDisabled: () =>
|
||||||
setHasStoriesEnabled: (value: boolean) =>
|
window.storage.get('hasStoriesDisabled', false),
|
||||||
window.storage.put('hasStoriesEnabled', value),
|
setHasStoriesDisabled: async (value: boolean) => {
|
||||||
|
await window.storage.put('hasStoriesDisabled', value);
|
||||||
|
const account = window.ConversationController.getOurConversationOrThrow();
|
||||||
|
account.captureChange('hasStoriesDisabled');
|
||||||
|
},
|
||||||
|
|
||||||
getPreferredAudioInputDevice: () =>
|
getPreferredAudioInputDevice: () =>
|
||||||
window.storage.get('preferred-audio-input-device'),
|
window.storage.get('preferred-audio-input-device'),
|
||||||
|
@ -357,11 +361,7 @@ export function createIPCEvents(
|
||||||
await universalExpireTimer.set(newValue);
|
await universalExpireTimer.set(newValue);
|
||||||
|
|
||||||
// Update account in Storage Service
|
// Update account in Storage Service
|
||||||
const conversationId =
|
const account = window.ConversationController.getOurConversationOrThrow();
|
||||||
window.ConversationController.getOurConversationIdOrThrow();
|
|
||||||
const account = window.ConversationController.get(conversationId);
|
|
||||||
assertDev(account, "Account wasn't found");
|
|
||||||
|
|
||||||
account.captureChange('universalExpireTimer');
|
account.captureChange('universalExpireTimer');
|
||||||
|
|
||||||
// Add a notification to the currently open conversation
|
// Add a notification to the currently open conversation
|
||||||
|
|
|
@ -52,7 +52,7 @@ installSetting('callRingtoneNotification');
|
||||||
installSetting('callSystemNotification');
|
installSetting('callSystemNotification');
|
||||||
installSetting('countMutedConversations');
|
installSetting('countMutedConversations');
|
||||||
installSetting('deviceName');
|
installSetting('deviceName');
|
||||||
installSetting('hasStoriesEnabled');
|
installSetting('hasStoriesDisabled');
|
||||||
installSetting('hideMenuBar');
|
installSetting('hideMenuBar');
|
||||||
installSetting('incomingCallNotification');
|
installSetting('incomingCallNotification');
|
||||||
installSetting('lastSyncTime');
|
installSetting('lastSyncTime');
|
||||||
|
|
|
@ -50,7 +50,7 @@ const settingSystemTraySetting = createSetting('systemTraySetting');
|
||||||
|
|
||||||
const settingLastSyncTime = createSetting('lastSyncTime');
|
const settingLastSyncTime = createSetting('lastSyncTime');
|
||||||
|
|
||||||
const settingHasStoriesEnabled = createSetting('hasStoriesEnabled');
|
const settingHasStoriesDisabled = createSetting('hasStoriesDisabled');
|
||||||
const settingZoomFactor = createSetting('zoomFactor');
|
const settingZoomFactor = createSetting('zoomFactor');
|
||||||
|
|
||||||
// Getters only.
|
// Getters only.
|
||||||
|
@ -150,7 +150,7 @@ const renderPreferences = async () => {
|
||||||
hasReadReceipts,
|
hasReadReceipts,
|
||||||
hasRelayCalls,
|
hasRelayCalls,
|
||||||
hasSpellCheck,
|
hasSpellCheck,
|
||||||
hasStoriesEnabled,
|
hasStoriesDisabled,
|
||||||
hasTypingIndicators,
|
hasTypingIndicators,
|
||||||
isPhoneNumberSharingSupported,
|
isPhoneNumberSharingSupported,
|
||||||
lastSyncTime,
|
lastSyncTime,
|
||||||
|
@ -188,7 +188,7 @@ const renderPreferences = async () => {
|
||||||
hasReadReceipts: settingReadReceipts.getValue(),
|
hasReadReceipts: settingReadReceipts.getValue(),
|
||||||
hasRelayCalls: settingRelayCalls.getValue(),
|
hasRelayCalls: settingRelayCalls.getValue(),
|
||||||
hasSpellCheck: settingSpellCheck.getValue(),
|
hasSpellCheck: settingSpellCheck.getValue(),
|
||||||
hasStoriesEnabled: settingHasStoriesEnabled.getValue(),
|
hasStoriesDisabled: settingHasStoriesDisabled.getValue(),
|
||||||
hasTypingIndicators: settingTypingIndicators.getValue(),
|
hasTypingIndicators: settingTypingIndicators.getValue(),
|
||||||
isPhoneNumberSharingSupported: ipcPNP(),
|
isPhoneNumberSharingSupported: ipcPNP(),
|
||||||
lastSyncTime: settingLastSyncTime.getValue(),
|
lastSyncTime: settingLastSyncTime.getValue(),
|
||||||
|
@ -244,7 +244,7 @@ const renderPreferences = async () => {
|
||||||
hasReadReceipts,
|
hasReadReceipts,
|
||||||
hasRelayCalls,
|
hasRelayCalls,
|
||||||
hasSpellCheck,
|
hasSpellCheck,
|
||||||
hasStoriesEnabled,
|
hasStoriesDisabled,
|
||||||
hasTypingIndicators,
|
hasTypingIndicators,
|
||||||
lastSyncTime,
|
lastSyncTime,
|
||||||
notificationContent,
|
notificationContent,
|
||||||
|
@ -301,7 +301,7 @@ const renderPreferences = async () => {
|
||||||
onCountMutedConversationsChange: reRender(
|
onCountMutedConversationsChange: reRender(
|
||||||
settingCountMutedConversations.setValue
|
settingCountMutedConversations.setValue
|
||||||
),
|
),
|
||||||
onHasStoriesEnabledChanged: reRender(settingHasStoriesEnabled.setValue),
|
onHasStoriesDisabledChanged: reRender(settingHasStoriesDisabled.setValue),
|
||||||
onHideMenuBarChange: reRender(settingHideMenuBar.setValue),
|
onHideMenuBarChange: reRender(settingHideMenuBar.setValue),
|
||||||
onIncomingCallNotificationsChange: reRender(
|
onIncomingCallNotificationsChange: reRender(
|
||||||
settingIncomingCallNotification.setValue
|
settingIncomingCallNotification.setValue
|
||||||
|
|
Loading…
Reference in a new issue