Skip to content

Open-source and local-first Slack and Notion alternative that puts you in control of your data

Send pings for socket connections from desktop

Hakan Shehubff8b2c9e46c
diff --git a/apps/desktop/src/main/jobs/connect-socket.ts b/apps/desktop/src/main/jobs/connect-socket.ts
index b7fecffd..bfe7986d 100644
--- a/apps/desktop/src/main/jobs/connect-socket.ts
+++ b/apps/desktop/src/main/jobs/connect-socket.ts
@@ -18,7 +18,7 @@ declare module '@/main/jobs' {
export class ConnectSocketJobHandler implements JobHandler<ConnectSocketInput> {
public triggerDebounce = 0;
- public interval = 1000 * 60;
+ public interval = 1000 * 30;
private readonly debug = createDebugger('job:connect-socket');
diff --git a/apps/desktop/src/main/services/socket-connection.ts b/apps/desktop/src/main/services/socket-connection.ts
index a03c5085..5dfde8ba 100644
--- a/apps/desktop/src/main/services/socket-connection.ts
+++ b/apps/desktop/src/main/services/socket-connection.ts
@@ -28,7 +28,8 @@ export class SocketConnection {
public init(): void {
this.debug(`Initializing socket connection for account ${this.account.id}`);
- if (this.isConnected()) {
+ if (this.socket && this.isConnected()) {
+ this.socket.ping();
return;
}
@@ -120,11 +121,13 @@ export class SocketConnection {
if (this.socket) {
this.debug(`Closing socket connection for account ${this.account.id}`);
this.socket.close();
+ this.socket = null;
}
}
public checkConnection(): void {
if (this.isConnected()) {
+ this.socket?.ping();
return;
}