-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added automatic updates support * Changed Beatsaber install directory check
- Loading branch information
1 parent
89d23e4
commit 72ac6ca
Showing
10 changed files
with
694 additions
and
4,543 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,56 @@ | ||
const log = require("electron-log"); | ||
const { autoUpdater } = require("electron-updater"); | ||
const { BrowserWindow, ipcMain } = require("electron"); | ||
|
||
function register() { | ||
autoUpdater.logger = log; | ||
autoUpdater.logger.transports.file.level = "info"; | ||
|
||
const sendStatusToWindow = (channel, text) => { | ||
log.info(`${channel}: ${text}`); | ||
|
||
BrowserWindow.getFocusedWindow().webContents.send(channel, text); | ||
}; | ||
|
||
autoUpdater.on("checking-for-update", () => { | ||
sendStatusToWindow("checkingForUpdate", "Checking for update..."); | ||
}); | ||
|
||
autoUpdater.on("update-available", info => { | ||
sendStatusToWindow("updateAvailable", "Update available."); | ||
}); | ||
|
||
autoUpdater.on("update-not-available", info => { | ||
sendStatusToWindow("updateNotAvailable", "Update not available."); | ||
}); | ||
|
||
autoUpdater.on("error", err => { | ||
sendStatusToWindow("updateError", "Error in auto-updater. " + err); | ||
}); | ||
|
||
autoUpdater.on("download-progress", progressObj => { | ||
let log_message = "Download speed: " + progressObj.bytesPerSecond; | ||
log_message = log_message + " - Downloaded " + progressObj.percent + "%"; | ||
log_message = | ||
log_message + | ||
" (" + | ||
progressObj.transferred + | ||
"/" + | ||
progressObj.total + | ||
")"; | ||
sendStatusToWindow("updateProgress", log_message); | ||
}); | ||
|
||
autoUpdater.on("update-downloaded", info => { | ||
sendStatusToWindow("updateDownloaded", "Update downloaded"); | ||
}); | ||
|
||
|
||
ipcMain.handle("restartAndUpdate", () => { | ||
autoUpdater.quitAndInstall(true, true); | ||
}); | ||
|
||
return autoUpdater; | ||
} | ||
|
||
module.exports = { register }; |
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,34 @@ | ||
<script> | ||
import Dialog from "../components/Dialog.svelte"; | ||
import { createEventDispatcher } from "svelte"; | ||
import { updateDialogStore } from "../stores/update-ready-dialog.store"; | ||
function handleYesClicked() { | ||
updateDialogStore.updateAndRestart(); | ||
} | ||
function handleNoClicked() { | ||
updateDialogStore.close(); | ||
} | ||
</script> | ||
|
||
<style> | ||
.dialog-content { | ||
color: var(--foregroundText); | ||
} | ||
</style> | ||
|
||
{#if $updateDialogStore.isOpen} | ||
<Dialog> | ||
<div class="dialog-content" slot="dialog-content"> | ||
<h1>Update Ready</h1> | ||
<div> | ||
<p>An update is ready. Do you want to restart and update?</p> | ||
</div> | ||
</div> | ||
<div slot="dialog-actions"> | ||
<button on:click={handleYesClicked}>Yes</button> | ||
<button on:click={handleNoClicked}>No</button> | ||
</div> | ||
</Dialog> | ||
{/if} |
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,29 @@ | ||
import { writable } from "svelte/store"; | ||
|
||
const electron = require("electron"); | ||
const { ipcRenderer } = electron; | ||
|
||
function createUpdateDialogStore() { | ||
const store = writable({ | ||
isOpen: false | ||
}); | ||
|
||
ipcRenderer.on("updateDownloaded", () => { | ||
store.set({ isOpen: true }); | ||
}); | ||
|
||
return { | ||
subscribe: store.subscribe, | ||
open: () => { | ||
store.set({ isOpen: true }); | ||
}, | ||
close: () => { | ||
store.set({ isOpen: false }); | ||
}, | ||
updateAndRestart: () => { | ||
ipcRenderer.invoke("restartAndUpdate"); | ||
} | ||
}; | ||
} | ||
|
||
export const updateDialogStore = createUpdateDialogStore(); |