6446 improve information banner component to make it scale better (#6545)
Closes #6446
This commit is contained in:
@ -11,9 +11,9 @@ import {
|
||||
CalendarChannelWorkspaceEntity,
|
||||
} from 'src/modules/calendar/common/standard-objects/calendar-channel.workspace-entity';
|
||||
import {
|
||||
ConnectedAccountKeyValueType,
|
||||
ConnectedAccountKeys,
|
||||
} from 'src/modules/connected-account/types/connected-account-key-value.type';
|
||||
AccountsToReconnectKeyValueType,
|
||||
AccountsToReconnectKeys,
|
||||
} from 'src/modules/connected-account/types/accounts-to-reconnect-key-value.type';
|
||||
|
||||
@Injectable()
|
||||
export class CalendarChannelSyncStatusService {
|
||||
@ -21,7 +21,7 @@ export class CalendarChannelSyncStatusService {
|
||||
private readonly twentyORMManager: TwentyORMManager,
|
||||
@InjectCacheStorage(CacheStorageNamespace.Calendar)
|
||||
private readonly cacheStorage: CacheStorageService,
|
||||
private readonly userVarsService: UserVarsService<ConnectedAccountKeyValueType>,
|
||||
private readonly userVarsService: UserVarsService<AccountsToReconnectKeyValueType>,
|
||||
) {}
|
||||
|
||||
public async scheduleFullCalendarEventListFetch(calendarChannelId: string) {
|
||||
@ -198,7 +198,7 @@ export class CalendarChannelSyncStatusService {
|
||||
(await this.userVarsService.get({
|
||||
userId,
|
||||
workspaceId,
|
||||
key: ConnectedAccountKeys.ACCOUNTS_TO_RECONNECT,
|
||||
key: AccountsToReconnectKeys.ACCOUNTS_TO_RECONNECT_INSUFFICIENT_PERMISSIONS,
|
||||
})) ?? [];
|
||||
|
||||
if (accountsToReconnect.includes(connectedAccountId)) {
|
||||
@ -210,7 +210,7 @@ export class CalendarChannelSyncStatusService {
|
||||
await this.userVarsService.set({
|
||||
userId,
|
||||
workspaceId,
|
||||
key: ConnectedAccountKeys.ACCOUNTS_TO_RECONNECT,
|
||||
key: AccountsToReconnectKeys.ACCOUNTS_TO_RECONNECT_INSUFFICIENT_PERMISSIONS,
|
||||
value: accountsToReconnect,
|
||||
});
|
||||
}
|
||||
|
||||
@ -2,25 +2,41 @@ import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { UserVarsService } from 'src/engine/core-modules/user/user-vars/services/user-vars.service';
|
||||
import {
|
||||
ConnectedAccountKeys,
|
||||
ConnectedAccountKeyValueType,
|
||||
} from 'src/modules/connected-account/types/connected-account-key-value.type';
|
||||
AccountsToReconnectKeyValueType,
|
||||
AccountsToReconnectKeys,
|
||||
} from 'src/modules/connected-account/types/accounts-to-reconnect-key-value.type';
|
||||
|
||||
@Injectable()
|
||||
export class AccountsToReconnectService {
|
||||
constructor(
|
||||
private readonly userVarsService: UserVarsService<ConnectedAccountKeyValueType>,
|
||||
private readonly userVarsService: UserVarsService<AccountsToReconnectKeyValueType>,
|
||||
) {}
|
||||
|
||||
public async removeAccountToReconnect(
|
||||
userId: string,
|
||||
workspaceId: string,
|
||||
connectedAccountId: string,
|
||||
) {
|
||||
for (const key of Object.values(AccountsToReconnectKeys)) {
|
||||
await this.removeAccountToReconnectByKey(
|
||||
key,
|
||||
userId,
|
||||
workspaceId,
|
||||
connectedAccountId,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private async removeAccountToReconnectByKey(
|
||||
key: AccountsToReconnectKeys,
|
||||
userId: string,
|
||||
workspaceId: string,
|
||||
connectedAccountId: string,
|
||||
) {
|
||||
const accountsToReconnect = await this.userVarsService.get({
|
||||
userId,
|
||||
workspaceId,
|
||||
key: ConnectedAccountKeys.ACCOUNTS_TO_RECONNECT,
|
||||
key,
|
||||
});
|
||||
|
||||
if (!accountsToReconnect) {
|
||||
@ -35,7 +51,7 @@ export class AccountsToReconnectService {
|
||||
await this.userVarsService.delete({
|
||||
userId,
|
||||
workspaceId,
|
||||
key: ConnectedAccountKeys.ACCOUNTS_TO_RECONNECT,
|
||||
key,
|
||||
});
|
||||
|
||||
return;
|
||||
@ -44,7 +60,7 @@ export class AccountsToReconnectService {
|
||||
await this.userVarsService.set({
|
||||
userId,
|
||||
workspaceId,
|
||||
key: ConnectedAccountKeys.ACCOUNTS_TO_RECONNECT,
|
||||
key,
|
||||
value: updatedAccountsToReconnect,
|
||||
});
|
||||
}
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
export enum AccountsToReconnectKeys {
|
||||
ACCOUNTS_TO_RECONNECT_INSUFFICIENT_PERMISSIONS = 'ACCOUNTS_TO_RECONNECT_INSUFFICIENT_PERMISSIONS',
|
||||
ACCOUNTS_TO_RECONNECT_EMAIL_ALIASES = 'ACCOUNTS_TO_RECONNECT_EMAIL_ALIASES',
|
||||
}
|
||||
|
||||
export type AccountsToReconnectKeyValueType = {
|
||||
[AccountsToReconnectKeys.ACCOUNTS_TO_RECONNECT_INSUFFICIENT_PERMISSIONS]: string[];
|
||||
[AccountsToReconnectKeys.ACCOUNTS_TO_RECONNECT_EMAIL_ALIASES]: string[];
|
||||
};
|
||||
@ -1,7 +0,0 @@
|
||||
export enum ConnectedAccountKeys {
|
||||
ACCOUNTS_TO_RECONNECT = 'ACCOUNTS_TO_RECONNECT',
|
||||
}
|
||||
|
||||
export type ConnectedAccountKeyValueType = {
|
||||
[ConnectedAccountKeys.ACCOUNTS_TO_RECONNECT]: string[];
|
||||
};
|
||||
@ -7,9 +7,9 @@ import { CacheStorageNamespace } from 'src/engine/integrations/cache-storage/typ
|
||||
import { InjectObjectMetadataRepository } from 'src/engine/object-metadata-repository/object-metadata-repository.decorator';
|
||||
import { TwentyORMManager } from 'src/engine/twenty-orm/twenty-orm.manager';
|
||||
import {
|
||||
ConnectedAccountKeys,
|
||||
ConnectedAccountKeyValueType,
|
||||
} from 'src/modules/connected-account/types/connected-account-key-value.type';
|
||||
AccountsToReconnectKeyValueType,
|
||||
AccountsToReconnectKeys,
|
||||
} from 'src/modules/connected-account/types/accounts-to-reconnect-key-value.type';
|
||||
import { MessageChannelRepository } from 'src/modules/messaging/common/repositories/message-channel.repository';
|
||||
import {
|
||||
MessageChannelSyncStage,
|
||||
@ -24,7 +24,7 @@ export class MessagingChannelSyncStatusService {
|
||||
private readonly messageChannelRepository: MessageChannelRepository,
|
||||
@InjectCacheStorage(CacheStorageNamespace.Messaging)
|
||||
private readonly cacheStorage: CacheStorageService,
|
||||
private readonly userVarsService: UserVarsService<ConnectedAccountKeyValueType>,
|
||||
private readonly userVarsService: UserVarsService<AccountsToReconnectKeyValueType>,
|
||||
private readonly twentyORMManager: TwentyORMManager,
|
||||
) {}
|
||||
|
||||
@ -203,7 +203,7 @@ export class MessagingChannelSyncStatusService {
|
||||
(await this.userVarsService.get({
|
||||
userId,
|
||||
workspaceId,
|
||||
key: ConnectedAccountKeys.ACCOUNTS_TO_RECONNECT,
|
||||
key: AccountsToReconnectKeys.ACCOUNTS_TO_RECONNECT_INSUFFICIENT_PERMISSIONS,
|
||||
})) ?? [];
|
||||
|
||||
if (accountsToReconnect.includes(connectedAccountId)) {
|
||||
@ -215,7 +215,7 @@ export class MessagingChannelSyncStatusService {
|
||||
await this.userVarsService.set({
|
||||
userId,
|
||||
workspaceId,
|
||||
key: ConnectedAccountKeys.ACCOUNTS_TO_RECONNECT,
|
||||
key: AccountsToReconnectKeys.ACCOUNTS_TO_RECONNECT_INSUFFICIENT_PERMISSIONS,
|
||||
value: accountsToReconnect,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user