diff --git a/src/main/base/store.ts b/src/main/base/store.ts index e733c8d6..db8f679d 100644 --- a/src/main/base/store.ts +++ b/src/main/base/store.ts @@ -15,6 +15,7 @@ export class Store { "update_branch": "main", "resumeOnStartupBehavior": "local", "privateEnabled": false, + "themeUpdateNotification": true }, "home": { "followedArtists": [], diff --git a/src/renderer/index.js b/src/renderer/index.js index f2365003..62a18456 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -905,6 +905,28 @@ const app = new Vue({ }, 500) ipcRenderer.invoke("renderer-ready", true) document.querySelector("#LOADER").remove() + if(this.cfg.general.themeUpdateNotification) { + this.checkForThemeUpdates() + } + }, + async checkForThemeUpdates() { + let self = this + const themes = ipcRenderer.sendSync("get-themes") + await asyncForEach(themes, async (theme) => { + if (theme.commit != "") { + await fetch(`https://api.github.com/repos/${theme.github_repo}/commits`) + .then(res => res.json()) + .then(res => { + if (res[0].sha != theme.commit) { + const notify = notyf.open({ className: "notyf-info", type: "info", message: `[Themes] ${theme.name} has an update available.` }) + notify.on("click", ()=>{ + app.appRoute("themes-github") + notyf.dismiss(notify) + }) + } + }) + } + }) }, async setTheme(theme = "", onlyPrefs = false) { console.log(theme) diff --git a/src/renderer/less/helpers.less b/src/renderer/less/helpers.less index d437c18f..712d498c 100644 --- a/src/renderer/less/helpers.less +++ b/src/renderer/less/helpers.less @@ -1,3 +1,13 @@ +.notyf__toast { + -webkit-app-region: no-drag; + cursor: pointer; +} + +.notyf-info { + background: var(--keyColor); +} + + .modal-fullscreen { display: flex; diff --git a/src/renderer/views/pages/themes-github.ejs b/src/renderer/views/pages/themes-github.ejs index 08d2eb28..cf70b743 100644 --- a/src/renderer/views/pages/themes-github.ejs +++ b/src/renderer/views/pages/themes-github.ejs @@ -6,7 +6,8 @@

{{$root.getLz('settings.header.visual.theme.github.page')}}

- @@ -33,12 +34,14 @@
-

{{ (repo.description != null) ? repo.description : repo.full_name }}

+

{{ (repo.description != null) ? repo.description : + repo.full_name }}

⭐ {{ repo.stargazers_count }}
- +
@@ -52,7 +55,8 @@

{{ openRepo.description }}

-
+
{{ openRepo.full_name }}
⭐ {{ openRepo.stargazers_count }}
@@ -60,7 +64,7 @@
@@ -102,6 +106,7 @@ this.themes = ipcRenderer.sendSync("get-themes") this.getRepos(); this.getInstalledThemes(); + app.checkForThemeUpdates() }, methods: { openThemesFolder() { @@ -113,7 +118,7 @@ // for each theme, get the github_repo property and push it to the themesInstalled array, if not blank themes.forEach(theme => { if (theme.github_repo !== "" && typeof theme.commit != "") { - self.themesInstalled.push(theme.github_repo) + self.themesInstalled.push(theme.github_repo.toLowerCase()) } }) },