11import { emit } from "@tauri-apps/api/event" ;
22import * as dialog from "@tauri-apps/plugin-dialog" ;
3- import type { SetStoreFunction } from "solid-js/store" ;
43import type { createOptionsQuery } from "./queries" ;
5- import {
6- commands ,
7- type RecordingAction ,
8- type StartRecordingInputs ,
9- } from "./tauri" ;
10-
11- const buttons = {
12- yes : "Login" ,
13- no : "Switch to Studio mode" ,
14- cancel : "Cancel" ,
15- } ;
4+ import { commands , type RecordingAction } from "./tauri" ;
165
176export function handleRecordingResult (
187 result : Promise < RecordingAction > ,
19- setOptions : ReturnType < typeof createOptionsQuery > [ "setOptions" ] ,
8+ setOptions : ReturnType < typeof createOptionsQuery > [ "setOptions" ] | undefined ,
209) {
2110 return result
2211 . then ( async ( result ) => {
2312 if ( result === "InvalidAuthentication" ) {
13+ const buttons = setOptions
14+ ? {
15+ yes : "Login" ,
16+ no : "Switch to Studio mode" ,
17+ cancel : "Cancel" ,
18+ }
19+ : {
20+ ok : "Login" ,
21+ cancel : "Cancel" ,
22+ } ;
23+
2424 const result = await dialog . message (
2525 "You must be authenticated to start an instant mode recording. Login or switch to Studio mode." ,
2626 {
@@ -29,8 +29,10 @@ export function handleRecordingResult(
2929 } ,
3030 ) ;
3131
32- if ( result === buttons . yes ) emit ( "start-sign-in" ) ;
33- else if ( result === buttons . no ) setOptions ( { mode : "studio" } ) ;
32+ if ( result === buttons . yes || result === buttons . ok )
33+ emit ( "start-sign-in" ) ;
34+ else if ( result === buttons . no && setOptions )
35+ setOptions ( { mode : "studio" } ) ;
3436 } else if ( result === "UpgradeRequired" ) commands . showWindow ( "Upgrade" ) ;
3537 else
3638 await dialog . message ( `Error: ${ result } ` , {
0 commit comments