This commit is contained in:
NoCrypt 2024-07-30 15:35:04 +07:00
commit 0e68eadc82
4 changed files with 45 additions and 19 deletions

View file

@ -1,7 +1,7 @@
ext {
minSdkVersion = 22
compileSdkVersion = 33
targetSdkVersion = 33
compileSdkVersion = 34
targetSdkVersion = 34
androidxActivityVersion = '1.7.0'
androidxAppCompatVersion = '1.6.1'
androidxCoordinatorLayoutVersion = '1.2.0'

View file

@ -9,9 +9,40 @@
import { logout } from './Logout.svelte'
import { rss } from '@/views/TorrentSearch/TorrentModal.svelte'
import IPC from '@/modules/ipc.js'
let wasUpdated = false
globalThis.dd = IPC
IPC.on('update-available', () => {
console.log('uwu')
if (!wasUpdated) {
// insert icon in 2nd to last position
links.splice(links.length - 1, 0, {
click: () => {
toast('Update is downloading...')
},
icon: 'download',
text: 'Update Downloading...'
})
links = links
}
wasUpdated = true
})
IPC.on('update-downloaded', () => {
links[links.length - 2].css = 'update'
links[links.length - 2].text = 'Update Ready!'
links[links.length - 2].click = () => {
IPC.emit('quit-and-install')
}
links = links
})
const view = getContext('view')
export let page
const links = [
let links = [
{
click: () => {
if (anilistClient.userID?.viewer?.data?.Viewer) {
@ -109,7 +140,7 @@
<div class='sidebar z-30 d-md-block' class:animated={$settings.expandingSidebar}>
<div class='sidebar-overlay pointer-events-none h-full position-absolute' />
<div class='sidebar-menu h-full d-flex flex-column justify-content-center align-items-center m-0 pb-5' class:animate={page !== 'player'}>
{#each links as { click: _click, icon, text, image, css, page: _page }, i (i)}
{#each links as { click: _click, icon, text, image, css, page: _page } (_click)}
<div
class='sidebar-link sidebar-link-with-icon pointer overflow-hidden {css}'
use:click={_click}>
@ -150,6 +181,10 @@
color: #fa68b6;
text-shadow: 0 0 1rem #fa68b6;
}
.update .material-symbols-outlined {
color: #47cb6a;
font-variation-settings: 'FILL' 1;
}
.sidebar-menu {
padding-top: 10rem;
}

View file

@ -20,21 +20,6 @@
IPC.on('version', data => (version = data))
IPC.emit('version')
let wasUpdated = false
IPC.on('update-available', () => {
if (!wasUpdated) {
wasUpdated = true
toast('Auto Updater', {
description: 'A new version of Migu is available. Downloading!'
})
}
})
IPC.on('update-downloaded', () => {
toast.success('Auto Updater', {
description: 'A new version of Migu has downloaded. You can restart to update!'
})
})
const changeLog = (async () => {
const res = await fetch('https://api.github.com/repos/ThaUnknown/miru/releases')
const json = await res.json()

View file

@ -23,6 +23,12 @@ export default class Updater {
this.hasUpdate = true
window.webContents.send('update-downloaded', true)
})
ipcMain.on('quit-and-install', () => {
if (this.hasUpdate) {
autoUpdater.quitAndInstall()
this.hasUpdate = false
}
})
}
install () {