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) {
|
setState(newState) {
|
||||||
const oldState = this.state;
|
const oldState = Object.assign({}, this.state);
|
||||||
Object.assign(this.state, newState);
|
Object.assign(this.state, newState);
|
||||||
if (this.stateChanged) this.stateChanged(oldState, 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 updates() { return this.state.updates }
|
||||||
get bdUpdates() { return this.state.updates.bd }
|
get bdUpdates() { return this.state.updates.bd }
|
||||||
|
get error() { return null; }
|
||||||
|
get updatesAvailable() { return this.state.updatesAvailable; }
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
updatesAvailable: false,
|
updatesAvailable: false,
|
||||||
error: null,
|
error: null,
|
||||||
updates: { bd: [] }
|
updates: { bd: [] },
|
||||||
|
updating: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
events(ipc) {
|
events(ipc) {
|
||||||
ipc.on('updater-checkForUpdates', () => {
|
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');
|
Events.emit('update-check-start');
|
||||||
});
|
});
|
||||||
|
|
||||||
ipc.on('updater-noUpdates', () => {
|
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) => {
|
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>
|
<template>
|
||||||
<SettingsWrapper headertext="Updates">
|
<SettingsWrapper headertext="Updates">
|
||||||
<div class="bd-flex bd-flexCol bd-updaterview">
|
<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>
|
</div>
|
||||||
</SettingsWrapper>
|
</SettingsWrapper>
|
||||||
</template>
|
</template>
|
||||||
|
@ -36,13 +47,19 @@
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
updatesAvailable() {
|
updatesAvailable() {
|
||||||
return false;
|
return this.updater.updatesAvailable;
|
||||||
},
|
},
|
||||||
newVersion() {
|
newVersion() {
|
||||||
return '2.0.0-beta.4';
|
return '2.0.0-beta.4';
|
||||||
},
|
},
|
||||||
error() {
|
error() {
|
||||||
return null;
|
return this.updater.error;
|
||||||
|
},
|
||||||
|
updates() {
|
||||||
|
return this.updater.updates;
|
||||||
|
},
|
||||||
|
bdUpdates() {
|
||||||
|
return this.updater.bdUpdates;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
Loading…
Reference in New Issue