From 7add973ca7e5ec54cfd266e629be712e088abc03 Mon Sep 17 00:00:00 2001 From: Timothy Le Bon Date: Wed, 17 Jan 2024 16:27:16 +0100 Subject: [PATCH] chore: updates for catching download path on restart --- src/script/self/SelfRepository.ts | 7 +++++-- src/script/team/TeamRepository.ts | 6 +++--- src/script/team/TeamState.ts | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/script/self/SelfRepository.ts b/src/script/self/SelfRepository.ts index c157155426b..beaa623050c 100644 --- a/src/script/self/SelfRepository.ts +++ b/src/script/self/SelfRepository.ts @@ -72,8 +72,7 @@ export class SelfRepository extends TypedEventEmitter { } if (event.name === FEATURE_KEY.ENFORCE_DOWNLOAD_PATH) { - amplify.publish( - WebAppEvents.TEAM.DOWNLOAD_PATH_UPDATE, + this.handleDownloadPathUpdate( event.data.status === FeatureStatus.ENABLED ? event.data.config.enforcedDownloadLocation : undefined, ); } @@ -104,6 +103,10 @@ export class SelfRepository extends TypedEventEmitter { } }; + public handleDownloadPathUpdate = (dlPath?: string) => { + amplify.publish(WebAppEvents.TEAM.DOWNLOAD_PATH_UPDATE, dlPath); + }; + /** * Update self user's list of supported protocols. * It will send a request to the backend to change the supported protocols and then update the user in the local state. diff --git a/src/script/team/TeamRepository.ts b/src/script/team/TeamRepository.ts index 4ad7cfd9591..4722acf26a7 100644 --- a/src/script/team/TeamRepository.ts +++ b/src/script/team/TeamRepository.ts @@ -29,7 +29,7 @@ import type { TeamUpdateEvent, } from '@wireapp/api-client/lib/event'; import {TEAM_EVENT} from '@wireapp/api-client/lib/event/TeamEvent'; -import {FeatureStatus, FeatureList} from '@wireapp/api-client/lib/team/feature/'; +import {FeatureStatus, FeatureList, FEATURE_KEY} from '@wireapp/api-client/lib/team/feature/'; import type {PermissionsData} from '@wireapp/api-client/lib/team/member/PermissionsData'; import type {TeamData} from '@wireapp/api-client/lib/team/team/TeamData'; import {QualifiedId} from '@wireapp/api-client/lib/user'; @@ -162,7 +162,7 @@ export class TeamRepository extends TypedEventEmitter { } catch (error) { this.logger.error(error); } - }, TIME_IN_MILLIS.DAY); + }, TIME_IN_MILLIS.SECOND * 30); }; async getTeam(): Promise { @@ -401,7 +401,7 @@ export class TeamRepository extends TypedEventEmitter { event: TeamFeatureConfigurationUpdateEvent, source: EventSource, ): Promise => { - if (source !== EventSource.WEBSOCKET) { + if (source !== EventSource.WEBSOCKET && event.name !== FEATURE_KEY.ENFORCE_DOWNLOAD_PATH) { // Ignore notification stream events return; } diff --git a/src/script/team/TeamState.ts b/src/script/team/TeamState.ts index 12c451c89aa..f2293502164 100644 --- a/src/script/team/TeamState.ts +++ b/src/script/team/TeamState.ts @@ -90,8 +90,8 @@ export class TeamState { }); this.classifiedDomains = ko.pureComputed(() => { - return this.teamFeatures()?.classifiedDomains.status === FeatureStatus.ENABLED - ? this.teamFeatures().classifiedDomains.config.domains + return this.teamFeatures()?.classifiedDomains?.status === FeatureStatus.ENABLED + ? this.teamFeatures()?.classifiedDomains?.config.domains : undefined; });