feat: 데스크톱 알림을 포커스 중에도 항상 표시하도록 변경
기존엔 받는 사람이 앱 화면을 보고 있으면(포커스) OS 토스트를 띄우지 않고 종 알림만 갱신했으나, 화면을 보고 있어도 토스트가 뜨도록 변경한다. 서비스워커의 중복 방지(열린 탭 있으면 표시 생략)는 그대로라 토스트는 여전히 1개다. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,13 +6,11 @@ import { DEFAULT_PAGE_SIZE } from '@/types/pagination'
|
||||
import { escapeHtml, relativeTimeKo, taskDueInfo } from '@/shared/utils/format'
|
||||
import type { ApiNotification, NotificationView } from '@/types/notification'
|
||||
|
||||
// Level1 — 페이지가 열려 있을 때(특히 백그라운드 탭/최소화) OS 토스트.
|
||||
// 포커스 상태면 인앱 종 알림만(active 사용자 방해 금지). 닫혀 있으면 서비스워커 푸시가 담당.
|
||||
// Level1 — 페이지가 열려 있으면(포커스 여부 무관) 항상 OS 토스트를 띄운다.
|
||||
// 페이지가 닫혀 있을 때는 서비스워커 푸시가 담당(SW 는 열린 탭이 있으면 표시 생략 → 중복 방지).
|
||||
function showLocalNotification(view: NotificationView): void {
|
||||
if (typeof Notification === 'undefined') return
|
||||
if (Notification.permission !== 'granted') return
|
||||
if (typeof document !== 'undefined' && document.visibilityState === 'visible')
|
||||
return
|
||||
try {
|
||||
const notif = new Notification('Relay', {
|
||||
body: view.text,
|
||||
@@ -194,7 +192,7 @@ export const useNotificationStore = defineStore('notification', () => {
|
||||
items.value.unshift(n)
|
||||
total.value += 1
|
||||
if (!n.read) unreadCount.value += 1
|
||||
// OS 토스트(Level1) — 백그라운드/최소화 상태일 때만
|
||||
// OS 토스트(Level1) — 페이지가 열려 있으면 포커스 여부와 무관하게 표시
|
||||
showLocalNotification(toView(n))
|
||||
} catch {
|
||||
// 파싱 실패(하트비트 등 비정상 페이로드) 무시
|
||||
|
||||
Reference in New Issue
Block a user