remove legacy code
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { app } from "electron";
|
import { app } from "electron";
|
||||||
import { existsSync, mkdirSync, readdirSync, renameSync, rmdirSync } from "fs";
|
import { existsSync, mkdirSync } from "fs";
|
||||||
import { dirname, join } from "path";
|
import { dirname, join } from "path";
|
||||||
|
|
||||||
const vesktopDir = dirname(process.execPath);
|
const vesktopDir = dirname(process.execPath);
|
||||||
@@ -15,28 +15,11 @@ export const PORTABLE =
|
|||||||
!process.execPath.toLowerCase().endsWith("electron.exe") &&
|
!process.execPath.toLowerCase().endsWith("electron.exe") &&
|
||||||
!existsSync(join(vesktopDir, "Uninstall Vesktop.exe"));
|
!existsSync(join(vesktopDir, "Uninstall Vesktop.exe"));
|
||||||
|
|
||||||
const LEGACY_DATA_DIR = join(app.getPath("appData"), "VencordDesktop", "VencordDesktop");
|
|
||||||
export const DATA_DIR =
|
export const DATA_DIR =
|
||||||
process.env.VENCORD_USER_DATA_DIR || (PORTABLE ? join(vesktopDir, "Data") : join(app.getPath("userData")));
|
process.env.VENCORD_USER_DATA_DIR || (PORTABLE ? join(vesktopDir, "Data") : join(app.getPath("userData")));
|
||||||
|
|
||||||
mkdirSync(DATA_DIR, { recursive: true });
|
mkdirSync(DATA_DIR, { recursive: true });
|
||||||
|
|
||||||
// TODO: remove eventually
|
|
||||||
if (existsSync(LEGACY_DATA_DIR)) {
|
|
||||||
try {
|
|
||||||
console.warn("Detected legacy settings dir", LEGACY_DATA_DIR + ".", "migrating to", DATA_DIR);
|
|
||||||
for (const file of readdirSync(LEGACY_DATA_DIR)) {
|
|
||||||
renameSync(join(LEGACY_DATA_DIR, file), join(DATA_DIR, file));
|
|
||||||
}
|
|
||||||
rmdirSync(LEGACY_DATA_DIR);
|
|
||||||
renameSync(
|
|
||||||
join(app.getPath("appData"), "VencordDesktop", "IndexedDB"),
|
|
||||||
join(DATA_DIR, "sessionData", "IndexedDB")
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
console.error("Migration failed", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const SESSION_DATA_DIR = join(DATA_DIR, "sessionData");
|
const SESSION_DATA_DIR = join(DATA_DIR, "sessionData");
|
||||||
app.setPath("sessionData", SESSION_DATA_DIR);
|
app.setPath("sessionData", SESSION_DATA_DIR);
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
||||||
import { dirname, join } from "path";
|
import { dirname, join } from "path";
|
||||||
import type { Settings as TSettings, State as TState } from "shared/settings";
|
import type { Settings as TSettings, State as TState } from "shared/settings";
|
||||||
import { SettingsStore } from "shared/utils/SettingsStore";
|
import { SettingsStore } from "shared/utils/SettingsStore";
|
||||||
@@ -35,18 +35,5 @@ function loadSettings<T extends object = any>(file: string, name: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const Settings = loadSettings<TSettings>(SETTINGS_FILE, "Vesktop settings");
|
export const Settings = loadSettings<TSettings>(SETTINGS_FILE, "Vesktop settings");
|
||||||
|
|
||||||
export const VencordSettings = loadSettings<any>(VENCORD_SETTINGS_FILE, "Vencord settings");
|
export const VencordSettings = loadSettings<any>(VENCORD_SETTINGS_FILE, "Vencord settings");
|
||||||
|
|
||||||
if (Object.hasOwn(Settings.plain, "firstLaunch") && !existsSync(STATE_FILE)) {
|
|
||||||
console.warn("legacy state in settings.json detected. migrating to state.json");
|
|
||||||
const state = {} as TState;
|
|
||||||
for (const prop of ["firstLaunch", "maximized", "minimized", "steamOSLayoutVersion", "windowBounds"] as const) {
|
|
||||||
state[prop] = Settings.plain[prop];
|
|
||||||
delete Settings.plain[prop];
|
|
||||||
}
|
|
||||||
Settings.markAsChanged();
|
|
||||||
writeFileSync(STATE_FILE, JSON.stringify(state, null, 4));
|
|
||||||
}
|
|
||||||
|
|
||||||
export const State = loadSettings<TState>(STATE_FILE, "Vesktop state");
|
export const State = loadSettings<TState>(STATE_FILE, "Vesktop state");
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
/* Workaround for making things in the draggable area clickable again on macOS */
|
|
||||||
.platform-osx [class*=topic_], .platform-osx [class*=notice_] button {
|
|
||||||
-webkit-app-region: no-drag;
|
|
||||||
}
|
|
||||||
@@ -4,8 +4,6 @@
|
|||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import "./fixes.css";
|
|
||||||
|
|
||||||
import { localStorage } from "./utils";
|
import { localStorage } from "./utils";
|
||||||
|
|
||||||
// Make clicking Notifications focus the window
|
// Make clicking Notifications focus the window
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ export function addPatch<P extends PatchData>(p: P) {
|
|||||||
const { patches, ...globals } = p;
|
const { patches, ...globals } = p;
|
||||||
|
|
||||||
for (const patch of patches) {
|
for (const patch of patches) {
|
||||||
// TODO: Update types
|
|
||||||
Vencord.Plugins.addPatch(patch, "Vesktop", "VesktopPatchGlobals");
|
Vencord.Plugins.addPatch(patch, "Vesktop", "VesktopPatchGlobals");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user