refactor(chat-communities): chat naming follows alias/ens naming
This commit is contained in:
parent
813f6d0062
commit
9e60b4ecfe
|
@ -138,7 +138,7 @@ proc newAppController*(appService: AppService): AppController =
|
|||
result.settingsService = settings_service.newService()
|
||||
result.accountsService = accounts_service.newService()
|
||||
result.contactsService = contacts_service.newService(appService.status.events, appService.threadpool)
|
||||
result.chatService = chat_service.newService()
|
||||
result.chatService = chat_service.newService(result.contactsService)
|
||||
result.communityService = community_service.newService(result.chatService)
|
||||
result.messageService = message_service.newService(appService.status.events, appService.threadpool)
|
||||
result.tokenService = token_service.newService(appService.status.events, appService.threadpool, result.settingService,
|
||||
|
|
|
@ -74,4 +74,7 @@ method setActiveItemSubItem*(self: Controller, itemId: string, subItemId: string
|
|||
|
||||
# We need to take other actions here like notify status go that unviewed mentions count is updated and so...
|
||||
|
||||
self.delegate.activeItemSubItemSet(self.activeItemId, self.activeSubItemId)
|
||||
self.delegate.activeItemSubItemSet(self.activeItemId, self.activeSubItemId)
|
||||
|
||||
method getPrettyChatName*(self: Controller, chatId: string): string =
|
||||
return self.chatService.prettyChatName(chatId)
|
|
@ -36,4 +36,7 @@ method getChatDetailsForChatTypes*(self: AccessInterface, types: seq[ChatType]):
|
|||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method setActiveItemSubItem*(self: AccessInterface, itemId: string, subItemId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getPrettyChatName*(self: AccessInterface, chatId: string): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
|
@ -63,8 +63,11 @@ proc buildChatUI(self: Module, events: EventEmitter, chatService: chat_service.S
|
|||
for c in chats:
|
||||
let hasNotification = c.unviewedMessagesCount > 0 or c.unviewedMentionsCount > 0
|
||||
let notificationsCount = c.unviewedMentionsCount
|
||||
let item = initItem(c.id, if c.alias.len > 0: c.alias else: c.name, c.identicon, c.color, c.description,
|
||||
c.chatType.int, hasNotification, notificationsCount, c.muted, false)
|
||||
var chatName = c.name
|
||||
if(c.chatType == ChatType.OneToOne):
|
||||
chatName = self.controller.getPrettyChatName(c.id)
|
||||
let item = initItem(c.id, chatName, c.identicon, c.color, c.description, c.chatType.int, hasNotification,
|
||||
notificationsCount, c.muted, false)
|
||||
self.view.appendItem(item)
|
||||
self.addSubmodule(c.id, false, events, chatService, communityService, messageService)
|
||||
|
||||
|
@ -87,9 +90,8 @@ proc buildCommunityUI(self: Module, events: EventEmitter, chatService: chat_serv
|
|||
|
||||
let hasNotification = chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0
|
||||
let notificationsCount = chatDto.unviewedMentionsCount
|
||||
let channelItem = initItem(chatDto.id, if chatDto.alias.len > 0: chatDto.alias else: chatDto.name,
|
||||
chatDto.identicon, chatDto.color, chatDto.description, chatDto.chatType.int, hasNotification, notificationsCount,
|
||||
chatDto.muted, false)
|
||||
let channelItem = initItem(chatDto.id, chatDto.name, chatDto.identicon, chatDto.color, chatDto.description,
|
||||
chatDto.chatType.int, hasNotification, notificationsCount, chatDto.muted, false)
|
||||
self.view.appendItem(channelItem)
|
||||
self.addSubmodule(chatDto.id, true, events, chatService, communityService, messageService)
|
||||
|
||||
|
@ -114,9 +116,8 @@ proc buildCommunityUI(self: Module, events: EventEmitter, chatService: chat_serv
|
|||
hasNotificationPerCategory = hasNotificationPerCategory or hasNotification
|
||||
notificationsCountPerCategory += notificationsCount
|
||||
|
||||
let channelItem = initSubItem(chatDto.id, if chatDto.alias.len > 0: chatDto.alias else: chatDto.name,
|
||||
chatDto.identicon, chatDto.color, chatDto.description, hasNotification, notificationsCount, chatDto.muted,
|
||||
false)
|
||||
let channelItem = initSubItem(chatDto.id, chatDto.name, chatDto.identicon, chatDto.color, chatDto.description,
|
||||
hasNotification, notificationsCount, chatDto.muted, false)
|
||||
categoryChannels.add(channelItem)
|
||||
self.addSubmodule(chatDto.id, true, events, chatService, communityService, messageService)
|
||||
|
||||
|
|
|
@ -23,4 +23,4 @@ proc first*(jArray: JsonNode, fieldName, id: string): JsonNode =
|
|||
|
||||
proc prettyEnsName*(ensName: string): string =
|
||||
if ensName.endsWith(".eth"):
|
||||
return "@" & ensName.split(".")[0]
|
||||
return "@" & ensName.split(".")[0]
|
|
@ -1,6 +1,7 @@
|
|||
import Tables, json, sequtils, strformat, chronicles
|
||||
|
||||
import service_interface, ./dto/chat
|
||||
import ../contacts/service as contact_service
|
||||
import status/statusgo_backend_new/chat as status_go
|
||||
|
||||
export service_interface
|
||||
|
@ -9,14 +10,16 @@ logScope:
|
|||
topics = "chat-service"
|
||||
|
||||
type
|
||||
Service* = ref object of ServiceInterface
|
||||
Service* = ref object of service_interface.ServiceInterface
|
||||
chats: Table[string, ChatDto] # [chat_id, ChatDto]
|
||||
contactService: contact_service.Service
|
||||
|
||||
method delete*(self: Service) =
|
||||
discard
|
||||
|
||||
proc newService*(): Service =
|
||||
proc newService*(contactService: contact_service.Service): Service =
|
||||
result = Service()
|
||||
result.contactService = contactService
|
||||
result.chats = initTable[string, ChatDto]()
|
||||
|
||||
method init*(self: Service) =
|
||||
|
@ -45,4 +48,11 @@ method getChatById*(self: Service, chatId: string): ChatDto =
|
|||
error "trying to get chat data for an unexisting chat id"
|
||||
return
|
||||
|
||||
return self.chats[chatId]
|
||||
return self.chats[chatId]
|
||||
|
||||
method prettyChatName*(self: Service, chatId: string): string =
|
||||
let contact = self.contactService.getContactById(chatId)
|
||||
if(contact.isNil):
|
||||
return
|
||||
|
||||
return contact.userNameOrAlias()
|
|
@ -19,4 +19,7 @@ method getChatsOfChatTypes*(self: ServiceInterface, types: seq[ChatType]): seq[C
|
|||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getChatById*(self: ServiceInterface, chatId: string): ChatDto {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method prettyChatName*(self: ServiceInterface, chatId: string): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
Loading…
Reference in New Issue