Prompt user to move to applications folder on first run
This commit is contained in:
@@ -91,6 +91,7 @@ export const UserSettingsSchema = z.object({
|
|||||||
autoApproveChanges: z.boolean().optional(),
|
autoApproveChanges: z.boolean().optional(),
|
||||||
telemetryConsent: z.enum(["opted_in", "opted_out", "unset"]).optional(),
|
telemetryConsent: z.enum(["opted_in", "opted_out", "unset"]).optional(),
|
||||||
telemetryUserId: z.string().optional(),
|
telemetryUserId: z.string().optional(),
|
||||||
|
hasRunBefore: z.boolean().optional(),
|
||||||
// DEPRECATED.
|
// DEPRECATED.
|
||||||
runtimeMode: RuntimeModeSchema.optional(),
|
runtimeMode: RuntimeModeSchema.optional(),
|
||||||
});
|
});
|
||||||
|
|||||||
37
src/main.ts
37
src/main.ts
@@ -1,4 +1,4 @@
|
|||||||
import { app, BrowserWindow } from "electron";
|
import { app, BrowserWindow, dialog } from "electron";
|
||||||
import * as path from "node:path";
|
import * as path from "node:path";
|
||||||
import { registerIpcHandlers } from "./ipc/ipc_host";
|
import { registerIpcHandlers } from "./ipc/ipc_host";
|
||||||
import dotenv from "dotenv";
|
import dotenv from "dotenv";
|
||||||
@@ -6,6 +6,7 @@ import dotenv from "dotenv";
|
|||||||
import started from "electron-squirrel-startup";
|
import started from "electron-squirrel-startup";
|
||||||
import { updateElectronApp } from "update-electron-app";
|
import { updateElectronApp } from "update-electron-app";
|
||||||
import log from "electron-log";
|
import log from "electron-log";
|
||||||
|
import { readSettings, writeSettings } from "./main/settings";
|
||||||
|
|
||||||
log.errorHandler.startCatching();
|
log.errorHandler.startCatching();
|
||||||
log.eventLogger.startLogging();
|
log.eventLogger.startLogging();
|
||||||
@@ -24,6 +25,40 @@ if (started) {
|
|||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this the first run of Fiddle? If so, perform
|
||||||
|
* tasks that we only want to do in this case.
|
||||||
|
*/
|
||||||
|
export async function onFirstRunMaybe() {
|
||||||
|
const settings = readSettings();
|
||||||
|
if (!settings.hasRunBefore) {
|
||||||
|
await promptMoveToApplicationsFolder();
|
||||||
|
writeSettings({
|
||||||
|
hasRunBefore: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ask the user if the app should be moved to the
|
||||||
|
* applications folder.
|
||||||
|
*/
|
||||||
|
async function promptMoveToApplicationsFolder(): Promise<void> {
|
||||||
|
if (process.platform !== "darwin") return;
|
||||||
|
if (app.isInApplicationsFolder()) return;
|
||||||
|
|
||||||
|
const { response } = await dialog.showMessageBox({
|
||||||
|
type: "question",
|
||||||
|
buttons: ["Move to Applications Folder", "Do Not Move"],
|
||||||
|
defaultId: 0,
|
||||||
|
message: "Move to Applications Folder? (required for auto-update)",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response === 0) {
|
||||||
|
app.moveToApplicationsFolder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
const MAIN_WINDOW_VITE_DEV_SERVER_URL: string;
|
const MAIN_WINDOW_VITE_DEV_SERVER_URL: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ const DEFAULT_SETTINGS: UserSettings = {
|
|||||||
providerSettings: {},
|
providerSettings: {},
|
||||||
telemetryConsent: "unset",
|
telemetryConsent: "unset",
|
||||||
telemetryUserId: uuidv4(),
|
telemetryUserId: uuidv4(),
|
||||||
|
hasRunBefore: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const SETTINGS_FILE = "user-settings.json";
|
const SETTINGS_FILE = "user-settings.json";
|
||||||
|
|||||||
Reference in New Issue
Block a user