Skip to content

Commit

Permalink
fix(account-state): Only swiths to disconnected if the account was pr…
Browse files Browse the repository at this point in the history
…eviously connected
  • Loading branch information
andris9 committed Oct 25, 2024
1 parent c25413f commit 4f56fe3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/email-client/gmail-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class GmailClient extends BaseClient {
clearTimeout(this.renewWatchTimer);
this.closed = true;

if (this.state !== 'disconnected') {
if (['init', 'connecting', 'syncing', 'connected'].includes(this.state)) {
this.state = 'disconnected';
await this.setStateVal();
await emitChangeEvent(this.logger, this.account, 'state', this.state);
Expand All @@ -328,7 +328,7 @@ class GmailClient extends BaseClient {
clearTimeout(this.renewWatchTimer);
this.closed = true;

if (this.state !== 'disconnected') {
if (['init', 'connecting', 'syncing', 'connected'].includes(this.state)) {
this.state = 'disconnected';
await this.setStateVal();
await emitChangeEvent(this.logger, this.account, 'state', this.state);
Expand Down
2 changes: 1 addition & 1 deletion lib/email-client/imap-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ class IMAPClient extends BaseClient {
await this.redis.hSetExists(this.getAccountKey(), 'connections', this.connections.size.toString());
imapClient?.log.info({ msg: 'Connection closed', type: 'imapClient', account: this.account, disabled: imapClient.disabled });

if (this.state !== 'disconnected') {
if (['init', 'connecting', 'syncing', 'connected'].includes(this.state)) {
this.state = 'disconnected';
await this.setStateVal();
await emitChangeEvent(this.logger, this.account, 'state', this.state);
Expand Down
4 changes: 2 additions & 2 deletions lib/email-client/outlook-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class OutlookClient extends BaseClient {
clearTimeout(this.renewWatchTimer);
this.closed = true;

if (this.state !== 'disconnected') {
if (['init', 'connecting', 'syncing', 'connected'].includes(this.state)) {
this.state = 'disconnected';
await this.setStateVal();
await emitChangeEvent(this.logger, this.account, 'state', this.state);
Expand All @@ -229,7 +229,7 @@ class OutlookClient extends BaseClient {
clearTimeout(this.renewWatchTimer);
this.closed = true;

if (this.state !== 'disconnected') {
if (['init', 'connecting', 'syncing', 'connected'].includes(this.state)) {
this.state = 'disconnected';
await this.setStateVal();
await emitChangeEvent(this.logger, this.account, 'state', this.state);
Expand Down

0 comments on commit 4f56fe3

Please sign in to comment.