Commit 053bd164 authored by armin's avatar armin
Browse files

Merge branch 'master' into 'mutexProb'

# Conflicts:
#   CustomModels/channelmodel.cpp
#   container/sortedvector.cpp
parents bd69e2a2 d0c9c342
......@@ -318,11 +318,29 @@ void ChannelModel::setType( const QString &value )
void ChannelModel::sortChanged()
{
static int counter = 0;
counter++;
qDebug()<<counter;
beginResetModel();
channelList.reOrder();
std::sort( channelList.begin(), channelList.end(), []( const QSharedPointer<RocketChatChannel> &channel1, const QSharedPointer<RocketChatChannel> &channel2 ) {
auto youngest1 = channel1->getYoungestMessage();
auto youngest2 = channel2->getYoungestMessage();
if ( !youngest1.isNull() && !youngest2.isNull() ) {
auto timestamp1 = youngest1->getTimestamp();
auto timestamp2 = youngest2->getTimestamp();
return timestamp2 < timestamp1;
}
if ( youngest1.isNull() && !youngest2.isNull() ) {
return false;
}
if ( youngest2.isNull() && !youngest1.isNull() ) {
return true;
}
return false;
} );
endResetModel();
emit countChanged();
}
......
......@@ -370,6 +370,7 @@ qint64 RocketChatChannel::getUpdatedAt() const
void RocketChatChannel::setUpdatedAt( const qint64 &updatedAt )
{
//skip signal the first time
if(mUpdatedAt != updatedAt){
if(mUpdatedAt != -1){
emit updatedChanged(mRoomId,mUpdatedAt);
......
......@@ -1517,16 +1517,16 @@ bool RocketChatServerData::isUserJoinMessage( const QJsonObject &pMessage ) cons
void RocketChatServerData::handleStreamRoomMessage( const QJsonObject &pMessage )
{
if ( Q_LIKELY( pMessage.contains( QStringLiteral( "fields" ) ) ) ) {
QJsonObject fields = pMessage[QStringLiteral( "fields" )].toObject();
auto fields = pMessage[QStringLiteral( "fields" )].toObject();
if ( Q_LIKELY( fields.contains( QStringLiteral( "args" ) ) ) ) {
QJsonArray args = fields[QStringLiteral( "args" )].toArray();
auto args = fields[QStringLiteral( "args" )].toArray();
for ( const auto currentArg : args ) {
QJsonObject currentArgObj = currentArg.toObject();
auto currentArgObj = currentArg.toObject();
if ( Q_LIKELY( currentArgObj.contains( QStringLiteral( "rid" ) ) && currentArgObj.contains( QStringLiteral( "_id" ) ) ) ) {
QString roomId = currentArgObj[QStringLiteral( "rid" )].toString();
auto roomId = currentArgObj[QStringLiteral( "rid" )].toString();
auto message = mMessageService->parseMessage( currentArgObj, true );
if ( Q_LIKELY( mChannels->contains( roomId ) ) ) {
......@@ -1541,6 +1541,7 @@ void RocketChatServerData::handleStreamRoomMessage( const QJsonObject &pMessage
}
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment