| 240 | } |
| 241 | |
| 242 | export function createLicenseQuery() { |
| 243 | const query = createQuery(() => ({ |
| 244 | queryKey: ["licenseQuery"], |
| 245 | queryFn: async () => { |
| 246 | const settings = await generalSettingsStore.get(); |
| 247 | const auth = await authStore.get(); |
| 248 | |
| 249 | if (auth?.plan?.upgraded) return { type: "pro" as const, ...auth.plan }; |
| 250 | if (settings?.commercialLicense) |
| 251 | return { |
| 252 | type: "commercial" as const, |
| 253 | ...settings.commercialLicense, |
| 254 | instanceId: settings.instanceId, |
| 255 | }; |
| 256 | return { type: "personal" as const }; |
| 257 | }, |
| 258 | })); |
| 259 | |
| 260 | const generalSettingsCleanup = generalSettingsStore.listen(() => |
| 261 | query.refetch(), |
| 262 | ); |
| 263 | const authCleanup = authStore.listen(() => query.refetch()); |
| 264 | |
| 265 | onCleanup(() => { |
| 266 | generalSettingsCleanup.then((cleanup) => cleanup()); |
| 267 | authCleanup.then((cleanup) => cleanup()); |
| 268 | }); |
| 269 | |
| 270 | return query; |
| 271 | } |
| 272 | |
| 273 | export function createCameraMutation() { |
| 274 | const { setOptions, rawOptions } = useRecordingOptions(); |