mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-04-10 23:15:34 -04:00
37 lines
899 B
TypeScript
37 lines
899 B
TypeScript
import { useHouseholdSelf } from "~/composables/use-households";
|
|
import { useGroupSelf } from "~/composables/use-groups";
|
|
|
|
export function useAnnouncements() {
|
|
const auth = useMealieAuth();
|
|
const { household } = useHouseholdSelf();
|
|
const { group } = useGroupSelf();
|
|
|
|
const announcementsEnabled = computed(
|
|
() =>
|
|
!!(
|
|
auth.user.value?.showAnnouncements
|
|
&& household.value?.preferences?.showAnnouncements
|
|
&& group.value?.preferences?.showAnnouncements
|
|
),
|
|
);
|
|
|
|
const newAnnouncements = ref<string[] | undefined>();
|
|
function refreshUnreadAnnouncements() {
|
|
if (!auth.user.value) {
|
|
newAnnouncements.value = undefined;
|
|
}
|
|
|
|
newAnnouncements.value = []; // TODO
|
|
}
|
|
|
|
refreshUnreadAnnouncements();
|
|
watch(() => auth.user, () => {
|
|
refreshUnreadAnnouncements();
|
|
});
|
|
|
|
return {
|
|
announcementsEnabled,
|
|
newAnnouncements,
|
|
};
|
|
}
|