user_settings: Extract {Stream,Pm}NotificationSettings types.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-08-25 12:12:35 -07:00 committed by Tim Abbott
parent 804be2f2a5
commit 4240b0400b
2 changed files with 25 additions and 15 deletions

View File

@ -3,7 +3,11 @@ import Handlebars from "handlebars/runtime";
import {$t, $t_html} from "./i18n";
import {page_params} from "./page_params";
import type {RealmDefaultSettings} from "./realm_user_settings_defaults";
import type {UserSettings} from "./user_settings";
import type {
PmNotificationSettings,
StreamNotificationSettings,
UserSettings,
} from "./user_settings";
/*
This file contains translations between the integer values used in
@ -571,9 +575,7 @@ export const stream_specific_notification_settings = [
"wildcard_mentions_notify",
];
type Settings = UserSettings | RealmDefaultSettings;
type PageParamsItem = keyof Settings;
export const stream_notification_settings: PageParamsItem[] = [
export const stream_notification_settings: (keyof StreamNotificationSettings)[] = [
"enable_stream_desktop_notifications",
"enable_stream_audible_notifications",
"enable_stream_push_notifications",
@ -581,7 +583,7 @@ export const stream_notification_settings: PageParamsItem[] = [
"wildcard_mentions_notify",
];
export const pm_mention_notification_settings: PageParamsItem[] = [
export const pm_mention_notification_settings: (keyof PmNotificationSettings)[] = [
"enable_desktop_notifications",
"enable_sounds",
"enable_offline_push_notifications",
@ -659,6 +661,8 @@ export const all_notification_settings = other_notification_settings.concat(
stream_notification_settings,
);
type Settings = UserSettings | RealmDefaultSettings;
type PageParamsItem = keyof Settings;
type NotificationSettingCheckbox = {
setting_name: string;
is_disabled: boolean;

View File

@ -1,4 +1,19 @@
export type UserSettings = {
export type StreamNotificationSettings = {
enable_stream_audible_notifications: boolean;
enable_stream_desktop_notifications: boolean;
enable_stream_email_notifications: boolean;
enable_stream_push_notifications: boolean;
wildcard_mentions_notify: boolean;
};
export type PmNotificationSettings = {
enable_desktop_notifications: boolean;
enable_sounds: boolean;
enable_offline_push_notifications: boolean;
enable_offline_email_notifications: boolean;
};
export type UserSettings = (StreamNotificationSettings & PmNotificationSettings) & {
color_scheme: number;
default_language: string;
default_view: string;
@ -7,19 +22,11 @@ export type UserSettings = {
dense_mode: boolean;
email_notifications_batching_period_seconds: number;
emojiset: string;
enable_desktop_notifications: boolean;
enable_digest_emails: boolean;
enable_drafts_synchronization: boolean;
enable_login_emails: boolean;
enable_marketing_emails: boolean;
enable_offline_push_notifications: boolean;
enable_offline_email_notifications: boolean;
enable_online_push_notifications: boolean;
enable_sounds: boolean;
enable_stream_audible_notifications: boolean;
enable_stream_desktop_notifications: boolean;
enable_stream_email_notifications: boolean;
enable_stream_push_notifications: boolean;
enter_sends: boolean;
escape_navigates_to_default_view: boolean;
fluid_layout_width: boolean;
@ -34,7 +41,6 @@ export type UserSettings = {
translate_emoticons: boolean;
display_emoji_reaction_users: boolean;
twenty_four_hour_time: boolean;
wildcard_mentions_notify: boolean;
send_stream_typing_notifications: boolean;
send_private_typing_notifications: boolean;
send_read_receipts: boolean;