From 943806cda942c6839ec9f6ce0f8743c3f88e1a13 Mon Sep 17 00:00:00 2001 From: Amir Ghezelbash Date: Thu, 11 May 2023 13:43:40 +0330 Subject: [PATCH] schedule for federated only --- .../conversation/ConversationRepository.test.ts | 15 ++++++++++++++- src/script/conversation/ConversationRepository.ts | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/script/conversation/ConversationRepository.test.ts b/src/script/conversation/ConversationRepository.test.ts index 919aa6ca490..636e3291fb4 100644 --- a/src/script/conversation/ConversationRepository.test.ts +++ b/src/script/conversation/ConversationRepository.test.ts @@ -1419,7 +1419,20 @@ describe('ConversationRepository', () => { jest.useRealTimers(); }); - it('should call loadMissingConversations & refreshAllConversationsUnavailableParticipants every 3 hours', async () => { + it('should not call loadMissingConversations & refreshAllConversationsUnavailableParticipants for non federated envs', async () => { + const conversationRepo = await testFactory.exposeConversationActors(); + + spyOn(testFactory.conversation_repository!, 'loadMissingConversations').and.callThrough(); + spyOn(testFactory.conversation_repository!, 'refreshAllConversationsUnavailableParticipants').and.callThrough(); + + expect(conversationRepo.loadMissingConversations).not.toHaveBeenCalled(); + expect(conversationRepo.refreshAllConversationsUnavailableParticipants).not.toHaveBeenCalled(); + }); + + it('should call loadMissingConversations & refreshAllConversationsUnavailableParticipants every 3 hours for federated envs', async () => { + Object.defineProperty(container.resolve(Core).backendFeatures, 'isFederated', { + get: jest.fn(() => true), + }); const conversationRepo = await testFactory.exposeConversationActors(); spyOn(testFactory.conversation_repository!, 'loadMissingConversations').and.callThrough(); diff --git a/src/script/conversation/ConversationRepository.ts b/src/script/conversation/ConversationRepository.ts index a2278626dae..209d159a6c3 100644 --- a/src/script/conversation/ConversationRepository.ts +++ b/src/script/conversation/ConversationRepository.ts @@ -484,6 +484,9 @@ export class ConversationRepository { * @Note Federation only */ private readonly scheduleMissingUsersAndConversationsMetadataRefresh = () => { + if (!this.core.backendFeatures.isFederated) { + return; + } window.setInterval(async () => { try { await this.loadMissingConversations();