feat: Join chats on demand
This commit is contained in:
parent
ae7ee0b363
commit
79638f6214
|
@ -0,0 +1,15 @@
|
|||
import "../status/chat" as status_chat
|
||||
|
||||
proc join*(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)
|
||||
status_chat.chatMessages(chatId)
|
||||
|
||||
proc load*(): seq[string] =
|
||||
# TODO: retrieve chats from DB
|
||||
join("test")
|
||||
result = @["test"]
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import NimQml
|
||||
import Tables
|
||||
import chat/core as chat
|
||||
|
||||
type
|
||||
RoleNames {.pure.} = enum
|
||||
|
@ -18,11 +19,15 @@ QtObject:
|
|||
|
||||
proc newChatsModel*(): ChatsModel =
|
||||
new(result, delete)
|
||||
result.names = @["test", "test2"]
|
||||
result.names = @[]
|
||||
result.setup
|
||||
|
||||
proc addNameTolist*(self: ChatsModel, name: string) =
|
||||
self.names.add(name)
|
||||
proc addNameTolist*(self: ChatsModel, chatId: string) {.slot.} =
|
||||
chat.join(chatId)
|
||||
self.beginInsertRows(newQModelIndex(), self.names.len, self.names.len)
|
||||
self.names.add(chatId)
|
||||
self.endInsertRows()
|
||||
|
||||
|
||||
method rowCount(self: ChatsModel, index: QModelIndex = nil): int =
|
||||
return self.names.len
|
||||
|
|
|
@ -28,7 +28,6 @@ proc mainProc() =
|
|||
echo status.callPrivateRPC("{\"jsonrpc\":\"2.0\", \"method\":\"wakuext_requestMessages\", \"params\":[{\"topics\": [\"0x7998f3c8\"]}], \"id\": 1}")
|
||||
|
||||
# result.accountResult = status.queryAccounts()
|
||||
status_test.subscribeToTest()
|
||||
|
||||
let logic = newApplicationView(app, status.callPrivateRPC)
|
||||
defer: logic.delete
|
||||
|
@ -49,11 +48,13 @@ proc mainProc() =
|
|||
chatsModel.addNameTolist(channel.name)
|
||||
)
|
||||
|
||||
status.startMessenger()
|
||||
appState.addChannel("test")
|
||||
appState.addChannel("test2")
|
||||
|
||||
engine.setRootContextProperty("logic", logicVariant)
|
||||
engine.setRootContextProperty("chatsModel", chatsVariant)
|
||||
|
||||
engine.load("../ui/main.qml")
|
||||
|
||||
# Qt main event loop is entered here
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import libstatus
|
||||
import signals
|
||||
import types
|
||||
import chat
|
||||
|
||||
proc setSignalHandler(signalHandler: SignalCallback) =
|
||||
libstatus.setSignalEventCallback(signalHandler)
|
||||
|
@ -8,6 +9,9 @@ proc setSignalHandler(signalHandler: SignalCallback) =
|
|||
proc init*() =
|
||||
setSignalHandler(onSignal)
|
||||
|
||||
proc startMessenger*() =
|
||||
chat.startMessenger()
|
||||
|
||||
proc callRPC*(inputJSON: string): string =
|
||||
return $libstatus.callRPC(inputJSON)
|
||||
|
||||
|
|
|
@ -14,6 +14,6 @@ var onSignal*: SignalCallback = proc(p0: cstring): void =
|
|||
of "messages.new":
|
||||
echo $p0
|
||||
else:
|
||||
echo messageType #TODO: do something
|
||||
discard messageType #TODO: do something
|
||||
|
||||
tearDownForeignThreadGc()
|
||||
|
|
|
@ -29,12 +29,6 @@ proc queryAccounts*(): string =
|
|||
echo response
|
||||
result = parseJson(response)["result"][0].getStr()
|
||||
|
||||
|
||||
proc subscribeToTest*() =
|
||||
loadFilters("test")
|
||||
saveChat("test")
|
||||
chatMessages("test")
|
||||
|
||||
proc setupNewAccount*() =
|
||||
# Deleting directories
|
||||
recreateDir(datadir)
|
||||
|
|
|
@ -108,6 +108,13 @@ SplitView {
|
|||
font.bold: true
|
||||
font.pixelSize: 28
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked : {
|
||||
chatsModel.addNameTolist(searchText.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue