feat: update codex live chat workflow
This commit is contained in:
20
src/sw.js
20
src/sw.js
@@ -76,6 +76,10 @@ self.addEventListener('notificationclick', (event) => {
|
||||
const notificationCategory = typeof notificationData.category === 'string' ? notificationData.category.trim() : '';
|
||||
const notificationType = typeof notificationData.type === 'string' ? notificationData.type.trim() : '';
|
||||
const notificationThreadId = typeof notificationData.threadId === 'string' ? notificationData.threadId.trim() : '';
|
||||
const isChatNotification =
|
||||
notificationCategory === 'chat' ||
|
||||
notificationType.startsWith('chat') ||
|
||||
notificationThreadId.startsWith('chat:');
|
||||
|
||||
event.notification.close();
|
||||
let targetUrl;
|
||||
@@ -98,6 +102,17 @@ self.addEventListener('notificationclick', (event) => {
|
||||
targetUrl.searchParams.set('topMenu', notificationData.category === 'chat' ? 'chat' : 'plans');
|
||||
}
|
||||
|
||||
if (isChatNotification) {
|
||||
targetUrl.pathname = '/chat/live';
|
||||
targetUrl.searchParams.set('topMenu', 'chat');
|
||||
targetUrl.searchParams.delete('chatView');
|
||||
targetUrl.searchParams.delete('runtimeRequestId');
|
||||
|
||||
if (notificationSessionId) {
|
||||
targetUrl.searchParams.set('sessionId', notificationSessionId);
|
||||
}
|
||||
}
|
||||
|
||||
if (notificationData.planId && !targetUrl.searchParams.has('planId')) {
|
||||
targetUrl.searchParams.set('planId', String(notificationData.planId));
|
||||
}
|
||||
@@ -109,11 +124,6 @@ self.addEventListener('notificationclick', (event) => {
|
||||
event.waitUntil(
|
||||
Promise.all([
|
||||
self.registration.getNotifications().then((notifications) => {
|
||||
const isChatNotification =
|
||||
notificationCategory === 'chat' ||
|
||||
notificationType.startsWith('chat') ||
|
||||
notificationThreadId.startsWith('chat:');
|
||||
|
||||
if (!notificationSessionId || !isChatNotification) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user