Commit 7a3ee436 authored by armin's avatar armin
Browse files

Merge branch 'anotherFix' into 'master'

asd

See merge request !128
parents 01713517 c1f0fa7b
......@@ -38,103 +38,105 @@ QVariant ChannelModel::data( const QModelIndex &index, int role ) const
auto currentChannel = channelList.at( row );
auto roleType = static_cast<ChannelRoles>( role );
if ( !currentChannel.isNull() ) {
auto roleType = static_cast<ChannelRoles>( role );
switch ( roleType ) {
case ChannelRoles::name:
return currentChannel->getName();
switch ( roleType ) {
case ChannelRoles::name:
return currentChannel->getName();
case ChannelRoles::roomId:
return currentChannel->getRoomId();
case ChannelRoles::roomId:
return currentChannel->getRoomId();
case ChannelRoles::lastMessageText: {
auto channel = channelList.at( row );
auto message = channel->getYoungestMessage();
case ChannelRoles::lastMessageText: {
auto channel = channelList.at( row );
auto message = channel->getYoungestMessage();
if ( message.isNull() ) {
return "";
}
if ( message.isNull() ) {
return "";
}
if ( message->getMessageType() == QStringLiteral( "file" ) || message->getMessageType() == QStringLiteral( "image" ) || message->getMessageType() == QStringLiteral( "audio" ) ) {
return tr( QByteArrayLiteral( "file upload" ) );
}
if ( message->getMessageType() == QStringLiteral( "file" ) || message->getMessageType() == QStringLiteral( "image" ) || message->getMessageType() == QStringLiteral( "audio" ) ) {
return tr( QByteArrayLiteral( "file upload" ) );
auto messageText = message->getMessageString();
messageText = messageText.replace( "<img height='20' width='20'", "<img height='10' width='10'" );
return messageText;
}
auto messageText = message->getMessageString();
messageText = messageText.replace( "<img height='20' width='20'", "<img height='10' width='10'" );
return messageText;
}
case ChannelRoles::channelType:
return currentChannel->getType();
case ChannelRoles::channelType:
return currentChannel->getType();
case ChannelRoles::unreadMessages:
return currentChannel->getUnreadMessages();
case ChannelRoles::unreadMessages:
return currentChannel->getUnreadMessages();
case ChannelRoles::readonly:
return currentChannel->getReadOnly() || currentChannel->getArchived() || currentChannel->getBlocked();
case ChannelRoles::readonly:
return currentChannel->getReadOnly() || currentChannel->getArchived() || currentChannel->getBlocked();
case ChannelRoles::ownerId:
return currentChannel->getOwnerId();
case ChannelRoles::ownerId:
return currentChannel->getOwnerId();
case ChannelRoles::archived:
return currentChannel->getArchived();
case ChannelRoles::archived:
return currentChannel->getArchived();
case ChannelRoles::blocked:
return currentChannel->getBlocked();
case ChannelRoles::blocked:
return currentChannel->getBlocked();
case ChannelRoles::username:
return currentChannel->getUsername();
case ChannelRoles::username:
return currentChannel->getUsername();
case ChannelRoles::userStatus: {
int status = 0;
auto partner = currentChannel->getChatPartner();
case ChannelRoles::userStatus: {
int status = 0;
auto partner = currentChannel->getChatPartner();
if ( !partner.isNull() ) {
switch ( partner->getStatus() ) {
case RocketChatUser::status::ONLINE :
status = 0;
break;
if ( !partner.isNull() ) {
switch ( partner->getStatus() ) {
case RocketChatUser::status::ONLINE :
status = 0;
break;
case RocketChatUser::status::AWAY :
status = 1;
break;
case RocketChatUser::status::AWAY :
status = 1;
break;
case RocketChatUser::status::OFFLINE:
status = 2;
break;
case RocketChatUser::status::OFFLINE:
status = 2;
break;
case RocketChatUser::status::BUSY:
status = 3;
break;
}
case RocketChatUser::status::BUSY:
status = 3;
break;
}
return status;
}
return status;
}
case ChannelRoles::deleted:
return currentChannel->getDeleted();
case ChannelRoles::deleted:
return currentChannel->getDeleted();
case ChannelRoles::ownerName:
return currentChannel->getOwnerName();
case ChannelRoles::ownerName:
return currentChannel->getOwnerName();
case ChannelRoles::avatarImg: {
auto avatarImg = currentChannel->getAvatarImg();
case ChannelRoles::avatarImg: {
auto avatarImg = currentChannel->getAvatarImg();
if ( !avatarImg.isNull() ) {
auto path = Utils::getPathPrefix() + avatarImg->getFilePath();
if ( !avatarImg.isNull() ) {
auto path = Utils::getPathPrefix() + avatarImg->getFilePath();
if ( path.endsWith( "svg" ) ) {
return "qrc:res/user-identity.svg";
if ( path.endsWith( "svg" ) ) {
return "qrc:res/user-identity.svg";
} else {
return path;
}
} else {
return path;
return "";
}
} else {
return "";
}
}
}
}
return QVariant();
......@@ -174,6 +176,8 @@ bool ChannelModel::addChannelsSlot( const QList<QSharedPointer<RocketChatChannel
int from = -1;
int to = -1;
beginResetModel();
for ( const auto &channel : pChannels ) {
if ( !channel.isNull() && !channel->getRoomId().isEmpty() && !duplicateCheck.contains( channel->getRoomId() ) ) {
//connect( channel.data(), &RocketChatChannel::messageAdded, this, &ChannelModel::onNewerMessage, Qt::UniqueConnection );
......@@ -197,9 +201,9 @@ bool ChannelModel::addChannelsSlot( const QList<QSharedPointer<RocketChatChannel
}
}
beginInsertRows( QModelIndex(), from, to );
endInsertRows();
// endResetModel();
//beginInsertRows( QModelIndex(), from, to );
//endInsertRows();
endResetModel();
return true;
}
......
......@@ -113,7 +113,7 @@ QList<QSharedPointer<RocketChatChannel> > RocketChatChannelService::processChann
qint64 updatedAt = -1;
//don't ask ...
if ( currentChannelObject.contains( QStringLiteral( "_updatedAt" ) ) ) {
if ( currentChannelObject.contains( QStringLiteral( "_updatedAt" ) ) && !currentChannelObject.contains( QStringLiteral( "ls" ) ) ) {
auto updatedObj = currentChannelObject[QStringLiteral( "_updatedAt" )].toObject();
updatedAt = static_cast<qint64>( updatedObj[QStringLiteral( "$date" )].toDouble() );
}
......
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