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
|
- global availability (in drop down list) gets restored after reconnection
|
||||||
- status icon in active chat changes when presence of the pen pal changes
|
- 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)
|
## Squawk 0.1.5 (Jul 29, 2020)
|
||||||
### Bug fixes
|
### 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
|
Shared::Message Core::Archive::getMessage(const std::string& id, MDB_txn* txn) const
|
||||||
{
|
{
|
||||||
MDB_val lmdbKey, lmdbData;
|
MDB_val lmdbKey, lmdbData;
|
||||||
|
@ -46,6 +46,7 @@ public:
|
|||||||
bool addElement(const Shared::Message& message);
|
bool addElement(const Shared::Message& message);
|
||||||
unsigned int addElements(const std::list<Shared::Message>& messages);
|
unsigned int addElements(const std::list<Shared::Message>& messages);
|
||||||
Shared::Message getElement(const QString& id) const;
|
Shared::Message getElement(const QString& id) const;
|
||||||
|
bool hasElement(const QString& id) const;
|
||||||
void changeMessage(const QString& id, const QMap<QString, QVariant>& data);
|
void changeMessage(const QString& id, const QMap<QString, QVariant>& data);
|
||||||
Shared::Message oldest();
|
Shared::Message oldest();
|
||||||
QString oldestId();
|
QString oldestId();
|
||||||
|
@ -248,19 +248,23 @@ void Core::RosterItem::appendMessageToArchive(const Shared::Message& msg)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case beginning:
|
case beginning:
|
||||||
|
if (!archive->hasElement(msg.getId())) {
|
||||||
appendCache.push_back(msg);
|
appendCache.push_back(msg);
|
||||||
if (!syncronizing) {
|
if (!syncronizing) {
|
||||||
requestHistory(-1, getId(msg));
|
requestHistory(-1, getId(msg));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case end:
|
case end:
|
||||||
archive->addElement(msg);
|
archive->addElement(msg);
|
||||||
break;
|
break;
|
||||||
case chunk:
|
case chunk:
|
||||||
|
if (!archive->hasElement(msg.getId())) {
|
||||||
appendCache.push_back(msg);
|
appendCache.push_back(msg);
|
||||||
if (!syncronizing) {
|
if (!syncronizing) {
|
||||||
requestHistory(-1, getId(msg));
|
requestHistory(-1, getId(msg));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case complete:
|
case complete:
|
||||||
archive->addElement(msg);
|
archive->addElement(msg);
|
||||||
|
Loading…
Reference in New Issue
Block a user