Some checks are pending
E2E / Playwright e2e (push) Waiting to run
- Introduced new ContactAvatar and ContactAvatarPicker components for enhanced avatar management in contact views. - Updated ContactDetailView and ContactFormView to utilize the new avatar components, improving user experience when adding or editing contacts. - Enhanced ContactHoverCard and ContactRow components to display avatars, providing a more visually appealing interface. - Added loading and error states in ContactsListView for better user feedback during data fetching. - Implemented a new ContactsLoadState component to handle loading and error scenarios in the contacts list. - Updated package.json to include @formkit/auto-animate for improved UI animations.
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
"use client"
|
|
|
|
import { create } from "zustand"
|
|
import { persist } from "zustand/middleware"
|
|
import { normalizeEmail } from "@/lib/contacts/find-contact"
|
|
import { debouncedPersistJSONStorage } from "@/lib/stores/debounced-json-storage"
|
|
|
|
type BlockedSendersState = {
|
|
blockedSenderEmails: string[]
|
|
}
|
|
|
|
type BlockedSendersActions = {
|
|
blockSenders: (emails: string[]) => void
|
|
unblockSender: (email: string) => void
|
|
}
|
|
|
|
export function isBlockedSenderEmail(
|
|
blockedSenderEmails: string[],
|
|
email: string,
|
|
): boolean {
|
|
const norm = normalizeEmail(email)
|
|
return norm ? blockedSenderEmails.includes(norm) : false
|
|
}
|
|
|
|
export const useBlockedSendersStore = create<
|
|
BlockedSendersState & BlockedSendersActions
|
|
>()(
|
|
persist(
|
|
(set, get) => ({
|
|
blockedSenderEmails: [],
|
|
|
|
blockSenders: (emails) => {
|
|
const next = new Set(get().blockedSenderEmails)
|
|
for (const email of emails) {
|
|
const norm = normalizeEmail(email)
|
|
if (norm) next.add(norm)
|
|
}
|
|
set({ blockedSenderEmails: [...next] })
|
|
},
|
|
|
|
unblockSender: (email) => {
|
|
const norm = normalizeEmail(email)
|
|
if (!norm) return
|
|
set((s) => ({
|
|
blockedSenderEmails: s.blockedSenderEmails.filter((e) => e !== norm),
|
|
}))
|
|
},
|
|
}),
|
|
{
|
|
name: "ultimail-blocked-senders",
|
|
storage: debouncedPersistJSONStorage,
|
|
},
|
|
),
|
|
)
|