import { C } from 'deltachat-node' ; import { getLogger } from '../../shared/logger' ; import SplitOut from './splitout' ; import { MessageType } from '../../shared/shared-types' ; const log = getLogger ( 'main/deltachat/chat' ) ; export default class DCChat extends SplitOut { getChatMedia ( chatId , msgType1 , msgType2 ) { const mediaMessages = this . selectedAccountContext . getChatMedia ( chatId , msgType1 , msgType2 , null ) ; return mediaMessages . map ( this . controller . messageList . messageIdToJson . bind ( this . controller . messageList ) ) ; } getEncryptionInfo ( chatId ) { return this . selectedAccountContext . getChatEncrytionInfo ( chatId ) ; } getQrCode ( chatId = 0 ) { return this . selectedAccountContext . getSecurejoinQrCode ( chatId ) ; } getQrCodeSVG ( chatId = 0 ) { return { content : this . selectedAccountContext . getSecurejoinQrCode ( chatId ) , svg : this . selectedAccountContext . getSecurejoinQrCodeSVG ( chatId ) , } ; } leaveGroup ( chatId ) { log . debug ( `action - leaving chat ${ chatId }` ) ; this . selectedAccountContext . removeContactFromChat ( chatId , C . DC_CONTACT_ID_SELF ) ; } setName ( chatId , name ) { return this . selectedAccountContext . setChatName ( chatId , name ) ; } modifyGroup ( chatId , name , image , members ) { log . debug ( 'action - modify group' , { chatId , name , image , members } ) ; this . selectedAccountContext . setChatName ( chatId , name ) ; const chat = this . selectedAccountContext . getChat ( chatId ) ; if ( typeof image !== 'undefined' && chat . getProfileImage ( ) !== image ) { this . selectedAccountContext . setChatProfileImage ( chatId , image || '' ) ; } if ( members !== null ) { const previousMembers = [ ... this . selectedAccountContext . getChatContacts ( chatId ) , ] ; const remove = previousMembers . filter ( m => ! members . includes ( m ) ) ; const add = members . filter ( m => ! previousMembers . includes ( m ) ) ; remove . forEach ( id => this . selectedAccountContext . removeContactFromChat ( chatId , id ) ) ; add . forEach ( id => this . selectedAccountContext . addContactToChat ( chatId , id ) ) ; } return true ; } addContactToChat ( chatId , contactId ) { return this . selectedAccountContext . addContactToChat ( chatId , contactId ) ; } setProfileImage ( chatId , newImage ) { return this . selectedAccountContext . setChatProfileImage ( chatId , newImage ) ; } returns createGroupChat ( verified , name ) { return this . selectedAccountContext . createGroupChat ( name , verified ) ; } delete ( chatId ) { log . debug ( `action - deleting chat ${ chatId }` ) ; this . selectedAccountContext . deleteChat ( chatId ) ; this . controller . chatList . updateChatList ( ) ; this . controller . emit ( 'DESKTOP_CLEAR_NOTIFICATIONS_FOR_CHAT' , chatId ) ; } setVisibility ( chatId , visibility ) { log . debug ( `action - set chat ${ chatId } visibility ${ visibility }` ) ; this . selectedAccountContext . setChatVisibility ( chatId , visibility ) ; } setMuteDuration ( chatId , duration ) { log . debug ( `action - set chat ${ chatId } muteduration ${ duration }` ) ; return this . selectedAccountContext . setChatMuteDuration ( chatId , duration ) ; } getChatContacts ( chatId ) { return this . selectedAccountContext . getChatContacts ( chatId ) ; } param { number } chatId markNoticedChat ( chatId ) { this . selectedAccountContext . markNoticedChat ( chatId ) ; } getChatEphemeralTimer ( chatId ) { return this . selectedAccountContext . getChatEphemeralTimer ( chatId ) ; } setChatEphemeralTimer ( chatId , timer ) { return this . selectedAccountContext . setChatEphemeralTimer ( chatId , timer ) ; } async sendVideoChatInvitation ( chatId ) { return await this . selectedAccountContext . sendVideochatInvitation ( chatId ) ; } accept ( chatId ) { this . selectedAccountContext . acceptChat ( chatId ) ; this . controller . chatList . updateChatList ( ) ; } block ( chatId ) { this . selectedAccountContext . blockChat ( chatId ) ; this . controller . chatList . updateChatList ( ) ; } getNextMedia ( messageId , direction ) { return this . selectedAccountContext . _getNextMedia ( messageId , direction , 0 , 0 , 0 ) ; } }