Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions discord/server/setupSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,6 @@ export const setupSettings = () => {
},
],
},
[AppSettingIDs.NOTIFICATION_TOASTS]: {
id: AppSettingIDs.NOTIFICATION_TOASTS,
type: SETTING_TYPES.BOOLEAN,
version: "0.11.7",
description: "Show floating notification toasts on the dashboard",
label: "Notification Toasts",
value: true,
},
[AppSettingIDs.SCROLL_TO_BOTTOM]: {
id: AppSettingIDs.SCROLL_TO_BOTTOM,
type: SETTING_TYPES.BOOLEAN,
Expand All @@ -213,6 +205,16 @@ export const setupSettings = () => {
label: "Notification Toasts",
value: true,
},
[AppSettingIDs.NOTIFICATION_TOAST_DURATION_SECONDS]: {
id: AppSettingIDs.NOTIFICATION_TOAST_DURATION_SECONDS,
type: SETTING_TYPES.NUMBER,
version: "0.11.14",
description: "How long notification toasts stay visible (in seconds)",
label: "Notification Toast Duration",
value: 10,
min: 1,
max: 60,
},
[AppSettingIDs.CONTROLS_ORDER]: {
id: AppSettingIDs.CONTROLS_ORDER,
type: SETTING_TYPES.RANKED,
Expand Down
137 changes: 71 additions & 66 deletions discord/shared/types/discord.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SETTING_TYPES, SettingsBoolean, SettingsColor, SettingsMultiSelect, SettingsRanked, SettingsSelect, SettingsString } from "@deskthing/types";
import { SETTING_TYPES, SettingsBoolean, SettingsColor, SettingsMultiSelect, SettingsNumber, SettingsRanked, SettingsSelect, SettingsString } from "@deskthing/types";

export interface CallStatus {
channelId: string | null;
Expand Down Expand Up @@ -61,7 +61,7 @@ export interface NotificationStatus {
}
export interface Notification {
id: string;
title: string
title: string;
channelId: string;
channelName?: string;
guildName?: string;
Expand Down Expand Up @@ -95,83 +95,84 @@ export interface GuildListStatus {
}

export type DMListStatus = {
selectedDMId: string | null
dms: DMStatus[]
channels: ChannelStatus[]
}
selectedDMId: string | null;
dms: DMStatus[];
channels: ChannelStatus[];
};

export type DMStatus = {
id: string
}
id: string;
};

export enum DISCORD_ACTIONS {
MUTE = 'mute',
DEAFEN = 'deafen',
DISCONNECT = 'disconnect',
REAUTH = 'reauth',
REPRESENCE = 'represence',
EXPAND_CHAT = 'expandChat',
COLLAPSE_CHAT = 'collapseChat',
SELECT_TEXT_CHANNEL = 'selectTextChannel',
MARK_NOTIFICATION_AS_READ = 'markNotificationAsRead',
MARK_ALL_NOTIFICATIONS_AS_READ = 'markAllNotificationsAsRead',
SEND_TEST_NOTIFICATION = 'sendTestNotification',
MUTE = "mute",
DEAFEN = "deafen",
DISCONNECT = "disconnect",
REAUTH = "reauth",
REPRESENCE = "represence",
EXPAND_CHAT = "expandChat",
COLLAPSE_CHAT = "collapseChat",
SELECT_TEXT_CHANNEL = "selectTextChannel",
MARK_NOTIFICATION_AS_READ = "markNotificationAsRead",
MARK_ALL_NOTIFICATIONS_AS_READ = "markAllNotificationsAsRead",
SEND_TEST_NOTIFICATION = "sendTestNotification",
}

export enum AppSettingIDs {
CLIENT_ID = 'client_id',
CLIENT_SECRET = 'client_secret',
REDIRECT_URL = 'redirect_url',
RICH_PRESENCE = 'rich_presence',
SET_MAIN_TEXT = 'set_main_text',
SET_SECONDARY_TEXT = 'set_secondary_text',
HAVE_TIMER = 'have_timer',
LEFT_DASHBOARD_PANEL = 'left_dashboard_panel',
RIGHT_DASHBOARD_PANEL = 'right_dashboard_panel',
DASHBOARD_ELEMENTS = 'dashboard_elements',
SCROLL_TO_BOTTOM = 'scroll_to_bottom',
NOTIFICATION_TOASTS = 'notification_toasts',
CONTROLS_ORDER = 'controls_order',
SPEAKING_COLOR = 'speaking_color',
CLOCK_OPTIONS = 'clock_options',
SONG_OPTIONS = 'song_options'
CLIENT_ID = "client_id",
CLIENT_SECRET = "client_secret",
REDIRECT_URL = "redirect_url",
RICH_PRESENCE = "rich_presence",
SET_MAIN_TEXT = "set_main_text",
SET_SECONDARY_TEXT = "set_secondary_text",
HAVE_TIMER = "have_timer",
LEFT_DASHBOARD_PANEL = "left_dashboard_panel",
RIGHT_DASHBOARD_PANEL = "right_dashboard_panel",
DASHBOARD_ELEMENTS = "dashboard_elements",
SCROLL_TO_BOTTOM = "scroll_to_bottom",
NOTIFICATION_TOASTS = "notification_toasts",
NOTIFICATION_TOAST_DURATION_SECONDS = "notification_toast_duration_seconds",
CONTROLS_ORDER = "controls_order",
SPEAKING_COLOR = "speaking_color",
CLOCK_OPTIONS = "clock_options",
SONG_OPTIONS = "song_options",
}

export enum PANEL_ELEMENTS {
CALL_STATUS = 'call_status',
GUILD_LIST = 'guild_list',
CHAT = 'chat',
SONG = 'song',
CLOCK = 'clock',
BLANK = 'blank'
CALL_STATUS = "call_status",
GUILD_LIST = "guild_list",
CHAT = "chat",
SONG = "song",
CLOCK = "clock",
BLANK = "blank",
}

export enum DASHBOARD_ELEMENTS {
MINI_CALL = 'mini_call',
CALL_CONTROLS = 'call_controls',
NOTIFICATIONS = 'notifications',
BG_ALBUM = 'bg_album'
MINI_CALL = "mini_call",
CALL_CONTROLS = "call_controls",
NOTIFICATIONS = "notifications",
BG_ALBUM = "bg_album",
}

export enum CONTROL_OPTIONS {
MUTE = 'mute',
DEAFEN = 'deafen',
DISCONNECT = 'disconnect'
MUTE = "mute",
DEAFEN = "deafen",
DISCONNECT = "disconnect",
}

export enum CLOCK_OPTIONS {
TOP_LEFT = 'top_left',
TOP_RIGHT = 'top_right',
TOP_CENTER = 'top_center',
CUSTOM = 'custom',
DISABLED = 'disabled'
TOP_LEFT = "top_left",
TOP_RIGHT = "top_right",
TOP_CENTER = "top_center",
CUSTOM = "custom",
DISABLED = "disabled",
}

export enum SONG_CONTROLS {
DISABLED = 'disabled',
FREE = 'free',
TOP = 'top',
BOTTOM = 'bottom',
DISABLED = "disabled",
FREE = "free",
TOP = "top",
BOTTOM = "bottom",
}

type SelectSetting = SettingsSelect & {
Expand All @@ -191,17 +192,21 @@ type SelectClockOptions = SettingsSelect & {
id: AppSettingIDs.CLOCK_OPTIONS;
value: CLOCK_OPTIONS;
options: { value: CLOCK_OPTIONS; label: string }[];
}
};

type SelectSongOptions = SettingsSelect & {
id: AppSettingIDs.SONG_OPTIONS;
value: SONG_CONTROLS;
options: { value: SONG_CONTROLS; label: string }[];
}
};

type NotificationToastSetting = SettingsBoolean & {
id: AppSettingIDs.NOTIFICATION_TOASTS;
}
};

type NotificationToastDurationSetting = SettingsNumber & {
id: AppSettingIDs.NOTIFICATION_TOAST_DURATION_SECONDS;
};

type OrderSettings = SettingsRanked & {
id: AppSettingIDs.CONTROLS_ORDER;
Expand All @@ -217,14 +222,14 @@ export type DiscordSettings = {
// [AppSettingIDs.SET_MAIN_TEXT]: SettingsString & { id: AppSettingIDs.SET_MAIN_TEXT };
// [AppSettingIDs.SET_SECONDARY_TEXT]: SettingsString & { id: AppSettingIDs.SET_SECONDARY_TEXT };
// [AppSettingIDs.HAVE_TIMER]: SettingsBoolean & { id: AppSettingIDs.HAVE_TIMER };
[AppSettingIDs.LEFT_DASHBOARD_PANEL]: SelectSetting & { id: AppSettingIDs.LEFT_DASHBOARD_PANEL, value: PANEL_ELEMENTS };
[AppSettingIDs.RIGHT_DASHBOARD_PANEL]: SelectSetting & { id: AppSettingIDs.RIGHT_DASHBOARD_PANEL, value: PANEL_ELEMENTS };
[AppSettingIDs.DASHBOARD_ELEMENTS]: MultiSelectSetting & { id: AppSettingIDs.DASHBOARD_ELEMENTS, value: DASHBOARD_ELEMENTS[] };
[AppSettingIDs.LEFT_DASHBOARD_PANEL]: SelectSetting & { id: AppSettingIDs.LEFT_DASHBOARD_PANEL; value: PANEL_ELEMENTS };
[AppSettingIDs.RIGHT_DASHBOARD_PANEL]: SelectSetting & { id: AppSettingIDs.RIGHT_DASHBOARD_PANEL; value: PANEL_ELEMENTS };
[AppSettingIDs.DASHBOARD_ELEMENTS]: MultiSelectSetting & { id: AppSettingIDs.DASHBOARD_ELEMENTS; value: DASHBOARD_ELEMENTS[] };
[AppSettingIDs.SCROLL_TO_BOTTOM]: SettingsBoolean & { id: AppSettingIDs.SCROLL_TO_BOTTOM };
[AppSettingIDs.NOTIFICATION_TOASTS]: SettingsBoolean & { id: AppSettingIDs.NOTIFICATION_TOASTS };
[AppSettingIDs.NOTIFICATION_TOASTS]: NotificationToastSetting & { id: AppSettingIDs.NOTIFICATION_TOASTS };
[AppSettingIDs.NOTIFICATION_TOAST_DURATION_SECONDS]: NotificationToastDurationSetting & { id: AppSettingIDs.NOTIFICATION_TOAST_DURATION_SECONDS };
[AppSettingIDs.CONTROLS_ORDER]: OrderSettings & { id: AppSettingIDs.CONTROLS_ORDER };
[AppSettingIDs.SPEAKING_COLOR]: SettingsColor & { id: AppSettingIDs.SPEAKING_COLOR };
[AppSettingIDs.CLOCK_OPTIONS]: SelectClockOptions & { id: AppSettingIDs.CLOCK_OPTIONS };
[AppSettingIDs.SONG_OPTIONS]: SelectSongOptions & { id: AppSettingIDs.SONG_OPTIONS };
[AppSettingIDs.NOTIFICATION_TOASTS]: NotificationToastSetting & { id: AppSettingIDs.NOTIFICATION_TOASTS };
};
};
2 changes: 2 additions & 0 deletions discord/src/overlays/OverlayWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default function OverlayWrapper() {
const markNotificationAsRead = useChatStore((state) => state.markNotificationAsRead)
const notifications = useChatStore((state) => state.notificationStatus?.notifications)
const toastsEnabled = useUIStore((state) => state.notification_toasts_enabled)
const toastDurationSeconds = useUIStore((state) => state.notification_toast_duration_seconds)

const unreadNotifications = useMemo(() => {
if (!notifications) return []
Expand All @@ -30,6 +31,7 @@ export default function OverlayWrapper() {
key={notification.id}
notification={notification}
onClose={markNotificationAsRead}
autoHideDuration={toastDurationSeconds * 1000}
/>
))}
</div>
Expand Down
3 changes: 3 additions & 0 deletions discord/src/stores/uiStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type UIStore = {
widgets: DASHBOARD_ELEMENTS[]
clock_options: CLOCK_OPTIONS
notification_toasts_enabled: boolean
notification_toast_duration_seconds: number

dimensions: {
width: number;
Expand Down Expand Up @@ -120,6 +121,7 @@ export const useUIStore = create<UIStore>((set, get) => ({
widgets: [...defaultWidgets],
clock_options: CLOCK_OPTIONS.DISABLED,
notification_toasts_enabled: true,
notification_toast_duration_seconds: 10,
dimensions: getInitialDimensions(),

initialize: () => {
Expand Down Expand Up @@ -173,6 +175,7 @@ export const useUIStore = create<UIStore>((set, get) => ({
widgets: settings[AppSettingIDs.DASHBOARD_ELEMENTS].value,
song_controls: settings[AppSettingIDs.SONG_OPTIONS].value,
notification_toasts_enabled: settings[AppSettingIDs.NOTIFICATION_TOASTS].value,
notification_toast_duration_seconds: settings[AppSettingIDs.NOTIFICATION_TOAST_DURATION_SECONDS].value,
settings: settings as DiscordSettings,
});
}
Expand Down
1 change: 1 addition & 0 deletions discord/src/utils/settingValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export function validateDiscordSettings(obj: AppSettings): asserts obj is Discor
AppSettingIDs.RIGHT_DASHBOARD_PANEL,
AppSettingIDs.DASHBOARD_ELEMENTS,
AppSettingIDs.NOTIFICATION_TOASTS,
AppSettingIDs.NOTIFICATION_TOAST_DURATION_SECONDS,
];

for (const id of requiredIds) {
Expand Down