[themes] hacks
not a good fix but it leads to better experience ig
This commit is contained in:
parent
ccb2a37f0d
commit
1d2577edb2
2 changed files with 16 additions and 17 deletions
10
src/index.ts
10
src/index.ts
|
|
@ -6,7 +6,7 @@ import { initVendettaObject } from "@core/vendettaObject";
|
|||
import { patchAssets } from "@lib/api/assets";
|
||||
import { patchCommands } from "@lib/api/commands";
|
||||
import { injectFluxInterceptor } from "@lib/api/flux";
|
||||
import { removeFile } from "@lib/api/native/fs";
|
||||
import { removeFile, writeFile } from "@lib/api/native/fs";
|
||||
import { isPyonLoader, isThemeSupported } from "@lib/api/native/loader";
|
||||
import { FileManager } from "@lib/api/native/modules";
|
||||
import { patchLogHook } from "@lib/debug";
|
||||
|
|
@ -22,8 +22,12 @@ export default async () => {
|
|||
// Themes
|
||||
if (isThemeSupported()) {
|
||||
try {
|
||||
if (isPyonLoader() && FileManager.removeFile != null) {
|
||||
removeFile("vendetta_theme.json", "");
|
||||
if (isPyonLoader()) {
|
||||
if (FileManager.removeFile != null) {
|
||||
removeFile("vendetta_theme.json", "");
|
||||
} else {
|
||||
writeFile("vendetta_theme.json", "null", "");
|
||||
}
|
||||
}
|
||||
initThemes();
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -141,6 +141,10 @@ function processData(data: ThemeData) {
|
|||
if (Platform.OS === "android") applyAndroidAlphaKeys(rawColors);
|
||||
}
|
||||
|
||||
// this field is required by the spec but vd seems to ignore this
|
||||
// so are most vd themes
|
||||
data.spec ??= 2;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
@ -191,17 +195,17 @@ export async function installTheme(id: string) {
|
|||
await fetchTheme(id);
|
||||
}
|
||||
|
||||
export function selectTheme(theme: Theme | null) {
|
||||
export function selectTheme(theme: Theme | null, write = true) {
|
||||
if (theme) theme.selected = true;
|
||||
Object.keys(themes).forEach(
|
||||
k => themes[k].selected = themes[k].id === theme?.id
|
||||
);
|
||||
|
||||
if (theme === null) {
|
||||
if (theme == null && write) {
|
||||
return writeTheme({});
|
||||
} else if (theme) {
|
||||
return writeTheme(theme);
|
||||
}
|
||||
|
||||
return writeTheme(theme);
|
||||
}
|
||||
|
||||
export async function removeTheme(id: string) {
|
||||
|
|
@ -258,16 +262,6 @@ function patchColor() {
|
|||
before("isThemeLight", isThemeModule, callback);
|
||||
before("updateTheme", ThemeManager, callback);
|
||||
|
||||
ThemeStore.addChangeListener(() => {
|
||||
if (ThemeStore.theme) {
|
||||
enabled = ThemeStore.theme === vdKey;
|
||||
if (!enabled) {
|
||||
selectTheme(null);
|
||||
vdThemeFallback = ThemeStore.theme;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
after("get", mmkvStorage, ([a], ret) => {
|
||||
if (a === "SelectivelySyncedUserSettingsStore") {
|
||||
storageResolved = true;
|
||||
|
|
@ -362,6 +356,7 @@ export function applyTheme(appliedTheme: Theme | null, fallbackTheme?: string) {
|
|||
if (!fallbackTheme) fallbackTheme = getDefaultFallbackTheme();
|
||||
|
||||
currentTheme = appliedTheme;
|
||||
enabled = !!currentTheme;
|
||||
vdThemeFallback = fallbackTheme!!;
|
||||
vdKey = `vd-theme-${inc++}-${fallbackTheme}`;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue