Added Phase‑1 continuation work across deep links, offline moderation queue, and admin push.
resources/js/admin/mobile/lib.
- Admin push is end‑to‑end: new backend model/migration/service/job + API endpoints, admin runtime config, push‑aware
service worker, and a settings toggle via useAdminPushSubscription. Notifications now auto‑refresh on push.
- New PHP/JS tests: admin push API feature test and queue/haptics unit tests
Added admin-specific PWA icon assets and wired them into the admin manifest, service worker, and admin shell, plus a
new “Device & permissions” card in mobile Settings with a persistent storage action and translations.
Details: public/manifest.json, public/admin-sw.js, resources/views/admin.blade.php, new icons in public/; new hook
resources/js/admin/mobile/hooks/useDevicePermissions.ts, helpers/tests in resources/js/admin/mobile/lib/
devicePermissions.ts + resources/js/admin/mobile/lib/devicePermissions.test.ts, and Settings UI updates in resources/
js/admin/mobile/SettingsPage.tsx with copy in resources/js/admin/i18n/locales/en/management.json and resources/js/
admin/i18n/locales/de/management.json.
This commit is contained in:
69
resources/js/admin/mobile/lib/photoModerationQueue.ts
Normal file
69
resources/js/admin/mobile/lib/photoModerationQueue.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
export type PhotoModerationAction = {
|
||||
id: string;
|
||||
eventSlug: string;
|
||||
photoId: number;
|
||||
action: 'approve' | 'hide' | 'show' | 'feature' | 'unfeature';
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'fotospiel-admin-photo-queue';
|
||||
|
||||
function buildId(): string {
|
||||
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
||||
return crypto.randomUUID();
|
||||
}
|
||||
|
||||
return `${Date.now()}-${Math.random().toString(16).slice(2, 10)}`;
|
||||
}
|
||||
|
||||
export function loadPhotoQueue(): PhotoModerationAction[] {
|
||||
if (typeof window === 'undefined') {
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
const raw = window.localStorage.getItem(STORAGE_KEY);
|
||||
if (!raw) {
|
||||
return [];
|
||||
}
|
||||
const parsed = JSON.parse(raw);
|
||||
return Array.isArray(parsed) ? (parsed as PhotoModerationAction[]) : [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export function savePhotoQueue(queue: PhotoModerationAction[]): void {
|
||||
if (typeof window === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(queue));
|
||||
} catch {
|
||||
// Ignore persistence failures.
|
||||
}
|
||||
}
|
||||
|
||||
export function enqueuePhotoAction(action: Omit<PhotoModerationAction, 'id' | 'createdAt'>): PhotoModerationAction[] {
|
||||
const queue = loadPhotoQueue();
|
||||
const entry: PhotoModerationAction = {
|
||||
...action,
|
||||
id: buildId(),
|
||||
createdAt: new Date().toISOString(),
|
||||
};
|
||||
const next = [...queue, entry];
|
||||
savePhotoQueue(next);
|
||||
return next;
|
||||
}
|
||||
|
||||
export function removePhotoAction(queue: PhotoModerationAction[], id: string): PhotoModerationAction[] {
|
||||
const next = queue.filter((item) => item.id !== id);
|
||||
savePhotoQueue(next);
|
||||
return next;
|
||||
}
|
||||
|
||||
export function replacePhotoQueue(queue: PhotoModerationAction[]): PhotoModerationAction[] {
|
||||
savePhotoQueue(queue);
|
||||
return queue;
|
||||
}
|
||||
Reference in New Issue
Block a user