remove logic message model from view and replace it with view representation
This commit is contained in:
parent
1883a4bc1f
commit
175c3a57f4
|
@ -6,20 +6,14 @@ import ../signals/types
|
|||
import ../../status/utils
|
||||
|
||||
var sendMessage = proc (view: ChatsView, chatId: string, msg: string): string =
|
||||
echo "sending message!"
|
||||
var message = Message(
|
||||
fromAuthor: "myself",
|
||||
text: msg,
|
||||
timestamp: "0",
|
||||
isCurrentUser: true
|
||||
)
|
||||
# var message = newChatMessage()
|
||||
# message.userName = "myself"
|
||||
# message.message = msg
|
||||
# message.timestamp = "0"
|
||||
# message.isCurrentUser = true
|
||||
echo "sending public message!"
|
||||
let chatMessage = newChatMessage()
|
||||
chatMessage.userName = "myself"
|
||||
chatMessage.message = msg
|
||||
chatMessage.timestamp = "0" #TODO convert to date/time?
|
||||
chatMessage.isCurrentUser = true #TODO: Determine who originated the message
|
||||
|
||||
view.pushMessage(message)
|
||||
view.pushMessage(chatMessage)
|
||||
status_chat.sendChatMessage(chatId, msg)
|
||||
|
||||
type ChatController* = ref object of SignalSubscriber
|
||||
|
@ -59,4 +53,9 @@ proc load*(self: ChatController): seq[string] =
|
|||
method onSignal(self: ChatController, data: Signal) =
|
||||
var chatSignal = cast[ChatSignal](data)
|
||||
for message in chatSignal.messages:
|
||||
self.view.pushMessage(message)
|
||||
let chatMessage = newChatMessage()
|
||||
chatMessage.userName = message.alias
|
||||
chatMessage.message = message.text
|
||||
chatMessage.timestamp = message.timestamp #TODO convert to date/time?
|
||||
chatMessage.isCurrentUser = message.isCurrentUser #TODO: Determine who originated the message
|
||||
self.view.pushMessage(chatMessage)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import NimQml, messages, Tables
|
||||
import ../signals/types
|
||||
|
||||
type
|
||||
ChatMessageRoles {.pure.} = enum
|
||||
|
@ -51,13 +50,7 @@ QtObject:
|
|||
ChatMessageRoles.IsCurrentUser.int:"isCurrentUser"
|
||||
}.toTable
|
||||
|
||||
proc add*(self: ChatMessageList, message: Message) =
|
||||
let chatMessage = newChatMessage()
|
||||
chatMessage.userName = message.alias
|
||||
chatMessage.message = message.text
|
||||
chatMessage.timestamp = message.timestamp #TODO convert to date/time?
|
||||
chatMessage.isCurrentUser = message.isCurrentUser #TODO: Determine who originated the message
|
||||
|
||||
proc add*(self: ChatMessageList, message: ChatMessage) =
|
||||
self.beginInsertRows(newQModelIndex(), self.messages.len, self.messages.len)
|
||||
self.messages.add(chatMessage)
|
||||
self.messages.add(message)
|
||||
self.endInsertRows()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import NimQml
|
||||
import Tables
|
||||
import messages
|
||||
import messageList
|
||||
import ../signals/types
|
||||
# import core as chat
|
||||
|
@ -75,7 +76,7 @@ QtObject:
|
|||
self.setCallResult(message)
|
||||
echo "Received message: ", message
|
||||
|
||||
proc pushMessage*(self:ChatsView, message: Message) =
|
||||
proc pushMessage*(self:ChatsView, message: ChatMessage) =
|
||||
self.messageList.add(message)
|
||||
|
||||
proc getMessageList(self: ChatsView): QVariant {.slot.} =
|
||||
|
|
Loading…
Reference in New Issue