1818 */
1919
2020import { NotificationPreference , WebappProperties } from '@wireapp/api-client/src/user/data/' ;
21+ import type { QualifiedId } from '@wireapp/api-client/src/user/' ;
2122import { Availability } from '@wireapp/protocol-messaging' ;
2223import { amplify } from 'amplify' ;
2324import ko from 'knockout' ;
@@ -73,7 +74,7 @@ interface ContentViewModelState {
7374
7475interface NotificationContent {
7576 /** Notification options */
76- options : { data : { conversationId : string ; messageId : string ; messageType : string } } ;
77+ options : { data : { conversationId ?: QualifiedId ; messageId ? : string ; messageType : string } ; tag : string } ;
7778 /** Timeout for notification */
7879 timeout : number ;
7980 /** Notification title */
@@ -92,7 +93,7 @@ export class NotificationRepository {
9293 private contentViewModelState : ContentViewModelState ;
9394 private readonly conversationRepository : ConversationRepository ;
9495 private readonly logger : Logger ;
95- private readonly notifications : any [ ] ;
96+ private readonly notifications : Notification [ ] ;
9697 private readonly notificationsPreference : ko . Observable < NotificationPreference > ;
9798 private readonly permissionRepository : PermissionRepository ;
9899 private readonly permissionState : ko . Observable < PermissionState | PermissionStatusState | NotificationPermission > ;
@@ -270,7 +271,7 @@ export class NotificationRepository {
270271 * @param permissionState State of browser permission
271272 * @returns Resolves with `true` if notifications are enabled
272273 */
273- readonly updatePermissionState = ( permissionState : PermissionState | NotificationPermission ) : boolean => {
274+ readonly updatePermissionState = ( permissionState : PermissionState | NotificationPermission ) : boolean | undefined => {
274275 this . permissionState ( permissionState ) ;
275276 return this . checkPermissionState ( ) ;
276277 } ;
@@ -388,7 +389,7 @@ export class NotificationRepository {
388389 private createBodyMemberUpdate ( messageEntity ?: MemberMessage , conversationEntity ?: Conversation ) : string | void {
389390 const isGroup = conversationEntity && conversationEntity . isGroup ( ) ;
390391
391- switch ( messageEntity . memberMessageType ) {
392+ switch ( messageEntity ? .memberMessageType ) {
392393 case SystemMessageType . NORMAL :
393394 if ( isGroup ) {
394395 if ( messageEntity . isMemberJoin ( ) ) {
@@ -498,10 +499,10 @@ export class NotificationRepository {
498499 messageEntity : ContentMessage ,
499500 connectionEntity : ConnectionEntity ,
500501 conversationEntity : Conversation ,
501- ) : Promise < any > {
502+ ) : Promise < NotificationContent | undefined > {
502503 const body = this . createOptionsBody ( messageEntity , conversationEntity ) ;
503504 if ( ! body ) {
504- return Promise . resolve ( ) ;
505+ return Promise . resolve ( undefined ) ;
505506 }
506507 const shouldObfuscateSender = this . shouldObfuscateNotificationSender ( messageEntity ) ;
507508 return this . createOptionsIcon ( shouldObfuscateSender , messageEntity . user ( ) ) . then ( iconUrl => {
@@ -557,7 +558,7 @@ export class NotificationRepository {
557558 messageEntity : Message ,
558559 connectionEntity : ConnectionEntity ,
559560 conversationEntity : Conversation ,
560- ) : { conversationId : string ; messageId : string | undefined ; messageType : string } {
561+ ) : NotificationContent [ 'options' ] [ 'data' ] {
561562 const { id : messageId , type : messageType } = messageEntity ;
562563
563564 return {
@@ -597,7 +598,7 @@ export class NotificationRepository {
597598 * @param conversationEntity Conversation entity
598599 */
599600 private createOptionsTag ( connectionEntity ?: ConnectionEntity , conversationEntity ?: Conversation ) : string {
600- return this . getConversationId ( connectionEntity , conversationEntity ) ;
601+ return this . getConversationId ( connectionEntity , conversationEntity ) ?. id || '' ;
601602 }
602603
603604 /**
@@ -665,11 +666,15 @@ export class NotificationRepository {
665666 * @param conversationEntity Conversation entity
666667 * @returns ID of conversation
667668 */
668- private getConversationId ( connectionEntity ?: ConnectionEntity , conversationEntity ?: Conversation ) : string {
669+ private getConversationId (
670+ connectionEntity ?: ConnectionEntity ,
671+ conversationEntity ?: Conversation ,
672+ ) : QualifiedId | undefined {
669673 if ( connectionEntity ) {
670- return connectionEntity . conversationId ;
674+ // TODO(federation) add domain when connection is implemented on the backend
675+ return { domain : '' , id : connectionEntity . conversationId } ;
671676 }
672- return conversationEntity && conversationEntity . id ;
677+ return conversationEntity && { domain : conversationEntity . domain , id : conversationEntity . id } ;
673678 }
674679
675680 /**
0 commit comments