- Replaced `LIST_PUBLIC_CATEGORIES` with `LIST_ADMIN_CATEGORIES_FLAT` in `ArticleFormModal.tsx`. - Removed the "Add Event" button from the dashboard page. - Simplified the `EventsPage` by removing the button and adjusting the layout. - Cleaned up the `AdminEventEditPage` by removing unnecessary props. - Deleted unused layout and page files related to event creation. - Updated `AdminAuthContent` to use `useAdminCitiesQuery` instead of `useDiscoveryCitiesQuery`. - Refactored `EventGuestListAccessPanel` to remove the `accessMode` prop and adjust API calls accordingly. - Removed several unused components and tests related to event creation, enhancing project maintainability.
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import {
|
|
errorResult,
|
|
handleServiceError,
|
|
type ServiceCallOptions,
|
|
type ServiceResult,
|
|
shouldBubbleErrorToParent,
|
|
successResult,
|
|
} from '@/services/errorHandler'
|
|
import { getNotifications } from '@/api/generated/notifications/notifications'
|
|
import { clearStoredPushSubscriptionId, getStoredPushSubscriptionId, unsubscribeBrowserPushManager } from '@/lib/pwa'
|
|
|
|
const notificationsApi = getNotifications()
|
|
|
|
const UNSUBSCRIBE_PUSH = async (
|
|
subscriptionId: string,
|
|
options?: ServiceCallOptions
|
|
): Promise<ServiceResult<{ deleted: boolean }>> => {
|
|
try {
|
|
await notificationsApi.notificationsControllerUnsubscribePush(subscriptionId)
|
|
|
|
return successResult({ deleted: true })
|
|
} catch (error) {
|
|
const normalizedError = handleServiceError(error, options)
|
|
|
|
if (shouldBubbleErrorToParent(options)) {
|
|
throw normalizedError
|
|
}
|
|
|
|
return errorResult(normalizedError)
|
|
}
|
|
}
|
|
|
|
/** Best-effort cleanup on admin logout — no subscribe flow in this app. */
|
|
export const unsubscribeCurrentDevicePush = async (): Promise<void> => {
|
|
const subscriptionId = getStoredPushSubscriptionId()
|
|
|
|
try {
|
|
if (subscriptionId) {
|
|
await UNSUBSCRIBE_PUSH(subscriptionId, { errorMode: 'silent' })
|
|
}
|
|
} finally {
|
|
clearStoredPushSubscriptionId()
|
|
await unsubscribeBrowserPushManager().catch(() => undefined)
|
|
}
|
|
}
|