Skip to content

Commit

Permalink
schedule for federated only
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisamir98 committed May 11, 2023
1 parent 5459a62 commit 943806c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/script/conversation/ConversationRepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/script/conversation/ConversationRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 943806c

Please sign in to comment.