platform/plugins/desktop-preferences-resources/src/utils.ts
Andrey Sobolev ddecae80dd
Move services to public (#6156)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
2024-07-28 14:55:43 +07:00

29 lines
782 B
TypeScript

import { writable } from 'svelte/store'
import { createQuery } from '@hcengineering/presentation'
import desktopPreferences, {
defaultNotificationPreference,
type DesktopNotificationPreference,
type DesktopNotificationPreferenceData
} from '@hcengineering/desktop-preferences'
// /**
// * @public
// */
export const activePreferences = writable<DesktopNotificationPreferenceData | DesktopNotificationPreference>(
defaultNotificationPreference
)
const preferencesQuery = createQuery(true)
preferencesQuery.query(
desktopPreferences.class.DesktopNotificationPreference,
{},
(res: DesktopNotificationPreference[]) => {
if (res?.length > 0) {
activePreferences.set(res[0])
} else {
activePreferences.set(defaultNotificationPreference)
}
}
)