@@ -6,7 +6,10 @@ import {
66 commands as detectCommands ,
77 events as detectEvents ,
88} from "@hypr/plugin-detect" ;
9- import { commands as notificationCommands } from "@hypr/plugin-notification" ;
9+ import {
10+ commands as notificationCommands ,
11+ type NotificationIcon ,
12+ } from "@hypr/plugin-notification" ;
1013
1114import { getSessionEventById } from "~/session/utils" ;
1215import * as main from "~/store/tinybase/store/main" ;
@@ -39,12 +42,49 @@ const BROWSER_MEETING_APP_IDS = new Set([
3942
4043type MainStore = NonNullable < ReturnType < typeof main . UI . useStore > > ;
4144
42- function getIgnorableAppIds ( apps : { id : string } [ ] ) {
43- return [
44- ...new Set (
45- apps . map ( ( app ) => app . id ) . filter ( ( id ) => id && ! id . startsWith ( "pid:" ) ) ,
46- ) ,
47- ] ;
45+ function getIgnorableApps ( apps : { id : string ; name : string } [ ] ) {
46+ const seen = new Set < string > ( ) ;
47+
48+ return apps . filter ( ( app ) => {
49+ if ( ! app . id || app . id . startsWith ( "pid:" ) || seen . has ( app . id ) ) {
50+ return false ;
51+ }
52+
53+ seen . add ( app . id ) ;
54+ return true ;
55+ } ) ;
56+ }
57+
58+ function getNotificationIconForAppId ( appId : string ) : NotificationIcon | null {
59+ if ( ! appId || appId . startsWith ( "pid:" ) ) {
60+ return null ;
61+ }
62+
63+ if ( appId . startsWith ( "/" ) || appId . startsWith ( "~/" ) ) {
64+ return { type : "path" , path : appId } ;
65+ }
66+
67+ return { type : "bundle_id" , bundle_id : appId } ;
68+ }
69+
70+ function getIgnoreAppsFooterText ( apps : { name : string } [ ] ) {
71+ const firstName = apps [ 0 ] ?. name . trim ( ) ;
72+
73+ if ( apps . length === 1 ) {
74+ return firstName ? `Ignore ${ firstName } ?` : "Ignore this app?" ;
75+ }
76+
77+ if ( ! firstName ) {
78+ return "Ignore these apps?" ;
79+ }
80+
81+ const secondName = apps [ 1 ] ?. name . trim ( ) ;
82+ if ( apps . length === 2 && secondName ) {
83+ return `Ignore ${ firstName } and ${ secondName } ?` ;
84+ }
85+
86+ const otherAppCount = apps . length - 1 ;
87+ return `Ignore ${ firstName } and ${ otherAppCount } other app${ otherAppCount === 1 ? "" : "s" } ?` ;
4888}
4989
5090function parseEventTimeMs ( value : string | undefined ) : number | null {
@@ -227,7 +267,8 @@ const useHandleDetectEvents = (store: ListenerStore) => {
227267 detectEvents . detectEvent
228268 . listen ( ( { payload } ) => {
229269 if ( payload . type === "micDetected" ) {
230- const appIds = getIgnorableAppIds ( payload . apps ) ;
270+ const ignorableApps = getIgnorableApps ( payload . apps ) ;
271+ const appIds = ignorableApps . map ( ( app ) => app . id ) ;
231272
232273 if ( store . getState ( ) . live . status === "active" ) {
233274 if ( appIds . length > 0 ) {
@@ -250,13 +291,11 @@ const useHandleDetectEvents = (store: ListenerStore) => {
250291 const options =
251292 nearbyEvents . length > 0 ? nearbyEvents . map ( ( e ) => e . title ) : null ;
252293 const footer =
253- appIds . length > 0
294+ ignorableApps . length > 0
254295 ? {
255- text :
256- appIds . length === 1
257- ? "Ignore this app?"
258- : "Ignore these apps?" ,
296+ text : getIgnoreAppsFooterText ( ignorableApps ) ,
259297 actionLabel : "Yes" ,
298+ icon : getNotificationIconForAppId ( ignorableApps [ 0 ] ! . id ) ,
260299 }
261300 : null ;
262301
0 commit comments