fix(chat): only turn available channels into clickable tags
Closes #8895
This commit is contained in:
parent
342d79e21c
commit
979b035049
|
@ -6,6 +6,7 @@ import ../../../core/eventemitter
|
|||
import ../../../../app_service/service/activity_center/service as activity_center_service
|
||||
import ../../../../app_service/service/contacts/service as contacts_service
|
||||
import ../../../../app_service/service/message/service as message_service
|
||||
import ../../../../app_service/service/community/service as community_service
|
||||
import ../../../../app_service/service/eth/utils as eth_utils
|
||||
import ../../../../app_service/service/chat/service as chat_service
|
||||
|
||||
|
@ -17,6 +18,7 @@ type
|
|||
contactsService: contacts_service.Service
|
||||
messageService: message_service.Service
|
||||
chatService: chat_service.Service
|
||||
communityService: community_service.Service
|
||||
|
||||
proc newController*(
|
||||
delegate: io_interface.AccessInterface,
|
||||
|
@ -24,7 +26,8 @@ proc newController*(
|
|||
activityCenterService: activity_center_service.Service,
|
||||
contactsService: contacts_service.Service,
|
||||
messageService: message_service.Service,
|
||||
chatService: chat_service.Service
|
||||
chatService: chat_service.Service,
|
||||
communityService: community_service.Service,
|
||||
): Controller =
|
||||
result = Controller()
|
||||
result.delegate = delegate
|
||||
|
@ -33,6 +36,7 @@ proc newController*(
|
|||
result.contactsService = contactsService
|
||||
result.messageService = messageService
|
||||
result.chatService = chatService
|
||||
result.communityService = communityService
|
||||
|
||||
proc delete*(self: Controller) =
|
||||
discard
|
||||
|
@ -73,6 +77,9 @@ proc unreadActivityCenterNotificationsCount*(self: Controller): int =
|
|||
proc getContactDetails*(self: Controller, contactId: string): ContactDetails =
|
||||
return self.contactsService.getContactDetails(contactId)
|
||||
|
||||
proc getCommunityById*(self: Controller, communityId: string): CommunityDto =
|
||||
return self.communityService.getCommunityById(communityId)
|
||||
|
||||
proc getActivityCenterNotifications*(self: Controller): seq[ActivityCenterNotificationDto] =
|
||||
return self.activityCenterService.getActivityCenterNotifications()
|
||||
|
||||
|
@ -99,8 +106,8 @@ proc acceptActivityCenterNotifications*(self: Controller, notificationIds: seq[s
|
|||
proc dismissActivityCenterNotifications*(self: Controller, notificationIds: seq[string]): string =
|
||||
return self.activityCenterService.dismissActivityCenterNotifications(notificationIds)
|
||||
|
||||
proc getRenderedText*(self: Controller, parsedTextArray: seq[ParsedText]): string =
|
||||
return self.messageService.getRenderedText(parsedTextArray)
|
||||
proc getRenderedText*(self: Controller, parsedTextArray: seq[ParsedText], communityChats: seq[ChatDto]): string =
|
||||
return self.messageService.getRenderedText(parsedTextArray, communityChats)
|
||||
|
||||
proc switchTo*(self: Controller, sectionId, chatId, messageId: string) =
|
||||
let data = ActiveSectionChatArgs(sectionId: sectionId, chatId: chatId, messageId: messageId)
|
||||
|
|
|
@ -12,6 +12,7 @@ import ../../../../app_service/service/activity_center/service as activity_cente
|
|||
import ../../../../app_service/service/contacts/service as contacts_service
|
||||
import ../../../../app_service/service/message/service as message_service
|
||||
import ../../../../app_service/service/chat/service as chat_service
|
||||
import ../../../../app_service/service/community/service as community_service
|
||||
|
||||
import ../../../global/app_sections_config as conf
|
||||
|
||||
|
@ -31,7 +32,8 @@ proc newModule*(
|
|||
activityCenterService: activity_center_service.Service,
|
||||
contactsService: contacts_service.Service,
|
||||
messageService: message_service.Service,
|
||||
chatService: chat_service.Service
|
||||
chatService: chat_service.Service,
|
||||
communityService: community_service.Service
|
||||
): Module =
|
||||
result = Module()
|
||||
result.delegate = delegate
|
||||
|
@ -43,7 +45,8 @@ proc newModule*(
|
|||
activityCenterService,
|
||||
contactsService,
|
||||
messageService,
|
||||
chatService
|
||||
chatService,
|
||||
communityService
|
||||
)
|
||||
result.moduleLoaded = false
|
||||
|
||||
|
@ -70,6 +73,8 @@ method unreadActivityCenterNotificationsCount*(self: Module): int =
|
|||
|
||||
proc createMessageItemFromDto(self: Module, message: MessageDto, chatDetails: ChatDto): MessageItem =
|
||||
let contactDetails = self.controller.getContactDetails(message.`from`)
|
||||
let communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
|
||||
|
||||
return msg_item_qobj.newMessageItem(msg_item.initItem(
|
||||
message.id,
|
||||
chatDetails.communityId, # we don't received community id via `activityCenterNotifications` api call
|
||||
|
@ -81,7 +86,7 @@ proc createMessageItemFromDto(self: Module, message: MessageDto, chatDetails: Ch
|
|||
contactDetails.isCurrentUser,
|
||||
contactDetails.details.added,
|
||||
message.outgoingStatus,
|
||||
self.controller.getRenderedText(message.parsedText),
|
||||
self.controller.getRenderedText(message.parsedText, communityChats),
|
||||
message.text,
|
||||
message.image,
|
||||
message.containsContactMentions(),
|
||||
|
@ -103,7 +108,7 @@ proc createMessageItemFromDto(self: Module, message: MessageDto, chatDetails: Ch
|
|||
message.mentioned,
|
||||
message.quotedMessage.`from`,
|
||||
message.quotedMessage.text,
|
||||
self.controller.getRenderedText( message.quotedMessage.parsedText),
|
||||
self.controller.getRenderedText(message.quotedMessage.parsedText, communityChats),
|
||||
message.quotedMessage.contentType,
|
||||
message.quotedMessage.deleted,
|
||||
message.quotedMessage.discordMessage,
|
||||
|
|
|
@ -156,8 +156,8 @@ proc resultItemClicked*(self: Controller, itemId: string) =
|
|||
messageId: itemDetails.messageId)
|
||||
self.events.emit(SIGNAL_MAKE_SECTION_CHAT_ACTIVE, data)
|
||||
|
||||
proc getRenderedText*(self: Controller, parsedTextArray: seq[ParsedText]): string =
|
||||
return self.messageService.getRenderedText(parsedTextArray)
|
||||
proc getRenderedText*(self: Controller, parsedTextArray: seq[ParsedText], communityChats: seq[ChatDto]): string =
|
||||
return self.messageService.getRenderedText(parsedTextArray, communityChats)
|
||||
|
||||
proc getColorHash*(self: Controller, pubkey: string): ColorHashDto =
|
||||
procs_from_visual_identity_service.colorHashOf(pubkey)
|
||||
|
|
|
@ -236,7 +236,9 @@ method onSearchMessagesDone*(self: Module, messages: seq[MessageDto]) =
|
|||
if(m.`from` == singletonInstance.userProfile.getPubKey()):
|
||||
senderName = "You"
|
||||
|
||||
let renderedMessageText = self.controller.getRenderedText(m.parsedText)
|
||||
let communityChats = self.controller.getCommunityById(chatDto.communityId).chats
|
||||
|
||||
let renderedMessageText = self.controller.getRenderedText(m.parsedText, communityChats)
|
||||
let colorHash = self.controller.getColorHash(m.`from`)
|
||||
let colorId = self.controller.getColorId(m.`from`)
|
||||
|
||||
|
|
|
@ -189,6 +189,9 @@ proc getChatDetails*(self: Controller): ChatDto =
|
|||
proc getCommunityDetails*(self: Controller): CommunityDto =
|
||||
return self.communityService.getCommunityById(self.sectionId)
|
||||
|
||||
proc getCommunityById*(self: Controller, communityId: string): CommunityDto =
|
||||
return self.communityService.getCommunityById(communityId)
|
||||
|
||||
proc getOneToOneChatNameAndImage*(self: Controller): tuple[name: string, image: string, largeImage: string] =
|
||||
return self.chatService.getOneToOneChatNameAndImage(self.chatId)
|
||||
|
||||
|
@ -235,8 +238,8 @@ proc getContactDetails*(self: Controller, contactId: string): ContactDetails =
|
|||
proc getCurrentFleet*(self: Controller): string =
|
||||
return self.nodeConfigurationService.getFleetAsString()
|
||||
|
||||
proc getRenderedText*(self: Controller, parsedTextArray: seq[ParsedText]): string =
|
||||
return self.messageService.getRenderedText(parsedTextArray)
|
||||
proc getRenderedText*(self: Controller, parsedTextArray: seq[ParsedText], communityChats: seq[ChatDto]): string =
|
||||
return self.messageService.getRenderedText(parsedTextArray, communityChats)
|
||||
|
||||
proc getTransactionDetails*(self: Controller, message: MessageDto): (string,string) =
|
||||
return self.messageService.getTransactionDetails(message)
|
||||
|
|
|
@ -222,6 +222,9 @@ proc getChatDetails*(self: Controller): ChatDto =
|
|||
proc getCommunityDetails*(self: Controller): CommunityDto =
|
||||
return self.communityService.getCommunityById(self.sectionId)
|
||||
|
||||
proc getCommunityById*(self: Controller, communityId: string): CommunityDto =
|
||||
return self.communityService.getCommunityById(communityId)
|
||||
|
||||
proc getOneToOneChatNameAndImage*(self: Controller):
|
||||
tuple[name: string, image: string, largeImage: string] =
|
||||
return self.chatService.getOneToOneChatNameAndImage(self.chatId)
|
||||
|
@ -251,8 +254,8 @@ proc getContactDetails*(self: Controller, contactId: string): ContactDetails =
|
|||
proc getNumOfPinnedMessages*(self: Controller): int =
|
||||
return self.messageService.getNumOfPinnedMessages(self.chatId)
|
||||
|
||||
proc getRenderedText*(self: Controller, parsedTextArray: seq[ParsedText]): string =
|
||||
return self.messageService.getRenderedText(parsedTextArray)
|
||||
proc getRenderedText*(self: Controller, parsedTextArray: seq[ParsedText], communityChats: seq[ChatDto]): string =
|
||||
return self.messageService.getRenderedText(parsedTextArray, communityChats)
|
||||
|
||||
proc getMessageDetails*(self: Controller, messageId: string):
|
||||
tuple[message: MessageDto, reactions: seq[ReactionDto], error: string] =
|
||||
|
|
|
@ -201,8 +201,10 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se
|
|||
continue
|
||||
|
||||
let sender = self.controller.getContactDetails(message.`from`)
|
||||
let chatDetails = self.controller.getChatDetails()
|
||||
let communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
|
||||
|
||||
let renderedMessageText = self.controller.getRenderedText(message.parsedText)
|
||||
let renderedMessageText = self.controller.getRenderedText(message.parsedText, communityChats)
|
||||
var transactionContract = message.transactionParameters.contract
|
||||
var transactionValue = message.transactionParameters.value
|
||||
var isCurrentUser = sender.isCurrentUser
|
||||
|
@ -250,7 +252,7 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se
|
|||
message.mentioned,
|
||||
message.quotedMessage.`from`,
|
||||
message.quotedMessage.text,
|
||||
self.controller.getRenderedText(message.quotedMessage.parsedText),
|
||||
self.controller.getRenderedText(message.quotedMessage.parsedText, communityChats),
|
||||
message.quotedMessage.contentType,
|
||||
message.quotedMessage.deleted,
|
||||
message.quotedMessage.discordMessage,
|
||||
|
@ -301,8 +303,10 @@ method messagesAdded*(self: Module, messages: seq[MessageDto]) =
|
|||
|
||||
for message in messages:
|
||||
let sender = self.controller.getContactDetails(message.`from`)
|
||||
let chatDetails = self.controller.getChatDetails()
|
||||
let communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
|
||||
|
||||
let renderedMessageText = self.controller.getRenderedText(message.parsedText)
|
||||
let renderedMessageText = self.controller.getRenderedText(message.parsedText, communityChats)
|
||||
|
||||
var transactionContract = message.transactionParameters.contract
|
||||
var transactionValue = message.transactionParameters.value
|
||||
|
@ -361,12 +365,11 @@ method messagesAdded*(self: Module, messages: seq[MessageDto]) =
|
|||
message.mentioned,
|
||||
message.quotedMessage.`from`,
|
||||
message.quotedMessage.text,
|
||||
self.controller.getRenderedText(message.quotedMessage.parsedText),
|
||||
self.controller.getRenderedText(message.quotedMessage.parsedText, communityChats),
|
||||
message.quotedMessage.contentType,
|
||||
message.quotedMessage.deleted,
|
||||
message.quotedMessage.discordMessage,
|
||||
)
|
||||
|
||||
items.add(item)
|
||||
|
||||
self.view.model().insertItemsBasedOnClock(items)
|
||||
|
@ -502,7 +505,9 @@ method updateContactDetails*(self: Module, contactId: string) =
|
|||
if(item.messageContainsMentions):
|
||||
let (message, _, err) = self.controller.getMessageDetails(item.id)
|
||||
if(err.len == 0):
|
||||
item.messageText = self.controller.getRenderedText(message.parsedText)
|
||||
let chatDetails = self.controller.getChatDetails()
|
||||
let communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
|
||||
item.messageText = self.controller.getRenderedText(message.parsedText, communityChats)
|
||||
item.messageContainsMentions = message.containsContactMentions()
|
||||
|
||||
method deleteMessage*(self: Module, messageId: string) =
|
||||
|
@ -520,10 +525,12 @@ method onMessageEdited*(self: Module, message: MessageDto) =
|
|||
return
|
||||
|
||||
let mentionedUsersPks = itemBeforeChange.mentionedUsersPks
|
||||
let chatDetails = self.controller.getChatDetails()
|
||||
let communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
|
||||
|
||||
self.view.model().updateEditedMsg(
|
||||
message.id,
|
||||
self.controller.getRenderedText(message.parsedText),
|
||||
self.controller.getRenderedText(message.parsedText, communityChats),
|
||||
message.text,
|
||||
message.contentType,
|
||||
message.containsContactMentions(),
|
||||
|
@ -604,8 +611,10 @@ method getMessageById*(self: Module, messageId: string): message_item.Item =
|
|||
let (message, _, err) = self.controller.getMessageDetails(messageId)
|
||||
if(err.len == 0):
|
||||
let sender = self.controller.getContactDetails(message.`from`)
|
||||
let chatDetails = self.controller.getChatDetails()
|
||||
let communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
|
||||
|
||||
let renderedMessageText = self.controller.getRenderedText(message.parsedText)
|
||||
let renderedMessageText = self.controller.getRenderedText(message.parsedText, communityChats)
|
||||
var transactionContract = message.transactionParameters.contract
|
||||
var transactionValue = message.transactionParameters.value
|
||||
var isCurrentUser = sender.isCurrentUser
|
||||
|
@ -653,7 +662,7 @@ method getMessageById*(self: Module, messageId: string): message_item.Item =
|
|||
message.mentioned,
|
||||
message.quotedMessage.`from`,
|
||||
message.quotedMessage.text,
|
||||
self.controller.getRenderedText(message.quotedMessage.parsedText),
|
||||
self.controller.getRenderedText(message.quotedMessage.parsedText, communityChats),
|
||||
message.quotedMessage.contentType,
|
||||
message.quotedMessage.deleted,
|
||||
message.quotedMessage.discordMessage
|
||||
|
|
|
@ -155,6 +155,8 @@ proc buildPinnedMessageItem(self: Module, messageId: string, actionInitiatedBy:
|
|||
return false
|
||||
|
||||
let contactDetails = self.controller.getContactDetails(message.`from`)
|
||||
let chatDetails = self.controller.getChatDetails()
|
||||
let communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
|
||||
|
||||
var transactionContract = message.transactionParameters.contract
|
||||
var transactionValue = message.transactionParameters.value
|
||||
|
@ -174,7 +176,7 @@ proc buildPinnedMessageItem(self: Module, messageId: string, actionInitiatedBy:
|
|||
isCurrentUser,
|
||||
contactDetails.details.added,
|
||||
message.outgoingStatus,
|
||||
self.controller.getRenderedText(message.parsedText),
|
||||
self.controller.getRenderedText(message.parsedText, communityChats),
|
||||
message.text,
|
||||
message.image,
|
||||
message.containsContactMentions(),
|
||||
|
@ -203,7 +205,7 @@ proc buildPinnedMessageItem(self: Module, messageId: string, actionInitiatedBy:
|
|||
message.mentioned,
|
||||
message.quotedMessage.`from`,
|
||||
message.quotedMessage.text,
|
||||
self.controller.getRenderedText(message.quotedMessage.parsedText),
|
||||
self.controller.getRenderedText(message.quotedMessage.parsedText, communityChats),
|
||||
message.quotedMessage.contentType,
|
||||
message.quotedMessage.deleted,
|
||||
message.quotedMessage.discordMessage,
|
||||
|
@ -340,7 +342,9 @@ method onContactDetailsUpdated*(self: Module, contactId: string) =
|
|||
if(item.messageContainsMentions):
|
||||
let (message, _, err) = self.controller.getMessageDetails(item.id)
|
||||
if(err.len == 0):
|
||||
item.messageText = self.controller.getRenderedText(message.parsedText)
|
||||
let chatDetails = self.controller.getChatDetails()
|
||||
let communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
|
||||
item.messageText = self.controller.getRenderedText(message.parsedText, communityChats)
|
||||
item.messageContainsMentions = message.containsContactMentions()
|
||||
|
||||
if(self.controller.getMyChatId() == contactId):
|
||||
|
|
|
@ -253,6 +253,9 @@ proc isCommunity*(self: Controller): bool =
|
|||
proc getMyCommunity*(self: Controller): CommunityDto =
|
||||
return self.communityService.getCommunityById(self.sectionId)
|
||||
|
||||
proc getCommunityById*(self: Controller, communityId: string): CommunityDto =
|
||||
return self.communityService.getCommunityById(communityId)
|
||||
|
||||
proc getCategories*(self: Controller, communityId: string): seq[Category] =
|
||||
return self.communityService.getCategories(communityId)
|
||||
|
||||
|
@ -486,8 +489,8 @@ proc reorderCommunityCategories*(self: Controller, categoryId: string, position:
|
|||
proc reorderCommunityChat*(self: Controller, categoryId: string, chatId: string, position: int): string =
|
||||
self.communityService.reorderCommunityChat(self.sectionId, categoryId, chatId, position)
|
||||
|
||||
proc getRenderedText*(self: Controller, parsedTextArray: seq[ParsedText]): string =
|
||||
return self.messageService.getRenderedText(parsedTextArray)
|
||||
proc getRenderedText*(self: Controller, parsedTextArray: seq[ParsedText], communityChats: seq[ChatDto]): string =
|
||||
return self.messageService.getRenderedText(parsedTextArray, communityChats)
|
||||
|
||||
proc getColorHash*(self: Controller, pubkey: string): ColorHashDto =
|
||||
procs_from_visual_identity_service.colorHashOf(pubkey)
|
||||
|
|
|
@ -771,7 +771,8 @@ method onNewMessagesReceived*(self: Module, sectionIdMsgBelongsTo: string, chatI
|
|||
notificationType = notification_details.NotificationType.NewMessageWithGlobalMention
|
||||
|
||||
let contactDetails = self.controller.getContactDetails(message.`from`)
|
||||
let renderedMessageText = self.controller.getRenderedText(message.parsedText)
|
||||
let communityChats = self.controller.getCommunityById(chatDetails.communityId).chats
|
||||
let renderedMessageText = self.controller.getRenderedText(message.parsedText, communityChats)
|
||||
let plainText = singletonInstance.utils.plainText(renderedMessageText)
|
||||
var notificationTitle = contactDetails.defaultDisplayName
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ proc newModule*[T](
|
|||
)
|
||||
result.stickersModule = stickers_module.newModule(result, events, stickersService, settingsService, walletAccountService, networkService, tokenService)
|
||||
result.activityCenterModule = activity_center_module.newModule(result, events, activityCenterService, contactsService,
|
||||
messageService, chatService)
|
||||
messageService, chatService, communityService)
|
||||
result.communitiesModule = communities_module.newModule(result, events, communityService, contactsService)
|
||||
result.appSearchModule = app_search_module.newModule(result, events, contactsService, chatService, communityService,
|
||||
messageService)
|
||||
|
|
|
@ -680,7 +680,7 @@ QtObject:
|
|||
self.threadpool.start(arg)
|
||||
|
||||
# See render-inline in status-mobile/src/status_im/ui/screens/chat/message/message.cljs
|
||||
proc renderInline(self: Service, parsedText: ParsedText): string =
|
||||
proc renderInline(self: Service, parsedText: ParsedText, communityChats: seq[ChatDto]): string =
|
||||
let value = escape_html(parsedText.literal)
|
||||
.multiReplace(("\r\n", "<br/>"))
|
||||
.multiReplace(("\n", "<br/>"))
|
||||
|
@ -712,7 +712,11 @@ proc renderInline(self: Service, parsedText: ParsedText): string =
|
|||
let contactDto = self.contactService.getContactById(id)
|
||||
result = fmt("<a href=\"//{id}\" class=\"mention\">{contactDto.userDefaultDisplayName()}</a>")
|
||||
of PARSED_TEXT_CHILD_TYPE_STATUS_TAG:
|
||||
result = fmt("<a href=\"#{value}\" class=\"status-tag\">#{value}</a>")
|
||||
result = fmt("<span>#{value}</span>")
|
||||
for chat in communityChats:
|
||||
if chat.name == value:
|
||||
result = fmt("<a href=\"#{value}\" class=\"status-tag\">#{value}</a>")
|
||||
break
|
||||
of PARSED_TEXT_CHILD_TYPE_DEL:
|
||||
result = fmt("<del>{value}</del>")
|
||||
of PARSED_TEXT_CHILD_TYPE_LINK:
|
||||
|
@ -721,13 +725,13 @@ proc renderInline(self: Service, parsedText: ParsedText): string =
|
|||
result = fmt(" {value} ")
|
||||
|
||||
# See render-block in status-mobile/src/status_im/ui/screens/chat/message/message.cljs
|
||||
proc getRenderedText*(self: Service, parsedTextArray: seq[ParsedText]): string =
|
||||
proc getRenderedText*(self: Service, parsedTextArray: seq[ParsedText], communityChats: seq[ChatDto]): string =
|
||||
for parsedText in parsedTextArray:
|
||||
case parsedText.type:
|
||||
of PARSED_TEXT_TYPE_PARAGRAPH:
|
||||
result = result & "<p>"
|
||||
for child in parsedText.children:
|
||||
result = result & self.renderInline(child)
|
||||
result = result & self.renderInline(child, communityChats)
|
||||
result = result & "</p>"
|
||||
of PARSED_TEXT_TYPE_BLOCKQUOTE:
|
||||
result = result & "<blockquote>" & escape_html(parsedText.literal) & "</blockquote>"
|
||||
|
|
Loading…
Reference in New Issue