|
1 | | -import { getName } from "@tauri-apps/api/app"; |
| 1 | +import { getIdentifier } from "@tauri-apps/api/app"; |
2 | 2 | import { appDataDir } from "@tauri-apps/api/path"; |
3 | 3 | import { Effect, Exit } from "effect"; |
4 | 4 | import { create as mutate } from "mutative"; |
5 | 5 | import type { StoreApi } from "zustand"; |
6 | 6 |
|
| 7 | +import { commands as detectCommands } from "@hypr/plugin-detect"; |
7 | 8 | import { commands as hooksCommands } from "@hypr/plugin-hooks"; |
8 | 9 | import { |
9 | 10 | commands as listenerCommands, |
@@ -201,18 +202,30 @@ export const createGeneralSlice = < |
201 | 202 | }), |
202 | 203 | ); |
203 | 204 |
|
204 | | - Promise.all([appDataDir(), getName().catch(() => "com.hyprnote.app")]) |
205 | | - .then(([dataDirPath, appName]) => { |
| 205 | + Promise.all([ |
| 206 | + appDataDir(), |
| 207 | + detectCommands |
| 208 | + .listMicUsingApplications() |
| 209 | + .then((r) => |
| 210 | + r.status === "ok" ? r.data.map((app) => app.id) : null, |
| 211 | + ), |
| 212 | + getIdentifier().catch(() => "com.hyprnote.stable"), |
| 213 | + ]) |
| 214 | + .then(([dataDirPath, micUsingApps, bundleId]) => { |
206 | 215 | const sessionPath = `${dataDirPath}/hyprnote/sessions/${targetSessionId}`; |
207 | | - return hooksCommands.runEventHooks({ |
208 | | - beforeListeningStarted: { |
209 | | - args: { |
210 | | - resource_dir: sessionPath, |
211 | | - app_hyprnote: appName, |
212 | | - app_meeting: null, |
| 216 | + const app_meeting = micUsingApps?.[0] ?? null; |
| 217 | + |
| 218 | + hooksCommands |
| 219 | + .runEventHooks({ |
| 220 | + beforeListeningStarted: { |
| 221 | + args: { |
| 222 | + resource_dir: sessionPath, |
| 223 | + app_hyprnote: bundleId, |
| 224 | + app_meeting, |
| 225 | + }, |
213 | 226 | }, |
214 | | - }, |
215 | | - }); |
| 227 | + }) |
| 228 | + .catch(console.error); |
216 | 229 | }) |
217 | 230 | .catch((error) => { |
218 | 231 | console.error("[hooks] BeforeListeningStarted failed:", error); |
@@ -274,15 +287,15 @@ export const createGeneralSlice = < |
274 | 287 | if (sessionId) { |
275 | 288 | Promise.all([ |
276 | 289 | appDataDir(), |
277 | | - getName().catch(() => "com.hyprnote.app"), |
| 290 | + getIdentifier().catch(() => "com.hyprnote.app"), |
278 | 291 | ]) |
279 | | - .then(([dataDirPath, appName]) => { |
| 292 | + .then(([dataDirPath, bundleId]) => { |
280 | 293 | const sessionPath = `${dataDirPath}/hyprnote/sessions/${sessionId}`; |
281 | 294 | return hooksCommands.runEventHooks({ |
282 | 295 | afterListeningStopped: { |
283 | 296 | args: { |
284 | 297 | resource_dir: sessionPath, |
285 | | - app_hyprnote: appName, |
| 298 | + app_hyprnote: bundleId, |
286 | 299 | app_meeting: null, |
287 | 300 | }, |
288 | 301 | }, |
|
0 commit comments