mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 07:59:35 -05:00
qml-app: Fix responsiveness of ChatView
ChatHandler::handleMessages(...) tick() before repling so the raw message queue is processed ChatHandler::handleLobbies(...) make sure tick() is called without previous mutex locking, putting the critical section inside a block ChatView.qml remove unnecessary request to statetoken service that slowed down processing by half, increased chat message refresh time to reduce performance hit
This commit is contained in:
parent
1fa20e16c2
commit
6c6b437db1
@ -837,6 +837,7 @@ void ChatHandler::handleLobbies(Request &/*req*/, Response &resp)
|
|||||||
{
|
{
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
|
{
|
||||||
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/
|
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/
|
||||||
resp.mDataStream.getStreamToMember();
|
resp.mDataStream.getStreamToMember();
|
||||||
for(std::vector<Lobby>::iterator vit = mLobbies.begin(); vit != mLobbies.end(); ++vit)
|
for(std::vector<Lobby>::iterator vit = mLobbies.begin(); vit != mLobbies.end(); ++vit)
|
||||||
@ -854,6 +855,7 @@ void ChatHandler::handleLobbies(Request &/*req*/, Response &resp)
|
|||||||
resp.mDataStream.getStreamToMember() << *vit << makeKeyValueReference("unread_msg_count", unread_msgs);
|
resp.mDataStream.getStreamToMember() << *vit << makeKeyValueReference("unread_msg_count", unread_msgs);
|
||||||
}
|
}
|
||||||
resp.mStateToken = mLobbiesStateToken;
|
resp.mStateToken = mLobbiesStateToken;
|
||||||
|
}
|
||||||
resp.setOk();
|
resp.setOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -921,6 +923,12 @@ ResponseTask* ChatHandler::handleLobbyParticipants(Request &req, Response &resp)
|
|||||||
|
|
||||||
void ChatHandler::handleMessages(Request &req, Response &resp)
|
void ChatHandler::handleMessages(Request &req, Response &resp)
|
||||||
{
|
{
|
||||||
|
/* G10h4ck: Whithout this the request processing won't happen, copied from
|
||||||
|
* ChatHandler::handleLobbies, is this a work around or is the right whay of
|
||||||
|
* doing it? */
|
||||||
|
tick();
|
||||||
|
|
||||||
|
{
|
||||||
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/
|
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/
|
||||||
ChatId id(req.mPath.top());
|
ChatId id(req.mPath.top());
|
||||||
// make response a list
|
// make response a list
|
||||||
@ -941,6 +949,7 @@ void ChatHandler::handleMessages(Request &req, Response &resp)
|
|||||||
}
|
}
|
||||||
resp.mStateToken = mMsgStateToken;
|
resp.mStateToken = mMsgStateToken;
|
||||||
handlePaginationRequest(req, resp, mit->second);
|
handlePaginationRequest(req, resp, mit->second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatHandler::handleSendMessage(Request &req, Response &resp)
|
void ChatHandler::handleSendMessage(Request &req, Response &resp)
|
||||||
|
@ -7,11 +7,7 @@ Item
|
|||||||
id: chatView
|
id: chatView
|
||||||
property string chatId
|
property string chatId
|
||||||
|
|
||||||
function refreshData()
|
function refreshData() { rsApi.request("/chat/messages/"+ chatId, "", function(par) { chatModel.json = par.response }) }
|
||||||
{
|
|
||||||
rsApi.request("/statetokenservice/*")
|
|
||||||
rsApi.request("/chat/messages/"+ chatId, "", function(par) { console.log("Callback called! -> " + par.response ); chatModel.json = par.response })
|
|
||||||
}
|
|
||||||
|
|
||||||
onFocusChanged: focus && refreshData()
|
onFocusChanged: focus && refreshData()
|
||||||
|
|
||||||
@ -84,7 +80,7 @@ Item
|
|||||||
Timer
|
Timer
|
||||||
{
|
{
|
||||||
id: refreshTimer
|
id: refreshTimer
|
||||||
interval: 500
|
interval: 800
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: if(chatView.visible) chatView.refreshData()
|
onTriggered: if(chatView.visible) chatView.refreshData()
|
||||||
Component.onCompleted: start()
|
Component.onCompleted: start()
|
||||||
|
@ -33,15 +33,15 @@ Item
|
|||||||
function refreshOwn()
|
function refreshOwn()
|
||||||
{
|
{
|
||||||
rsApi.request("/identity/own", "", function(par)
|
rsApi.request("/identity/own", "", function(par)
|
||||||
{
|
{
|
||||||
var json = JSON.parse(par.response)
|
var json = JSON.parse(par.response)
|
||||||
if(json.data.length > 0)
|
if(json.data.length > 0)
|
||||||
{
|
{
|
||||||
contactsView.own_gxs_id = json.data[0].gxs_id
|
contactsView.own_gxs_id = json.data[0].gxs_id
|
||||||
contactsView.own_nick = json.data[0].name
|
contactsView.own_nick = json.data[0].name
|
||||||
}
|
}
|
||||||
else createIdentityDialog.visible = true
|
else createIdentityDialog.visible = true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onFocusChanged: focus && refreshData()
|
onFocusChanged: focus && refreshData()
|
||||||
|
Loading…
Reference in New Issue
Block a user