Skip to content
Snippets Groups Projects
Commit 538481a9 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

smartlist: improve cache cleaning and avoid glitches

Interaction's cache is cleaned to avoid to store too much informations
and to refresh preferences for the chatview when necessary.
However, this was called too much times. We only need to clear cache
when the settings are changing or if we need to remove a lot of
conversations. This patch uses the SmartListItem to determine
what conversation needs to be cleaned.

Change-Id: I731bb9e7d41b140bbc2607800c1a8e0a1eff3244
parent bbdd75f1
No related branches found
No related tags found
No related merge requests found
......@@ -433,11 +433,7 @@ void
LRCInstance::set_selectedConvUid(QString selectedConvUid)
{
if (selectedConvUid_ != selectedConvUid) {
auto& accInfo = accountModel().getAccountInfo(get_currentAccountId());
auto& convModel = accInfo.conversationModel;
convModel->clearInteractionsCache(selectedConvUid_);
selectedConvUid_ = selectedConvUid;
Q_EMIT selectedConvUidChanged();
}
}
}
\ No newline at end of file
......@@ -33,8 +33,23 @@ ItemDelegate {
width: ListView.view.width
height: JamiTheme.smartListItemHeight
function convUid() {
return UID
property string accountId: ""
property string convId: ""
onVisibleChanged: {
if (visible)
return
UtilsAdapter.clearInteractionsCache(root.accountId, root.convId)
}
Component.onCompleted: {
// Store to avoid undefined at the end
root.accountId = CurrentAccount.id
root.convId = UID
}
Component.onDestruction: {
UtilsAdapter.clearInteractionsCache(root.accountId, root.convId)
}
RowLayout {
......
......@@ -399,4 +399,16 @@ UtilsAdapter::monitor(const bool& continuous)
Q_EMIT debugMessageReceived(data);
});
lrcInstance_->monitor(continuous);
}
void
UtilsAdapter::clearInteractionsCache(const QString& accountId, const QString& convId)
{
if (lrcInstance_->get_selectedConvUid() != convId) {
try {
auto& accInfo = lrcInstance_->accountModel().getAccountInfo(accountId);
auto& convModel = accInfo.conversationModel;
convModel->clearInteractionsCache(convId);
} catch (...) {}
}
}
\ No newline at end of file
......@@ -89,6 +89,7 @@ public:
Q_INVOKABLE void setRunOnStartUp(bool state);
Q_INVOKABLE void setDownloadPath(QString dir);
Q_INVOKABLE void monitor(const bool& continuous);
Q_INVOKABLE void clearInteractionsCache(const QString& accountId, const QString& convUid);
Q_SIGNALS:
void debugMessageReceived(const QString& message);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment