parent
97cd5043eb
commit
33011385af
|
@ -2,10 +2,11 @@ import NimQml
|
|||
import ../../status/chat as status_chat
|
||||
import view
|
||||
import ../signals/types
|
||||
import ../../status/utils
|
||||
|
||||
var sendMessage = proc (msg: string): string =
|
||||
echo "sending public message"
|
||||
status_chat.sendPublicChatMessage("test", msg)
|
||||
var sendMessage = proc (chatId: string, msg: string): string =
|
||||
echo "sending message"
|
||||
status_chat.sendChatMessage(chatId, msg)
|
||||
|
||||
type ChatController* = ref object of SignalSubscriber
|
||||
view*: ChatsView
|
||||
|
@ -28,8 +29,10 @@ proc join*(self: ChatController, chatId: string) =
|
|||
# TODO: check whether we have joined a chat already or not
|
||||
# TODO: save chat list in the db
|
||||
echo "Joining chat: ", chatId
|
||||
status_chat.loadFilters(chatId)
|
||||
status_chat.saveChat(chatId)
|
||||
let oneToOne = isOneToOneChat(chatId)
|
||||
echo "Is one to one? ", oneToOne
|
||||
status_chat.loadFilters(chatId, oneToOne)
|
||||
status_chat.saveChat(chatId, oneToOne)
|
||||
status_chat.chatMessages(chatId)
|
||||
# self.chatsModel.addNameTolist(channel.name)
|
||||
self.view.addNameTolist(chatId)
|
||||
|
|
|
@ -14,7 +14,7 @@ QtObject:
|
|||
names*: seq[string]
|
||||
callResult: string
|
||||
messageList: ChatMessageList
|
||||
sendMessage: proc (msg: string): string
|
||||
sendMessage: proc (chatId: string, msg: string): string
|
||||
|
||||
proc delete(self: ChatsView) =
|
||||
self.QAbstractListModel.delete
|
||||
|
@ -67,7 +67,8 @@ QtObject:
|
|||
notify = callResultChanged
|
||||
|
||||
proc onSend*(self: ChatsView, inputJSON: string) {.slot.} =
|
||||
self.setCallResult(self.sendMessage(inputJSON))
|
||||
# TODO unhardcode chatId
|
||||
self.setCallResult(self.sendMessage("test", inputJSON))
|
||||
echo "Done!: ", self.callResult
|
||||
|
||||
proc onMessage*(self: ChatsView, message: string) {.slot.} =
|
||||
|
|
|
@ -12,7 +12,7 @@ proc startMessenger*() =
|
|||
discard $libstatus.callPrivateRPC($payload)
|
||||
# TODO: create template for error handling
|
||||
|
||||
proc loadFilters*(chatId: string) =
|
||||
proc loadFilters*(chatId: string, oneToOne = false) =
|
||||
let payload = %* {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 3, #TODO:
|
||||
|
@ -20,13 +20,13 @@ proc loadFilters*(chatId: string) =
|
|||
"params": [
|
||||
[{
|
||||
"ChatID": chatId,
|
||||
"OneToOne": false
|
||||
"OneToOne": oneToOne
|
||||
}]
|
||||
]
|
||||
}
|
||||
discard $libstatus.callPrivateRPC($payload)
|
||||
|
||||
proc saveChat*(chatId: string) =
|
||||
proc saveChat*(chatId: string, oneToOne = false) =
|
||||
let payload = %* {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 4,
|
||||
|
@ -40,7 +40,7 @@ proc saveChat*(chatId: string) =
|
|||
"active": true,
|
||||
"id": chatId,
|
||||
"unviewedMessagesCount": 0,
|
||||
"chatType": 2,
|
||||
"chatType": if oneToOne: 1 else: 2,
|
||||
"timestamp": 1588940692659
|
||||
}
|
||||
]
|
||||
|
@ -59,7 +59,8 @@ proc chatMessages*(chatId: string) =
|
|||
discard $libstatus.callPrivateRPC($payload)
|
||||
# TODO: create template for error handling
|
||||
|
||||
proc sendPublicChatMessage*(chatId: string, msg: string): string =
|
||||
|
||||
proc sendChatMessage*(chatId: string, msg: string): string =
|
||||
let payload = %* {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 40,
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
import strutils
|
||||
|
||||
proc isWakuEnabled(): bool =
|
||||
true # TODO:
|
||||
|
||||
proc prefix*(methodName: string): string =
|
||||
result = if isWakuEnabled(): "wakuext_" else: "shhext_"
|
||||
result = result & methodName
|
||||
result = result & methodName
|
||||
|
||||
proc isOneToOneChat*(chatId: string): bool =
|
||||
result = chatId.startsWith("0x") # There is probably a better way to do this
|
Loading…
Reference in New Issue