Load chat history when chat pane starts
This commit is contained in:
parent
541ef48bb7
commit
8103d80df2
|
|
@ -6,6 +6,15 @@ Item {
|
||||||
id: chatPane
|
id: chatPane
|
||||||
property bool sidebarVisible: true
|
property bool sidebarVisible: true
|
||||||
signal toggleSidebar()
|
signal toggleSidebar()
|
||||||
|
function loadChat() {
|
||||||
|
chatModel.reset()
|
||||||
|
if (ollie.activeSessionId && ollie.activeAgentId) {
|
||||||
|
var log = ollie.readLogForSession(ollie.activeSessionId, ollie.activeAgentId)
|
||||||
|
if (log) { chatModel.appendData(log); chatModel.trimFront(20) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: loadChat()
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
@ -254,15 +263,16 @@ Item {
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: ollie
|
target: ollie
|
||||||
function loadChat() {
|
function onSessionsChanged() { chatPane.loadChat() }
|
||||||
chatModel.reset()
|
function onActiveSessionIdChanged() { chatPane.loadChat() }
|
||||||
if (ollie.activeSessionId && ollie.activeAgentId) {
|
function onActiveAgentIdChanged() { chatPane.loadChat() }
|
||||||
var log = ollie.readLogForSession(ollie.activeSessionId, ollie.activeAgentId)
|
}
|
||||||
if (log) { chatModel.appendData(log); chatModel.trimFront(20) }
|
|
||||||
}
|
Timer {
|
||||||
}
|
interval: 0
|
||||||
function onActiveSessionIdChanged() { loadChat() }
|
repeat: false
|
||||||
function onActiveAgentIdChanged() { loadChat() }
|
running: true
|
||||||
|
onTriggered: chatPane.loadChat()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in New Issue