chore: exclude local resource artifacts from main sync

This commit is contained in:
2026-05-15 10:16:45 +09:00
parent 442879313f
commit d38d022872
504 changed files with 17074 additions and 3642 deletions

96
src/app/main/notificationApi.ts Executable file → Normal file
View File

@@ -100,13 +100,6 @@ export type ClientNotificationSendResult = {
};
};
export type PwaNotificationTokenPayload = {
token: string;
deviceId?: string;
appOrigin?: string;
appDomain?: string;
};
function getCurrentAppOrigin() {
if (typeof window === 'undefined') {
return '';
@@ -169,7 +162,7 @@ const NOTIFICATION_MESSAGE_TABLE = 'notification_messages';
let notificationMessageTableSetupPromise: Promise<void> | null = null;
function emitNotificationMessagesUpdated() {
export function notifyNotificationMessagesUpdated() {
if (typeof window === 'undefined') {
return;
}
@@ -370,7 +363,7 @@ async function createNotificationMessageViaCrud(payload: CreateNotificationMessa
}
const item = mapNotificationMessageRow(row);
emitNotificationMessagesUpdated();
notifyNotificationMessagesUpdated();
return item;
}
@@ -398,7 +391,7 @@ async function updateNotificationMessageReadStateViaCrud(id: number, read: boole
}
const item = mapNotificationMessageRow(row);
emitNotificationMessagesUpdated();
notifyNotificationMessagesUpdated();
return item;
}
@@ -426,7 +419,7 @@ async function deleteNotificationMessageViaCrud(id: number) {
throw new NotificationApiError('삭제할 알림 메시지를 찾을 수 없습니다.', 404);
}
emitNotificationMessagesUpdated();
notifyNotificationMessagesUpdated();
}
async function requestOnce<T>(baseUrl: string, path: string, init?: RequestInit): Promise<T> {
@@ -606,7 +599,7 @@ export async function createNotificationMessage(payload: CreateNotificationMessa
}),
});
emitNotificationMessagesUpdated();
notifyNotificationMessagesUpdated();
return response.item;
} catch (error) {
if (error instanceof NotificationApiError && error.status === 404) {
@@ -626,7 +619,7 @@ export async function updateNotificationMessageReadState(id: number, read: boole
}),
});
emitNotificationMessagesUpdated();
notifyNotificationMessagesUpdated();
return response.item;
} catch (error) {
if (error instanceof NotificationApiError && error.status === 404) {
@@ -642,7 +635,7 @@ export async function deleteNotificationMessage(id: number) {
await request<{ ok: boolean; deleted: boolean }>(`/notifications/messages/${id}`, {
method: 'DELETE',
});
emitNotificationMessagesUpdated();
notifyNotificationMessagesUpdated();
} catch (error) {
if (error instanceof NotificationApiError && error.status === 404) {
return deleteNotificationMessageViaCrud(id);
@@ -690,10 +683,34 @@ export async function markChatNotificationMessagesAsRead(sessionId: string) {
return targetIds.length;
}
export async function dismissChatWebPushNotifications(sessionId: string) {
export async function dismissChatNotificationMessages(sessionId: string) {
const normalizedSessionId = sessionId.trim();
if (!normalizedSessionId || typeof navigator === 'undefined' || !('serviceWorker' in navigator)) {
if (!normalizedSessionId) {
return 0;
}
const response = await fetchNotificationMessages({
status: 'all',
limit: 100,
});
const targetIds = response.items
.filter((item) => item.category === 'chat' && getNotificationMetadataText(item.metadata, 'sessionId') === normalizedSessionId)
.map((item) => item.id);
if (targetIds.length === 0) {
return 0;
}
await Promise.allSettled(targetIds.map((id) => deleteNotificationMessage(id)));
return targetIds.length;
}
export async function dismissChatWebPushNotifications(sessionId?: string) {
const normalizedSessionId = typeof sessionId === 'string' ? sessionId.trim() : '';
if (typeof navigator === 'undefined' || !('serviceWorker' in navigator)) {
return 0;
}
@@ -716,17 +733,22 @@ export async function dismissChatWebPushNotifications(sessionId: string) {
const notificationType = getNotificationMetadataText(notificationData, 'type');
const notificationThreadId = getNotificationMetadataText(notificationData, 'threadId');
if (
(
notificationCategory === 'chat' ||
notificationType.startsWith('chat') ||
notificationThreadId.startsWith('chat:')
) &&
getNotificationMetadataText(notificationData, 'sessionId') === normalizedSessionId
) {
notification.close();
dismissedCount += 1;
const isChatNotification =
notificationCategory === 'chat' ||
notificationType.startsWith('chat') ||
notificationThreadId.startsWith('chat:');
const notificationSessionId = getNotificationMetadataText(notificationData, 'sessionId');
if (!isChatNotification) {
return;
}
if (normalizedSessionId && notificationSessionId !== normalizedSessionId) {
return;
}
notification.close();
dismissedCount += 1;
});
return dismissedCount;
@@ -761,28 +783,6 @@ export async function unregisterWebPushSubscription(endpoint: string) {
});
}
export async function registerPwaNotificationToken(payload: PwaNotificationTokenPayload) {
return request<{ ok: boolean; token: string }>('/notifications/tokens/ios', {
method: 'PUT',
body: JSON.stringify({
token: payload.token,
deviceId: payload.deviceId,
appOrigin: payload.appOrigin || getCurrentAppOrigin(),
appDomain: payload.appDomain || getCurrentAppDomain(),
enabled: true,
}),
});
}
export async function unregisterPwaNotificationToken(token: string) {
return request<{ ok: boolean; token: string; removed: boolean }>('/notifications/tokens/ios', {
method: 'DELETE',
body: JSON.stringify({
token,
}),
});
}
export function shouldFallbackToLocalNotification(result: ClientNotificationSendResult) {
return (
result.web.skipped === true ||