import { useUserPreference } from '@rocket.chat/ui-contexts'; export type AccountPreferencesData = { language?: string; dontAskAgainList?: string[]; enableAutoAway?: boolean; idleTimeLimit?: number; desktopNotificationRequireInteraction?: boolean; desktopNotifications?: string; pushNotifications?: string; emailNotificationMode?: string; receiveLoginDetectionEmail?: boolean; notifyCalendarEvents?: boolean; enableMobileRinging?: boolean; unreadAlert?: boolean; showThreadsInMainChannel?: boolean; alsoSendThreadToChannel?: 'default' | 'always' | 'never'; useEmojis?: boolean; convertAsciiEmoji?: boolean; autoImageLoad?: boolean; saveMobileBandwidth?: boolean; collapseMediaByDefault?: boolean; hideFlexTab?: boolean; sendOnEnter?: 'normal' | 'alternative' | 'desktop'; highlights?: string; newRoomNotification?: string; newMessageNotification?: string; muteFocusedConversations?: boolean; enableNewMessageTemplate?: boolean; displayAvatars?: boolean; sidebarShowFavorites?: boolean; sidebarShowUnread?: boolean; sidebarSortby?: string; sidebarViewMode?: string; sidebarDisplayAvatar?: boolean; sidebarGroupByType?: boolean; masterVolume?: number; notificationsSoundVolume?: number; voipRingerVolume?: number; desktopNotificationVoiceCalls?: boolean; }; export const useAccountPreferencesValues = (): AccountPreferencesData => { const language = useUserPreference('language') || ''; const userDontAskAgainList = useUserPreference<{ action: string; label: string }[]>('dontAskAgainList') || []; const dontAskAgainList = userDontAskAgainList.map(({ action }) => action); const enableAutoAway = useUserPreference('enableAutoAway'); const idleTimeLimit = useUserPreference('idleTimeLimit'); const desktopNotificationRequireInteraction = useUserPreference('desktopNotificationRequireInteraction'); const desktopNotifications = useUserPreference('desktopNotifications'); const pushNotifications = useUserPreference('pushNotifications'); const emailNotificationMode = useUserPreference('emailNotificationMode'); const receiveLoginDetectionEmail = useUserPreference('receiveLoginDetectionEmail', true); const notifyCalendarEvents = useUserPreference('notifyCalendarEvents'); const enableMobileRinging = useUserPreference('enableMobileRinging'); const unreadAlert = useUserPreference('unreadAlert'); const showThreadsInMainChannel = useUserPreference('showThreadsInMainChannel'); const alsoSendThreadToChannel = useUserPreference<'default' | 'always' | 'never'>('alsoSendThreadToChannel'); const useEmojis = useUserPreference('useEmojis'); const convertAsciiEmoji = useUserPreference('convertAsciiEmoji'); const autoImageLoad = useUserPreference('autoImageLoad'); const saveMobileBandwidth = useUserPreference('saveMobileBandwidth'); const collapseMediaByDefault = useUserPreference('collapseMediaByDefault'); const hideFlexTab = useUserPreference('hideFlexTab'); const sendOnEnter = useUserPreference<'normal' | 'alternative' | 'desktop'>('sendOnEnter'); const displayAvatars = useUserPreference('displayAvatars'); const highlights = useUserPreference('highlights')?.join(',\n') ?? ''; const newRoomNotification = useUserPreference('newRoomNotification'); const newMessageNotification = useUserPreference('newMessageNotification'); const muteFocusedConversations = useUserPreference('muteFocusedConversations'); const masterVolume = useUserPreference('masterVolume', 100); const notificationsSoundVolume = useUserPreference('notificationsSoundVolume', 100); const voipRingerVolume = useUserPreference('voipRingerVolume', 100); const desktopNotificationVoiceCalls = useUserPreference('desktopNotificationVoiceCalls'); return { language, dontAskAgainList, enableAutoAway, idleTimeLimit, desktopNotificationRequireInteraction, desktopNotifications, pushNotifications, emailNotificationMode, receiveLoginDetectionEmail, notifyCalendarEvents, enableMobileRinging, unreadAlert, showThreadsInMainChannel, alsoSendThreadToChannel, useEmojis, convertAsciiEmoji, autoImageLoad, saveMobileBandwidth, collapseMediaByDefault, hideFlexTab, sendOnEnter, displayAvatars, highlights, newRoomNotification, newMessageNotification, muteFocusedConversations, masterVolume, notificationsSoundVolume, voipRingerVolume, desktopNotificationVoiceCalls, }; };