fix: use local nickname in chat input link previews (#13168)

This commit is contained in:
Igor Sirotin 2024-01-09 22:36:09 +00:00 committed by GitHub
parent 56f194c96c
commit 8144ccaf46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 3 deletions

View File

@ -3,6 +3,7 @@ import io_interface, tables, sets
import ../../../../../../app_service/service/settings/service as settings_service
import ../../../../../../app_service/service/message/service as message_service
import ../../../../../../app_service/service/contacts/service as contact_service
import ../../../../../../app_service/service/community/service as community_service
import ../../../../../../app_service/service/chat/service as chat_service
import ../../../../../../app_service/service/gif/service as gif_service
@ -22,6 +23,7 @@ type
chatId: string
belongsToCommunity: bool
communityService: community_service.Service
contactService: contact_service.Service
chatService: chat_service.Service
gifService: gif_service.Service
messageService: message_service.Service
@ -42,6 +44,7 @@ proc newController*(
belongsToCommunity: bool,
chatService: chat_service.Service,
communityService: community_service.Service,
contactService: contact_service.Service,
gifService: gif_service.Service,
messageService: message_service.Service,
settingsService: settings_service.Service
@ -54,6 +57,7 @@ proc newController*(
result.belongsToCommunity = belongsToCommunity
result.chatService = chatService
result.communityService = communityService
result.contactService = contactService
result.gifService = gifService
result.messageService = messageService
result.settingsService = settingsService
@ -306,3 +310,6 @@ proc setLinkPreviewEnabled*(self: Controller, enabled: bool) =
proc onUnfurlingModeChanged(self: Controller, value: UrlUnfurlingMode) =
self.linkPreviewPersistentSetting = value
self.reloadUnfurlingPlan()
proc getContactDetails*(self: Controller, contactId: string): ContactDetails =
return self.contactService.getContactDetails(contactId)

View File

@ -2,6 +2,7 @@ import NimQml, tables
import ../../../../../../app_service/service/gif/dto
import ../../../../../../app_service/service/message/dto/link_preview
import ../../../../../../app_service/service/contacts/dto/contact_details
type
AccessInterface* {.pure inheritable.} = ref object of RootObj
@ -134,3 +135,6 @@ method setLinkPreviewEnabledForThisMessage*(self: AccessInterface, enabled: bool
method setUrls*(self: AccessInterface, urls: seq[string]) {.base.} =
raise newException(ValueError, "No implementation available")
method getContactDetails*(self: AccessInterface, contactId: string): ContactDetails {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -10,6 +10,7 @@ import ../../../../../../app_service/service/message/service as message_service
import ../../../../../../app_service/service/message/dto/link_preview
import ../../../../../../app_service/service/chat/service as chat_service
import ../../../../../../app_service/service/community/service as community_service
import ../../../../../../app_service/service/contacts/service as contact_service
import ../../../../../../app_service/service/gif/service as gif_service
import ../../../../../../app_service/service/gif/dto
@ -31,6 +32,7 @@ proc newModule*(
belongsToCommunity: bool,
chatService: chat_service.Service,
communityService: community_service.Service,
contactService: contact_service.Service,
gifService: gif_service.Service,
messageService: message_service.Service,
settingsService: settings_service.Service
@ -40,7 +42,7 @@ proc newModule*(
result.delegate = delegate
result.view = view.newView(result)
result.viewVariant = newQVariant(result.view)
result.controller = controller.newController(result, events, sectionId, chatId, belongsToCommunity, chatService, communityService, gifService, messageService, settingsService)
result.controller = controller.newController(result, events, sectionId, chatId, belongsToCommunity, chatService, communityService, contactService, gifService, messageService, settingsService)
result.moduleLoaded = false
method delete*(self: Module) =
@ -192,3 +194,6 @@ method setLinkPreviewEnabledForThisMessage*(self: Module, value: bool) =
method setUrls*(self: Module, urls: seq[string]) =
self.view.setUrls(urls)
method getContactDetails*(self: Module, contactId: string): ContactDetails =
return self.controller.getContactDetails(contactId)

View File

@ -1,4 +1,4 @@
import NimQml
import NimQml, sets
import ./io_interface
import ./gif_column_model
import ./preserved_properties
@ -238,6 +238,11 @@ QtObject:
proc updateLinkPreviewsFromCache*(self: View, urls: seq[string]) =
let linkPreviews = self.delegate.linkPreviewsFromCache(urls)
self.linkPreviewModel.updateLinkPreviews(linkPreviews)
for contactId in self.linkPreviewModel.getContactIds().items:
let contact = self.delegate.getContactDetails(contactId)
if contact.dto.displayName != "":
self.linkPreviewModel.setContactInfo(contact)
proc setLinkPreviewUrls*(self: View, urls: seq[string]) =
self.linkPreviewModel.setUrls(urls)

View File

@ -59,7 +59,7 @@ proc newModule*(delegate: delegate_interface.AccessInterface, events: EventEmitt
result.moduleLoaded = false
result.inputAreaModule = input_area_module.newModule(result, events, sectionId, chatId, belongsToCommunity,
chatService, communityService, gifService, messageService, settingsService)
chatService, communityService, contactService, gifService, messageService, settingsService)
result.messagesModule = messages_module.newModule(result, events, sectionId, chatId, belongsToCommunity,
contactService, communityService, chatService, messageService, mailserversService, sharedUrlsService)
result.usersModule = users_module.newModule(events, sectionId, chatId, belongsToCommunity,