Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for updates every 30 minutes and at startup #66

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ autoUpdater.on("update-downloaded", (res) => {
`Update Downloaded. Downloaded file: ${res.downloadedFile}, Version: ${res.version}, `,
);
autoUpdater.quitAndInstall();
app.relaunch();
});
autoUpdater.on("update-not-available", () => {
Logging.instance().log("Update not available");
Expand Down
18 changes: 12 additions & 6 deletions electron/watchers/wakatime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class Wakatime {
private lastCategory: Category = "coding";
private tray?: Tray | null;
private versionString: string;
private lastCheckedForUpdates: number = 0;

constructor() {
const version = `${getPlatfrom()}-wakatime/${app.getVersion()}`;
Expand All @@ -40,17 +41,14 @@ export class Wakatime {
Logging.instance().activateLoggingToFile();
}

Logging.instance().log("Starting WakaTime");

if (PropertiesManager.autoUpdateEnabled && !isDev) {
Logging.instance().log("Auto Update Enabled");
autoUpdater.checkForUpdatesAndNotify();
}
Logging.instance().log(`Starting WakaTime v${app.getVersion()}`);

if (SettingsManager.shouldRegisterAsLogInItem()) {
SettingsManager.registerAsLogInItem();
}

this.checkForUpdates();

Dependencies.installDependencies();

AppsManager.instance()
Expand Down Expand Up @@ -194,6 +192,7 @@ export class Wakatime {
}

await this.fetchToday();
this.checkForUpdates();
}

public async fetchToday() {
Expand Down Expand Up @@ -244,6 +243,13 @@ export class Wakatime {
}
}

public async checkForUpdates() {
if (!PropertiesManager.autoUpdateEnabled || isDev) return;
if (this.lastCheckedForUpdates + 600 * 1000 > Date.now()) return;

autoUpdater.checkForUpdatesAndNotify();
}

pluginString(appData?: AppData, windowInfo?: WindowInfo) {
const appName = windowInfo?.info.name || appData?.name;
if (!appName) {
Expand Down
Loading