107 lines
3.6 KiB
TypeScript
107 lines
3.6 KiB
TypeScript
// Metro module 10245 (f10246).
|
|
import { DesktopNotificationTypes, NotificationPermissionTypes, TTSNotificationTypes } from "../Constants";
|
|
import { isPlatformEmbedded } from "../utils/PlatformUtils";
|
|
import Module589 from "../_bundle/Module589";
|
|
import Dispatcher from "../Dispatcher";
|
|
let c6834_5, c6834_6;
|
|
const desktopType = isPlatformEmbedded ? DesktopNotificationTypes.ALL : DesktopNotificationTypes.NEVER;
|
|
const handleSetDesktopType = function handleSetDesktopType(a0) {
|
|
c6834_6.desktopType = a0.desktopType;
|
|
};
|
|
c6834_5 = {
|
|
desktopType,
|
|
disableAllSounds: false,
|
|
disabledSounds: [],
|
|
ttsType: TTSNotificationTypes.NEVER,
|
|
disableUnreadBadge: false,
|
|
taskbarFlash: true,
|
|
notifyMessagesInSelectedChannel: false,
|
|
screenDowntimeReminder: true
|
|
};
|
|
c6834_6 = c6834_5;
|
|
class NotificationSettingsStore extends Module589.DeviceSettingsStore {
|
|
static displayName = "NotificationSettingsStore";
|
|
static persistKey = "notifications";
|
|
static migrations = [(a0) => {
|
|
const r1 = {
|
|
...a0
|
|
};
|
|
r1.disabledSounds = r1.disabledSounds || [];
|
|
r1.disableUnreadBadge = r1.disableUnreadBadge || false;
|
|
r1.taskbarFlash = r1.taskbarFlash == null || r1.taskbarFlash;
|
|
r1.ttsType = r1.ttsType || TTSNotificationTypes.NEVER;
|
|
if (r1.desktopType == null) {
|
|
r1.desktopType = isPlatformEmbedded ? DesktopNotificationTypes.ALL : DesktopNotificationTypes.NEVER;
|
|
}
|
|
return r1;
|
|
}];
|
|
initialize(a0) {
|
|
c6834_6 = {
|
|
...c6834_5,
|
|
...a0
|
|
};
|
|
}
|
|
getUserAgnosticState() {
|
|
return c6834_6;
|
|
}
|
|
getDesktopType() {
|
|
return c6834_6.desktopType;
|
|
}
|
|
getTTSType() {
|
|
return c6834_6.ttsType;
|
|
}
|
|
getDisabledSounds() {
|
|
return c6834_6.disabledSounds;
|
|
}
|
|
getDisableAllSounds() {
|
|
return c6834_6.disableAllSounds;
|
|
}
|
|
getDisableUnreadBadge() {
|
|
return c6834_6.disableUnreadBadge;
|
|
}
|
|
getNotifyMessagesInSelectedChannel() {
|
|
return c6834_6.notifyMessagesInSelectedChannel;
|
|
}
|
|
get taskbarFlash() {
|
|
return c6834_6.taskbarFlash;
|
|
}
|
|
get screenDowntimeReminder() {
|
|
return c6834_6.screenDowntimeReminder;
|
|
}
|
|
isSoundDisabled(a0) {
|
|
return c6834_6.disableAllSounds || c6834_6.disabledSounds.indexOf(a0) !== -1;
|
|
}
|
|
}
|
|
const notificationSettingsStore = new NotificationSettingsStore(Dispatcher, {
|
|
NOTIFICATIONS_SET_DESKTOP_TYPE: handleSetDesktopType,
|
|
NOTIFICATIONS_SET_TTS_TYPE: function handleSetTTSType(a0) {
|
|
c6834_6.ttsType = a0.ttsType;
|
|
},
|
|
NOTIFICATIONS_SET_DISABLED_SOUNDS: function handleSetDisabledSounds(a0) {
|
|
c6834_6.disabledSounds = a0.sounds;
|
|
},
|
|
NOTIFICATIONS_TOGGLE_ALL_DISABLED: function handleToggleAllDisabled() {
|
|
c6834_6.disableAllSounds = !c6834_6.disableAllSounds;
|
|
},
|
|
NOTIFICATIONS_SET_PERMISSION_STATE: function handleSetHavePermission({ enabled }) {
|
|
if (enabled === NotificationPermissionTypes.BLOCKED) {
|
|
c6834_6.desktopType = DesktopNotificationTypes.NEVER;
|
|
} else if (enabled === NotificationPermissionTypes.ENABLED) {
|
|
c6834_6.desktopType = DesktopNotificationTypes.ALL;
|
|
}
|
|
},
|
|
NOTIFICATIONS_SET_DISABLE_UNREAD_BADGE: function handleSetDisableUnreadBadge(a0) {
|
|
c6834_6.disableUnreadBadge = a0.disableUnreadBadge;
|
|
},
|
|
NOTIFICATIONS_SET_TASKBAR_FLASH: function handleSetTaskbarFlash(a0) {
|
|
c6834_6.taskbarFlash = a0.taskbarFlash;
|
|
},
|
|
NOTIFICATIONS_SET_NOTIFY_MESSAGES_IN_SELECTED_CHANNEL: function handleSetNotifyMessagesInSelectedChannel(a0) {
|
|
c6834_6.notifyMessagesInSelectedChannel = a0.notify;
|
|
},
|
|
NOTIFICATIONS_SET_SCREEN_DOWNTIME_REMINDER: function handleSetScreenDowntimeReminder(a0) {
|
|
c6834_6.screenDowntimeReminder = a0.screenDowntimeReminder;
|
|
}
|
|
});
|
|
export default notificationSettingsStore;
|