mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Start distant chat using helper on ChatCache
This commit is contained in:
parent
f77fe533e7
commit
c27db173ce
@ -136,4 +136,35 @@ QtObject
|
||||
|
||||
}
|
||||
|
||||
property QtObject chatHelper: QtObject
|
||||
{
|
||||
id: chatHelper
|
||||
property var gxs_id
|
||||
property var name
|
||||
property var cb
|
||||
|
||||
function startDistantChat (own_gxs_id, gxs_id, name, cb)
|
||||
{
|
||||
console.log("startDistantChat()")
|
||||
chatHelper.gxs_id = gxs_id
|
||||
chatHelper.name = name
|
||||
chatHelper.cb = cb
|
||||
var jsonData = { "own_gxs_hex": own_gxs_id,
|
||||
"remote_gxs_hex": gxs_id }
|
||||
rsApi.request("/chat/initiate_distant_chat",
|
||||
JSON.stringify(jsonData),
|
||||
startDistantChatCB)
|
||||
|
||||
}
|
||||
|
||||
function startDistantChatCB (par)
|
||||
{
|
||||
var chatId = JSON.parse(par.response).data.chat_id
|
||||
lastMessageCache.setRemoteGXS(chatId, { gxs: gxs_id, name: name})
|
||||
cb(chatId)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -132,13 +132,6 @@ Item
|
||||
rsApi.request("/chat/unread_msgs", "", refreshUnreadCallback)
|
||||
}
|
||||
|
||||
function startChatCallback(par)
|
||||
{
|
||||
var chId = JSON.parse(par.response).data.chat_id
|
||||
stackView.push("qrc:/ChatView.qml", {'chatId': chId})
|
||||
}
|
||||
|
||||
|
||||
/** This must be equivalent to
|
||||
p3GxsTunnelService::makeGxsTunnelId(...) */
|
||||
function getChatId(from_gxs, to_gxs)
|
||||
|
@ -53,11 +53,7 @@ Item
|
||||
if(model.own) contactsView.own_gxs_id = model.gxs_id
|
||||
else
|
||||
{
|
||||
var jsonData = { "own_gxs_hex": contactsView.own_gxs_id,
|
||||
"remote_gxs_hex": model.gxs_id }
|
||||
rsApi.request("/chat/initiate_distant_chat",
|
||||
JSON.stringify(jsonData),
|
||||
startDistantChatCB)
|
||||
startDistantChat()
|
||||
}
|
||||
}
|
||||
|
||||
@ -278,11 +274,14 @@ Item
|
||||
"qrc:/ContactDetails.qml",
|
||||
{md: contactsListView.model.get(index)})
|
||||
}
|
||||
function startDistantChatCB (par)
|
||||
|
||||
function startDistantChat ()
|
||||
{
|
||||
var chId = JSON.parse(par.response).data.chat_id
|
||||
ChatCache.lastMessageCache.setRemoteGXS(chId, { gxs: model.gxs_id, name: model.name})
|
||||
contactsView.startChatCallback (par)
|
||||
ChatCache.chatHelper.startDistantChat(contactsView.own_gxs_id, model.gxs_id, model.name,
|
||||
function (chatId)
|
||||
{
|
||||
stackView.push("qrc:/ChatView.qml", {'chatId': chatId})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user