Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chat
RocketChatMobileEngine
Commits
a1a7bb1d
Commit
a1a7bb1d
authored
Feb 09, 2019
by
Armin Felder
Browse files
fix
parent
2880990c
Changes
4
Hide whitespace changes
Inline
Side-by-side
CustomModels/channelmodel.cpp
100644 → 100755
View file @
a1a7bb1d
...
...
@@ -147,6 +147,11 @@ bool ChannelModel::addChannel( const QSharedPointer<RocketChatChannel> &channel
connect
(
channel
.
data
(),
&
RocketChatChannel
::
unreadMessagesChanged
,
this
,
&
ChannelModel
::
onUnreadMessageChanged
,
Qt
::
UniqueConnection
);
connect
(
channel
.
data
(),
&
RocketChatChannel
::
dataChanged
,
this
,
&
ChannelModel
::
onDataChanged
,
Qt
::
UniqueConnection
);
connect
(
channel
.
data
(),
&
RocketChatChannel
::
channelDeleted
,
this
,
&
ChannelModel
::
onDeleted
,
Qt
::
UniqueConnection
);
/* connect(channel.data(), &RocketChatChannel::updatedChanged, [model = this](const QString &id, qint64 pTimeStamp){
model->beginResetModel();
model->channelList.reOrder();
model->endResetModel();
});*/
duplicateCheck
.
insert
(
channel
->
getRoomId
()
);
int
pos
=
channelList
.
findPosition
(
channel
);
if
(
pos
<
0
){
...
...
@@ -172,6 +177,11 @@ bool ChannelModel::addChannelsSlot(const QVector<QSharedPointer<RocketChatChanne
connect
(
channel
.
data
(),
&
RocketChatChannel
::
unreadMessagesChanged
,
this
,
&
ChannelModel
::
onUnreadMessageChanged
,
Qt
::
UniqueConnection
);
connect
(
channel
.
data
(),
&
RocketChatChannel
::
dataChanged
,
this
,
&
ChannelModel
::
onDataChanged
,
Qt
::
UniqueConnection
);
connect
(
channel
.
data
(),
&
RocketChatChannel
::
channelDeleted
,
this
,
&
ChannelModel
::
onDeleted
,
Qt
::
UniqueConnection
);
/* connect(channel.data(), &RocketChatChannel::updatedChanged, [model=this](const QString &id, qint64 pTimeStamp){
model->beginResetModel();
// model->channelList.reOrder();
model->endResetModel();
});*/
duplicateCheck
.
insert
(
channel
->
getRoomId
()
);
channelList
.
insertSort
(
channel
);
}
...
...
@@ -291,6 +301,11 @@ void ChannelModel::onDeleted( const QString &pId, bool deleted )
}
void
ChannelModel
::
onChannelOrderChanged
(
const
QString
&
pId
,
qint64
pTimestamp
)
{
qDebug
()
<<
"order changed 123"
;
}
void
ChannelModel
::
addChannelSlot
(
const
QSharedPointer
<
RocketChatChannel
>
&
channel
)
{
addChannel
(
channel
);
...
...
@@ -308,11 +323,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
();
}
...
...
container/sortedvector.cpp
View file @
a1a7bb1d
...
...
@@ -99,6 +99,8 @@ int SortedVector<T>::findPosition( const QSharedPointer<T> &pointer ) const
template
<
typename
T
>
void
SortedVector
<
T
>::
reOrder
()
{
std
::
sort
(
this
->
begin
(),
this
->
end
());
std
::
sort
(
this
->
begin
(),
this
->
end
(),[](
const
auto
&
first
,
const
auto
&
second
){
return
first
.
get
()
>
second
.
get
();
});
}
repos/entities/rocketchatchannel.cpp
View file @
a1a7bb1d
...
...
@@ -366,9 +366,12 @@ 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
);
}
mUpdatedAt
=
updatedAt
;
emit
updatedChanged
(
mRoomId
,
mUpdatedAt
);
}
}
...
...
rocketchatserver.cpp
View file @
a1a7bb1d
...
...
@@ -1489,16 +1489,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 ) ) ) {
...
...
@@ -1513,6 +1513,7 @@ void RocketChatServerData::handleStreamRoomMessage( const QJsonObject &pMessage
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment