forked from blue/squawk
found a way to avoid requesting all the MUCs history alltogether on startup
This commit is contained in:
parent
3a120c773a
commit
ef1a9846bf
@ -7,6 +7,9 @@
|
||||
- global availability (in drop down list) gets restored after reconnection
|
||||
- status icon in active chat changes when presence of the pen pal changes
|
||||
|
||||
### Improvements
|
||||
- slightly reduced the traffic on the startup by not requesting history of all MUCs
|
||||
|
||||
|
||||
## Squawk 0.1.5 (Jul 29, 2020)
|
||||
### Bug fixes
|
||||
|
@ -214,6 +214,26 @@ Shared::Message Core::Archive::getElement(const QString& id) const
|
||||
}
|
||||
}
|
||||
|
||||
bool Core::Archive::hasElement(const QString& id) const
|
||||
{
|
||||
if (!opened) {
|
||||
throw Closed("hasElement", jid.toStdString());
|
||||
}
|
||||
|
||||
MDB_txn *txn;
|
||||
mdb_txn_begin(environment, NULL, MDB_RDONLY, &txn);
|
||||
|
||||
bool has;
|
||||
MDB_val lmdbKey, lmdbData;
|
||||
lmdbKey.mv_size = id.size();
|
||||
lmdbKey.mv_data = (char*)id.toStdString().c_str();
|
||||
int rc = mdb_get(txn, main, &lmdbKey, &lmdbData);
|
||||
has = rc == 0;
|
||||
mdb_txn_abort(txn);
|
||||
|
||||
return has;
|
||||
}
|
||||
|
||||
Shared::Message Core::Archive::getMessage(const std::string& id, MDB_txn* txn) const
|
||||
{
|
||||
MDB_val lmdbKey, lmdbData;
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
bool addElement(const Shared::Message& message);
|
||||
unsigned int addElements(const std::list<Shared::Message>& messages);
|
||||
Shared::Message getElement(const QString& id) const;
|
||||
bool hasElement(const QString& id) const;
|
||||
void changeMessage(const QString& id, const QMap<QString, QVariant>& data);
|
||||
Shared::Message oldest();
|
||||
QString oldestId();
|
||||
|
@ -248,18 +248,22 @@ void Core::RosterItem::appendMessageToArchive(const Shared::Message& msg)
|
||||
}
|
||||
break;
|
||||
case beginning:
|
||||
appendCache.push_back(msg);
|
||||
if (!syncronizing) {
|
||||
requestHistory(-1, getId(msg));
|
||||
if (!archive->hasElement(msg.getId())) {
|
||||
appendCache.push_back(msg);
|
||||
if (!syncronizing) {
|
||||
requestHistory(-1, getId(msg));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case end:
|
||||
archive->addElement(msg);
|
||||
break;
|
||||
case chunk:
|
||||
appendCache.push_back(msg);
|
||||
if (!syncronizing) {
|
||||
requestHistory(-1, getId(msg));
|
||||
if (!archive->hasElement(msg.getId())) {
|
||||
appendCache.push_back(msg);
|
||||
if (!syncronizing) {
|
||||
requestHistory(-1, getId(msg));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case complete:
|
||||
|
Loading…
Reference in New Issue
Block a user