mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 04:55:42 +09:00
fix(desktop): stop the updater button flickering after download (#2089)
This commit is contained in:
1 parent
96c5db3f5d
commit
9b8659a40b
3 files changed
+60
-1
No files matched your search
@@ -45,6 +45,36 @@ describe('updaterStateMachine', () => {
|
||||
expect(snapshot.context.updateInfo.web.available).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps a downloaded native update pending restart when checks re-emit available or not-available', () => {
|
||||
let snapshot = createUpdaterMachineSnapshot();
|
||||
snapshot = transition(snapshot, {
|
||||
type: 'native.available',
|
||||
version: '2.0.0',
|
||||
downloadSize: 1000,
|
||||
downloadStarted: true,
|
||||
downloadUrl: null,
|
||||
downloadOptions: [],
|
||||
});
|
||||
snapshot = transition(snapshot, {type: 'native.downloaded', version: '2.0.0'});
|
||||
expect(snapshot.context.updateInfo.native.downloaded).toBe(true);
|
||||
|
||||
snapshot = transition(snapshot, {type: 'native.notAvailable', now: NOW});
|
||||
expect(snapshot.context.updateInfo.native.downloaded).toBe(true);
|
||||
expect(snapshot.context.updateInfo.native.available).toBe(true);
|
||||
|
||||
snapshot = transition(snapshot, {
|
||||
type: 'native.available',
|
||||
version: null,
|
||||
downloadSize: null,
|
||||
downloadStarted: true,
|
||||
downloadUrl: null,
|
||||
downloadOptions: [],
|
||||
});
|
||||
expect(snapshot.context.updateInfo.native.downloaded).toBe(true);
|
||||
expect(snapshot.context.updateInfo.native.downloading).toBe(false);
|
||||
expect(snapshot.context.updateInfo.native.version).toBe('2.0.0');
|
||||
});
|
||||
|
||||
it('tracks check start and finish separately from available updates', () => {
|
||||
let snapshot = createUpdaterMachineSnapshot();
|
||||
snapshot = transition(snapshot, {type: 'check.started'});
|
||||
|
||||
@@ -166,6 +166,13 @@ export const updaterStateMachine = setup({
|
||||
}),
|
||||
applyNativeAvailable: assign(({context, event}) => {
|
||||
if (event.type !== 'native.available') return {};
|
||||
const currentNative = context.updateInfo.native;
|
||||
if (currentNative.downloaded && (event.version == null || event.version === currentNative.version)) {
|
||||
return {
|
||||
isChecking: false,
|
||||
nativeUnsupported: null,
|
||||
};
|
||||
}
|
||||
return {
|
||||
updateInfo: {
|
||||
...context.updateInfo,
|
||||
|
||||
Reference in new issue
Block a user