mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-02 13:03:22 +00:00
Use Partial types for DNDSettings, SettingsOptions.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
@@ -3,14 +3,14 @@ import * as ConfigUtil from "./config-util";
|
|||||||
type SettingName = "showNotification" | "silent" | "flashTaskbarOnMessage";
|
type SettingName = "showNotification" | "silent" | "flashTaskbarOnMessage";
|
||||||
|
|
||||||
export interface DNDSettings {
|
export interface DNDSettings {
|
||||||
showNotification?: boolean;
|
showNotification: boolean;
|
||||||
silent?: boolean;
|
silent: boolean;
|
||||||
flashTaskbarOnMessage?: boolean;
|
flashTaskbarOnMessage: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Toggle {
|
interface Toggle {
|
||||||
dnd: boolean;
|
dnd: boolean;
|
||||||
newSettings: DNDSettings;
|
newSettings: Partial<DNDSettings>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toggle(): Toggle {
|
export function toggle(): Toggle {
|
||||||
@@ -20,9 +20,9 @@ export function toggle(): Toggle {
|
|||||||
dndSettingList.push("flashTaskbarOnMessage");
|
dndSettingList.push("flashTaskbarOnMessage");
|
||||||
}
|
}
|
||||||
|
|
||||||
let newSettings: DNDSettings;
|
let newSettings: Partial<DNDSettings>;
|
||||||
if (dnd) {
|
if (dnd) {
|
||||||
const oldSettings: DNDSettings = {};
|
const oldSettings: Partial<DNDSettings> = {};
|
||||||
newSettings = {};
|
newSettings = {};
|
||||||
|
|
||||||
// Iterate through the dndSettingList.
|
// Iterate through the dndSettingList.
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export interface RendererMessage {
|
|||||||
autoHideMenubar: boolean,
|
autoHideMenubar: boolean,
|
||||||
updateMenu: boolean,
|
updateMenu: boolean,
|
||||||
) => void;
|
) => void;
|
||||||
"toggle-dnd": (state: boolean, newSettings: DNDSettings) => void;
|
"toggle-dnd": (state: boolean, newSettings: Partial<DNDSettings>) => void;
|
||||||
"toggle-menubar-setting": (state: boolean) => void;
|
"toggle-menubar-setting": (state: boolean) => void;
|
||||||
"toggle-sidebar": (show: boolean) => void;
|
"toggle-sidebar": (show: boolean) => void;
|
||||||
"toggle-sidebar-setting": (state: boolean) => void;
|
"toggle-sidebar-setting": (state: boolean) => void;
|
||||||
|
|||||||
@@ -46,12 +46,12 @@ interface SettingsOptions extends DNDSettings {
|
|||||||
customCSS: boolean;
|
customCSS: boolean;
|
||||||
lastActiveTab: number;
|
lastActiveTab: number;
|
||||||
dnd: boolean;
|
dnd: boolean;
|
||||||
dndPreviousSettings: DNDSettings;
|
dndPreviousSettings: Partial<DNDSettings>;
|
||||||
downloadsPath: string;
|
downloadsPath: string;
|
||||||
quitOnClose: boolean;
|
quitOnClose: boolean;
|
||||||
promptDownload: boolean;
|
promptDownload: boolean;
|
||||||
dockBouncing?: boolean;
|
dockBouncing: boolean;
|
||||||
spellcheckerLanguages?: string[];
|
spellcheckerLanguages: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebviewListener =
|
type WebviewListener =
|
||||||
@@ -194,7 +194,7 @@ class ServerManagerView {
|
|||||||
// This will make sure the default settings are correctly set to either true or false
|
// This will make sure the default settings are correctly set to either true or false
|
||||||
initDefaultSettings(): void {
|
initDefaultSettings(): void {
|
||||||
// Default settings which should be respected
|
// Default settings which should be respected
|
||||||
const settingOptions: SettingsOptions = {
|
const settingOptions: Partial<SettingsOptions> = {
|
||||||
autoHideMenubar: false,
|
autoHideMenubar: false,
|
||||||
trayIcon: true,
|
trayIcon: true,
|
||||||
useManualProxy: false,
|
useManualProxy: false,
|
||||||
@@ -226,7 +226,7 @@ class ServerManagerView {
|
|||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
// Only available on Windows
|
// Only available on Windows
|
||||||
settingOptions.flashTaskbarOnMessage = true;
|
settingOptions.flashTaskbarOnMessage = true;
|
||||||
settingOptions.dndPreviousSettings.flashTaskbarOnMessage = true;
|
settingOptions.dndPreviousSettings!.flashTaskbarOnMessage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.platform === "darwin") {
|
if (process.platform === "darwin") {
|
||||||
@@ -1074,7 +1074,7 @@ class ServerManagerView {
|
|||||||
|
|
||||||
ipcRenderer.on(
|
ipcRenderer.on(
|
||||||
"toggle-dnd",
|
"toggle-dnd",
|
||||||
(event: Event, state: boolean, newSettings: DNDSettings) => {
|
(event: Event, state: boolean, newSettings: Partial<DNDSettings>) => {
|
||||||
this.toggleDNDButton(state);
|
this.toggleDNDButton(state);
|
||||||
ipcRenderer.send(
|
ipcRenderer.send(
|
||||||
"forward-message",
|
"forward-message",
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export function initPreferenceView(): void {
|
|||||||
|
|
||||||
ipcRenderer.on(
|
ipcRenderer.on(
|
||||||
"toggle-dnd",
|
"toggle-dnd",
|
||||||
(_event: Event, _state: boolean, newSettings: DNDSettings) => {
|
(_event: Event, _state: boolean, newSettings: Partial<DNDSettings>) => {
|
||||||
handleToggle("show-notification-option", newSettings.showNotification);
|
handleToggle("show-notification-option", newSettings.showNotification);
|
||||||
handleToggle("silent-option", newSettings.silent);
|
handleToggle("silent-option", newSettings.silent);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user