mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-03 14:25:38 +02:00
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
This commit is contained in:
parent
bbdd75f1e1
commit
538481a9f8
4 changed files with 31 additions and 7 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 (...) {}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue