|
@@ -33,6 +33,8 @@ class ContactDetailViewModel {
|
|
}
|
|
}
|
|
|
|
|
|
let chatId: Int
|
|
let chatId: Int
|
|
|
|
+ var isSavedMessages: Bool
|
|
|
|
+ var isDeviceTalk: Bool
|
|
private let sharedChats: DcChatlist
|
|
private let sharedChats: DcChatlist
|
|
private var sections: [ProfileSections] = []
|
|
private var sections: [ProfileSections] = []
|
|
private var chatActions: [ChatAction] = []
|
|
private var chatActions: [ChatAction] = []
|
|
@@ -42,6 +44,8 @@ class ContactDetailViewModel {
|
|
self.context = dcContext
|
|
self.context = dcContext
|
|
self.contactId = contactId
|
|
self.contactId = contactId
|
|
self.chatId = dcContext.getChatIdByContactId(contactId: contactId)
|
|
self.chatId = dcContext.getChatIdByContactId(contactId: contactId)
|
|
|
|
+ self.isSavedMessages = false
|
|
|
|
+ self.isDeviceTalk = false
|
|
self.sharedChats = context.getChatlist(flags: 0, queryString: nil, queryId: contactId)
|
|
self.sharedChats = context.getChatlist(flags: 0, queryString: nil, queryId: contactId)
|
|
|
|
|
|
sections.append(.chatOptions)
|
|
sections.append(.chatOptions)
|
|
@@ -51,8 +55,25 @@ class ContactDetailViewModel {
|
|
sections.append(.chatActions)
|
|
sections.append(.chatActions)
|
|
|
|
|
|
if chatId != 0 {
|
|
if chatId != 0 {
|
|
- chatOptions = [.gallery, .documents, .ephemeralMessages, .muteChat, .startChat]
|
|
|
|
- chatActions = [.archiveChat, .showEncrInfo, .blockContact, .deleteChat]
|
|
|
|
|
|
+ let dcChat = dcContext.getChat(chatId: chatId)
|
|
|
|
+ isSavedMessages = dcChat.isSelfTalk
|
|
|
|
+ isDeviceTalk = dcChat.isDeviceTalk
|
|
|
|
+
|
|
|
|
+ chatOptions = [.gallery, .documents]
|
|
|
|
+ if !isDeviceTalk {
|
|
|
|
+ chatOptions.append(.ephemeralMessages)
|
|
|
|
+ }
|
|
|
|
+ chatOptions.append(.muteChat)
|
|
|
|
+ if !isDeviceTalk {
|
|
|
|
+ chatOptions.append(.startChat)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ chatActions = [.archiveChat]
|
|
|
|
+ if !isDeviceTalk && !isSavedMessages {
|
|
|
|
+ chatActions.append(.showEncrInfo)
|
|
|
|
+ chatActions.append(.blockContact)
|
|
|
|
+ }
|
|
|
|
+ chatActions.append(.deleteChat)
|
|
} else {
|
|
} else {
|
|
chatOptions = [.gallery, .documents, .startChat]
|
|
chatOptions = [.gallery, .documents, .startChat]
|
|
chatActions = [.showEncrInfo, .blockContact]
|
|
chatActions = [.showEncrInfo, .blockContact]
|