From 1ea3b2b8d2822ed44131220ba9411dddd27ec510 Mon Sep 17 00:00:00 2001 From: "soroush.asadi" Date: Fri, 5 Jun 2026 00:38:08 +0330 Subject: [PATCH] Remove fake/periodic notifications (spam) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mock emitted random "a friend is online / event is live" notifications on a 35s timer and the live service forwarded them. Dropped both — only real notifications now fire (friend requests, achievements, daily reward, payment, match-ended, and server hub events). Co-Authored-By: Claude Opus 4.8 --- src/lib/online/mock-service.ts | 24 +----------------------- src/lib/online/signalr-service.ts | 6 ++---- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/src/lib/online/mock-service.ts b/src/lib/online/mock-service.ts index 6602a5a..68c4064 100644 --- a/src/lib/online/mock-service.ts +++ b/src/lib/online/mock-service.ts @@ -475,34 +475,12 @@ export class MockOnlineService implements OnlineService { /* --------------------------- notifications ------------------------- */ private notifCbs = new Set<(n: AppNotification) => void>(); - private notifTimer: ReturnType | null = null; + // Real notifications only — no periodic fake/"liveliness" spam. onNotification(cb: (n: AppNotification) => void): Unsubscribe { this.notifCbs.add(cb); - if (this.notifTimer == null) { - const samples: Array> = [ - { kind: "system", titleFa: "یک دوست آنلاین شد", titleEn: "A friend is online", icon: "👋" }, - { kind: "system", titleFa: "مسابقه‌ی امروز شروع شد", titleEn: "Today's event is live", icon: "🏆" }, - { kind: "invite", titleFa: "یک نفر دنبال هم‌بازیه", titleEn: "Someone is looking for a partner", icon: "🎴" }, - ]; - this.notifTimer = setInterval(() => { - if (this.notifCbs.size === 0) return; - const s = pick(samples); - const n: AppNotification = { - id: rid("ntf"), - ts: Date.now(), - read: false, - ...s, - }; - for (const c of this.notifCbs) c(n); - }, 35000); - } return () => { this.notifCbs.delete(cb); - if (this.notifCbs.size === 0 && this.notifTimer) { - clearInterval(this.notifTimer); - this.notifTimer = null; - } }; } diff --git a/src/lib/online/signalr-service.ts b/src/lib/online/signalr-service.ts index fb88a71..17bb333 100644 --- a/src/lib/online/signalr-service.ts +++ b/src/lib/online/signalr-service.ts @@ -58,7 +58,6 @@ export class SignalrService implements OnlineService { private chatCbs = new Set<(id: string, m: ChatMessage[]) => void>(); private forfeitCbs = new Set<(r: ForfeitRequest | null) => void>(); private cachedProfile: UserProfile | null = null; - private mockNotifUnsub?: () => void; constructor() { if (typeof window !== "undefined") { @@ -385,10 +384,9 @@ export class SignalrService implements OnlineService { onChat(cb: (id: string, m: ChatMessage[]) => void) { this.chatCbs.add(cb); return () => this.chatCbs.delete(cb); } onNotification(cb: (n: AppNotification) => void): Unsubscribe { + // Real notifications only — server hub "notification" events + app-generated + // ones (friend requests, achievements, daily, payment). No fake spam. this.notifCbs.add(cb); - // also forward the mock's periodic notifications for liveliness - if (!this.mockNotifUnsub) - this.mockNotifUnsub = this.mock.onNotification((n) => this.notifCbs.forEach((c) => c(n))); return () => this.notifCbs.delete(cb); }