-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1409 from hydralauncher/feature/custom-themes
Feature/custom themes
- Loading branch information
Showing
68 changed files
with
1,857 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Theme } from "@types"; | ||
import { registerEvent } from "../register-event"; | ||
import { themesSublevel } from "@main/level"; | ||
|
||
const addCustomTheme = async ( | ||
_event: Electron.IpcMainInvokeEvent, | ||
theme: Theme | ||
) => { | ||
await themesSublevel.put(theme.id, theme); | ||
}; | ||
|
||
registerEvent("addCustomTheme", addCustomTheme); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { WindowManager } from "@main/services"; | ||
import { registerEvent } from "../register-event"; | ||
|
||
const closeEditorWindow = async ( | ||
_event: Electron.IpcMainInvokeEvent, | ||
themeId?: string | ||
) => { | ||
WindowManager.closeEditorWindow(themeId); | ||
}; | ||
|
||
registerEvent("closeEditorWindow", closeEditorWindow); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { themesSublevel } from "@main/level"; | ||
import { registerEvent } from "../register-event"; | ||
|
||
const deleteAllCustomThemes = async (_event: Electron.IpcMainInvokeEvent) => { | ||
await themesSublevel.clear(); | ||
}; | ||
|
||
registerEvent("deleteAllCustomThemes", deleteAllCustomThemes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { themesSublevel } from "@main/level"; | ||
import { registerEvent } from "../register-event"; | ||
|
||
const deleteCustomTheme = async ( | ||
_event: Electron.IpcMainInvokeEvent, | ||
themeId: string | ||
) => { | ||
await themesSublevel.del(themeId); | ||
}; | ||
|
||
registerEvent("deleteCustomTheme", deleteCustomTheme); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { themesSublevel } from "@main/level"; | ||
import { registerEvent } from "../register-event"; | ||
|
||
const getActiveCustomTheme = async () => { | ||
const allThemes = await themesSublevel.values().all(); | ||
return allThemes.find((theme) => theme.isActive); | ||
}; | ||
|
||
registerEvent("getActiveCustomTheme", getActiveCustomTheme); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { themesSublevel } from "@main/level"; | ||
import { registerEvent } from "../register-event"; | ||
|
||
const getAllCustomThemes = async (_event: Electron.IpcMainInvokeEvent) => { | ||
return themesSublevel.values().all(); | ||
}; | ||
|
||
registerEvent("getAllCustomThemes", getAllCustomThemes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { themesSublevel } from "@main/level"; | ||
import { registerEvent } from "../register-event"; | ||
|
||
const getCustomThemeById = async ( | ||
_event: Electron.IpcMainInvokeEvent, | ||
themeId: string | ||
) => { | ||
return themesSublevel.get(themeId); | ||
}; | ||
|
||
registerEvent("getCustomThemeById", getCustomThemeById); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { WindowManager } from "@main/services"; | ||
import { registerEvent } from "../register-event"; | ||
|
||
const openEditorWindow = async ( | ||
_event: Electron.IpcMainInvokeEvent, | ||
themeId: string | ||
) => { | ||
WindowManager.openEditorWindow(themeId); | ||
}; | ||
|
||
registerEvent("openEditorWindow", openEditorWindow); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { themesSublevel } from "@main/level"; | ||
import { registerEvent } from "../register-event"; | ||
|
||
const toggleCustomTheme = async ( | ||
_event: Electron.IpcMainInvokeEvent, | ||
themeId: string, | ||
isActive: boolean | ||
) => { | ||
const theme = await themesSublevel.get(themeId); | ||
|
||
if (!theme) { | ||
throw new Error("Theme not found"); | ||
} | ||
|
||
await themesSublevel.put(themeId, { | ||
...theme, | ||
isActive, | ||
updatedAt: new Date(), | ||
}); | ||
}; | ||
|
||
registerEvent("toggleCustomTheme", toggleCustomTheme); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { themesSublevel } from "@main/level"; | ||
import { registerEvent } from "../register-event"; | ||
import { WindowManager } from "@main/services"; | ||
|
||
const updateCustomTheme = async ( | ||
_event: Electron.IpcMainInvokeEvent, | ||
themeId: string, | ||
code: string | ||
) => { | ||
const theme = await themesSublevel.get(themeId); | ||
|
||
if (!theme) { | ||
throw new Error("Theme not found"); | ||
} | ||
|
||
await themesSublevel.put(themeId, { | ||
...theme, | ||
code, | ||
updatedAt: new Date(), | ||
}); | ||
|
||
if (theme.isActive) { | ||
WindowManager.mainWindow?.webContents.send("css-injected", code); | ||
} | ||
}; | ||
|
||
registerEvent("updateCustomTheme", updateCustomTheme); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,10 @@ | ||
import { registerEvent } from "../register-event"; | ||
import { db, levelKeys } from "@main/level"; | ||
import { Crypto } from "@main/services"; | ||
import type { UserPreferences } from "@types"; | ||
|
||
const getUserPreferences = async () => | ||
db | ||
.get<string, UserPreferences | null>(levelKeys.userPreferences, { | ||
valueEncoding: "json", | ||
}) | ||
.then((userPreferences) => { | ||
if (userPreferences?.realDebridApiToken) { | ||
userPreferences.realDebridApiToken = Crypto.decrypt( | ||
userPreferences.realDebridApiToken | ||
); | ||
} | ||
|
||
if (userPreferences?.torBoxApiToken) { | ||
userPreferences.torBoxApiToken = Crypto.decrypt( | ||
userPreferences.torBoxApiToken | ||
); | ||
} | ||
|
||
return userPreferences; | ||
}); | ||
db.get<string, UserPreferences | null>(levelKeys.userPreferences, { | ||
valueEncoding: "json", | ||
}); | ||
|
||
registerEvent("getUserPreferences", getUserPreferences); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.