mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-09-19 16:17:37 +03:00
Convert then chain into await statements
This commit is contained in:
parent
91ca426378
commit
b3c2fd0c7e
@ -68,22 +68,16 @@ export async function invoke<T>(command: string, params: Record<string, unknown>
|
||||
// });
|
||||
const loadingItem = { name: command, startedAt: new Date() };
|
||||
isLoading.push(loadingItem);
|
||||
return await invokeTauri<T>(command, params)
|
||||
// .then((value) => {
|
||||
// console.debug(`ipc->${command}(${JSON.stringify(params)})`, value);
|
||||
// return value;
|
||||
// })
|
||||
.then((value) => {
|
||||
return value;
|
||||
})
|
||||
.catch((reason) => {
|
||||
const userError = UserError.fromError(reason);
|
||||
console.error(`ipc->${command}: ${JSON.stringify(params)}`, userError, reason);
|
||||
throw userError;
|
||||
})
|
||||
.finally(() => {
|
||||
isLoading.pop(loadingItem);
|
||||
});
|
||||
|
||||
try {
|
||||
return await invokeTauri<T>(command, params);
|
||||
} catch (reason) {
|
||||
const userError = UserError.fromError(reason);
|
||||
console.error(`ipc->${command}: ${JSON.stringify(params)}`, userError, reason);
|
||||
throw userError;
|
||||
} finally {
|
||||
isLoading.pop(loadingItem);
|
||||
}
|
||||
}
|
||||
|
||||
export function listen<T>(event: EventName, handle: EventCallback<T>) {
|
||||
|
Loading…
Reference in New Issue
Block a user