adds theme notifications

This commit is contained in:
booploops 2022-02-28 22:42:02 -08:00
parent b4de904cd0
commit e865e41b93
4 changed files with 44 additions and 6 deletions

View file

@ -15,6 +15,7 @@ export class Store {
"update_branch": "main", "update_branch": "main",
"resumeOnStartupBehavior": "local", "resumeOnStartupBehavior": "local",
"privateEnabled": false, "privateEnabled": false,
"themeUpdateNotification": true
}, },
"home": { "home": {
"followedArtists": [], "followedArtists": [],

View file

@ -905,6 +905,28 @@ const app = new Vue({
}, 500) }, 500)
ipcRenderer.invoke("renderer-ready", true) ipcRenderer.invoke("renderer-ready", true)
document.querySelector("#LOADER").remove() 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) { async setTheme(theme = "", onlyPrefs = false) {
console.log(theme) console.log(theme)

View file

@ -1,3 +1,13 @@
.notyf__toast {
-webkit-app-region: no-drag;
cursor: pointer;
}
.notyf-info {
background: var(--keyColor);
}
.modal-fullscreen { .modal-fullscreen {
display: flex; display: flex;

View file

@ -6,7 +6,8 @@
<h1 class="header-text">{{$root.getLz('settings.header.visual.theme.github.page')}}</h1> <h1 class="header-text">{{$root.getLz('settings.header.visual.theme.github.page')}}</h1>
</div> </div>
<div class="col-auto flex-center"> <div class="col-auto flex-center">
<select class="md-select" @change="$root.setTheme($root.cfg.visual.theme)" v-model="$root.cfg.visual.theme"> <select class="md-select" @change="$root.setTheme($root.cfg.visual.theme)"
v-model="$root.cfg.visual.theme">
<option value="default.less">{{$root.getLz('settings.option.visual.theme.default')}}</option> <option value="default.less">{{$root.getLz('settings.option.visual.theme.default')}}</option>
<option value="dark.less">{{$root.getLz('settings.option.visual.theme.dark')}}</option> <option value="dark.less">{{$root.getLz('settings.option.visual.theme.dark')}}</option>
<option v-for="theme in themes" :value="theme.file">{{ theme.name }}</option> <option v-for="theme in themes" :value="theme.file">{{ theme.name }}</option>
@ -33,12 +34,14 @@
<div class="row"> <div class="row">
<div class="col flex-center"> <div class="col flex-center">
<div> <div>
<h4 class="repo-name">{{ (repo.description != null) ? repo.description : repo.full_name }}</h4> <h4 class="repo-name">{{ (repo.description != null) ? repo.description :
repo.full_name }}</h4>
<div>⭐ {{ repo.stargazers_count }}</div> <div>⭐ {{ repo.stargazers_count }}</div>
</div> </div>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<span v-if="themesInstalled.includes(repo.full_name)" class="codicon codicon-cloud-download"></span> <span v-if="themesInstalled.includes(repo.full_name.toLowerCase())"
class="codicon codicon-cloud-download"></span>
</div> </div>
</div> </div>
</li> </li>
@ -52,7 +55,8 @@
<div> <div>
<h3 class="repo-preview-name">{{ openRepo.description }}</h3> <h3 class="repo-preview-name">{{ openRepo.description }}</h3>
<div> <div>
<div class="svg-icon inline" :style="{'--url': 'url(\'./assets/github.svg\')'}"></div> <div class="svg-icon inline"
:style="{'--url': 'url(\'./assets/github.svg\')'}"></div>
<a class="repo-url" target="_blank" :href="openRepo.html_url">{{ openRepo.full_name <a class="repo-url" target="_blank" :href="openRepo.html_url">{{ openRepo.full_name
}}</a></div> }}</a></div>
<div>⭐ {{ openRepo.stargazers_count }}</div> <div>⭐ {{ openRepo.stargazers_count }}</div>
@ -60,7 +64,7 @@
</div> </div>
<div class="col-auto nopadding flex-center"> <div class="col-auto nopadding flex-center">
<button class="md-btn md-btn-primary" @click="installThemeRepo(openRepo)"> <button class="md-btn md-btn-primary" @click="installThemeRepo(openRepo)">
<span v-if="!themesInstalled.includes(openRepo.full_name)">{{$root.getLz('action.install')}}</span> <span v-if="!themesInstalled.includes(openRepo.full_name.toLowerCase())">{{$root.getLz('action.install')}}</span>
<span v-else>{{$root.getLz('action.update')}}</span> <span v-else>{{$root.getLz('action.update')}}</span>
</button> </button>
</div> </div>
@ -102,6 +106,7 @@
this.themes = ipcRenderer.sendSync("get-themes") this.themes = ipcRenderer.sendSync("get-themes")
this.getRepos(); this.getRepos();
this.getInstalledThemes(); this.getInstalledThemes();
app.checkForThemeUpdates()
}, },
methods: { methods: {
openThemesFolder() { openThemesFolder() {
@ -113,7 +118,7 @@
// for each theme, get the github_repo property and push it to the themesInstalled array, if not blank // for each theme, get the github_repo property and push it to the themesInstalled array, if not blank
themes.forEach(theme => { themes.forEach(theme => {
if (theme.github_repo !== "" && typeof theme.commit != "") { if (theme.github_repo !== "" && typeof theme.commit != "") {
self.themesInstalled.push(theme.github_repo) self.themesInstalled.push(theme.github_repo.toLowerCase())
} }
}) })
}, },