Skip to content

Commit

Permalink
Add product model count to footer status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrho committed Oct 22, 2024
1 parent 3f7709c commit f72a055
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
2 changes: 1 addition & 1 deletion jccm/src/Frontend/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const Main = () => {

useEffect(() => {
const generateEvents = async () => {
await delay(1000);
await delay(1000); // Delay for 1 second
await eventBus.emit('user-session-check');
await eventBus.emit('local-inventory-refresh');
await eventBus.emit('device-facts-refresh');
Expand Down
53 changes: 30 additions & 23 deletions jccm/src/Services/AutoUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,40 @@ export const setupAutoUpdate = () => {
return false;
}
});
let isFirstUpdateCheck = true; // Track if it's the first call

ipcMain.handle('check-for-updates', (event) => {
console.log('Checking for updates...');

return new Promise((resolve, reject) => {
let isUpdateAvailable = false;

autoUpdater.once('update-available', () => {
console.log('Update available.');
isUpdateAvailable = true;
});

autoUpdater.once('update-not-available', () => {
console.log('No update available.');
isUpdateAvailable = false;
});

// Set a timeout to reject the promise if no updates are found quickly
const timeout = setTimeout(() => {
console.log('Update check will complete in 3 seconds. Please wait...');
autoUpdater.removeAllListeners('update-available');
autoUpdater.removeAllListeners('update-not-available');
console.log('Update check result:', isUpdateAvailable);
resolve(isUpdateAvailable);
}, 3000);

// Initiate the update check
autoUpdater.checkForUpdates();
const delay = isFirstUpdateCheck ? 10000 : 0; // 10-second delay for the first call only because of https://www.electronjs.org/docs/latest/api/auto-updater#windows
isFirstUpdateCheck = false; // Reset after first call

setTimeout(() => {
let isUpdateAvailable = false;

autoUpdater.once('update-available', () => {
console.log('Update available.');
isUpdateAvailable = true;
});

autoUpdater.once('update-not-available', () => {
console.log('No update available.');
isUpdateAvailable = false;
});

// Timeout to finalize the check if listeners do not resolve quickly
const timeout = setTimeout(() => {
console.log('Update check will complete in 3 seconds. Please wait...');
autoUpdater.removeAllListeners('update-available');
autoUpdater.removeAllListeners('update-not-available');
console.log('Update check result:', isUpdateAvailable);
resolve(isUpdateAvailable);
}, 3000);

// Initiate the update check
autoUpdater.checkForUpdates();
}, delay); // Apply the delay if it's the first call
});
});

Expand Down

0 comments on commit f72a055

Please sign in to comment.