assign old state, some updater checks.
This commit is contained in:
parent
dc7247a12d
commit
0be6facba4
|
@ -39,7 +39,7 @@ export default class Module {
|
|||
}
|
||||
|
||||
setState(newState) {
|
||||
const oldState = this.state;
|
||||
const oldState = Object.assign({}, this.state);
|
||||
Object.assign(this.state, newState);
|
||||
if (this.stateChanged) this.stateChanged(oldState, newState);
|
||||
}
|
||||
|
|
|
@ -15,27 +15,44 @@ export default new class extends Module {
|
|||
|
||||
get updates() { return this.state.updates }
|
||||
get bdUpdates() { return this.state.updates.bd }
|
||||
get error() { return null; }
|
||||
get updatesAvailable() { return this.state.updatesAvailable; }
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
updatesAvailable: false,
|
||||
error: null,
|
||||
updates: { bd: [] }
|
||||
updates: { bd: [] },
|
||||
updating: false
|
||||
});
|
||||
}
|
||||
|
||||
events(ipc) {
|
||||
ipc.on('updater-checkForUpdates', () => {
|
||||
if (this.state.updating) return; // We're already updating. Updater should be paused anyways at this point.
|
||||
Events.emit('update-check-start');
|
||||
});
|
||||
|
||||
ipc.on('updater-noUpdates', () => {
|
||||
Events.emit('update-check-end');
|
||||
if (this.state.updatesAvailable) return; // If for some reason we get this even though we have updates already.
|
||||
this.setState({
|
||||
updatesAvailable: false,
|
||||
updates: {}
|
||||
});
|
||||
});
|
||||
|
||||
ipc.on('updater-updatesAvailable', (_, updates) => {
|
||||
console.log('UPDATES', updates);
|
||||
if (this.state.updating) return; // If for some reason we get more updates when we're already updating
|
||||
this.setState({
|
||||
updates,
|
||||
updatesAvailable: true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
stateChanged(oldState, newState) {
|
||||
if (!newState.updatesAvailable) return Events.emit('update-check-end');
|
||||
if (!oldState.updatesAvailable && newState.updatesAvailable) return Events.emit('updates-available');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,18 @@
|
|||
<template>
|
||||
<SettingsWrapper headertext="Updates">
|
||||
<div class="bd-flex bd-flexCol bd-updaterview">
|
||||
|
||||
<div class="bd-settingsCategories">
|
||||
<div class="bd-settingsCategory" v-if="bdUpdates && bdUpdates.length">
|
||||
<div class="bd-formItem">
|
||||
<h5>BetterDiscord</h5>
|
||||
</div>
|
||||
<div class="bd-formDivider"></div>
|
||||
<div v-for="update in bdUpdates">
|
||||
{{update.id}} - {{update.currentVersion}} - {{update.version}}
|
||||
<div class="bd-formDivider"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</SettingsWrapper>
|
||||
</template>
|
||||
|
@ -36,13 +47,19 @@
|
|||
},
|
||||
computed: {
|
||||
updatesAvailable() {
|
||||
return false;
|
||||
return this.updater.updatesAvailable;
|
||||
},
|
||||
newVersion() {
|
||||
return '2.0.0-beta.4';
|
||||
},
|
||||
error() {
|
||||
return null;
|
||||
return this.updater.error;
|
||||
},
|
||||
updates() {
|
||||
return this.updater.updates;
|
||||
},
|
||||
bdUpdates() {
|
||||
return this.updater.bdUpdates;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
Loading…
Reference in New Issue