mirror of
https://github.com/ivabus/gui
synced 2025-04-23 14:07:14 +03:00
make initialization a singleton (#517)
This commit is contained in:
parent
a5c80d4d5c
commit
d300efd805
1 changed files with 18 additions and 0 deletions
|
@ -16,7 +16,25 @@ const destinationDirectory = getGuiPath();
|
|||
// Get the binary path from the current app directory
|
||||
const binaryUrl = "https://tea.xyz/$(uname)/$(uname -m)";
|
||||
|
||||
let initializePromise: Promise<string> | null = null;
|
||||
|
||||
export async function initializeTeaCli(): Promise<string> {
|
||||
if (initializePromise) {
|
||||
return initializePromise;
|
||||
}
|
||||
|
||||
log.info("Initializing tea cli");
|
||||
initializePromise = initializeTeaCliInternal();
|
||||
|
||||
initializePromise.catch((error) => {
|
||||
log.info("Error initializing tea cli, resetting promise:", error);
|
||||
initializePromise = null;
|
||||
});
|
||||
|
||||
return initializePromise;
|
||||
}
|
||||
|
||||
async function initializeTeaCliInternal(): Promise<string> {
|
||||
try {
|
||||
let binCheck = "";
|
||||
let needsUpdate = false;
|
||||
|
|
Loading…
Reference in a new issue