mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(offlingmsg): only dipatch offline messages on friend online change
Before if the new status was online, we would dipsatch, which could cause double sends in the case of a friend going from e.g. busy -> away
This commit is contained in:
parent
239dfdc65c
commit
479b39f536
|
@ -152,8 +152,15 @@ bool Friend::getEventFlag() const
|
|||
void Friend::setStatus(Status::Status s)
|
||||
{
|
||||
if (friendStatus != s) {
|
||||
auto oldStatus = friendStatus;
|
||||
friendStatus = s;
|
||||
emit statusChanged(friendPk, friendStatus);
|
||||
if (!Status::isOnline(oldStatus) && Status::isOnline(friendStatus)) {
|
||||
emit onlineOfflineChanged(friendPk, true);
|
||||
} else if (Status::isOnline(oldStatus) && !Status::isOnline(friendStatus)) {
|
||||
emit onlineOfflineChanged(friendPk, false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ signals:
|
|||
void nameChanged(const ToxPk& friendId, const QString& name);
|
||||
void aliasChanged(const ToxPk& friendId, QString alias);
|
||||
void statusChanged(const ToxPk& friendId, Status::Status status);
|
||||
void onlineOfflineChanged(const ToxPk& friendId, bool isOnline);
|
||||
void statusMessageChanged(const ToxPk& friendId, const QString& message);
|
||||
void loadChatHistory();
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ FriendMessageDispatcher::FriendMessageDispatcher(Friend& f_, MessageProcessor pr
|
|||
, offlineMsgEngine(&f_, &messageSender_)
|
||||
, processor(std::move(processor_))
|
||||
{
|
||||
connect(&f, &Friend::statusChanged, this, &FriendMessageDispatcher::onFriendStatusChange);
|
||||
connect(&f, &Friend::onlineOfflineChanged, this, &FriendMessageDispatcher::onFriendOnlineOfflineChanged);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,9 +108,9 @@ void FriendMessageDispatcher::onReceiptReceived(ReceiptNum receipt)
|
|||
* @brief Handles status change for friend
|
||||
* @note Parameters just to fit slot api
|
||||
*/
|
||||
void FriendMessageDispatcher::onFriendStatusChange(const ToxPk&, Status::Status)
|
||||
void FriendMessageDispatcher::onFriendOnlineOfflineChanged(const ToxPk&, bool isOnline)
|
||||
{
|
||||
if (Status::isOnline(f.getStatus())) {
|
||||
if (isOnline) {
|
||||
offlineMsgEngine.deliverOfflineMsgs();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
void onReceiptReceived(ReceiptNum receipt);
|
||||
void clearOutgoingMessages();
|
||||
private slots:
|
||||
void onFriendStatusChange(const ToxPk& key, Status::Status status);
|
||||
void onFriendOnlineOfflineChanged(const ToxPk& key, bool isOnline);
|
||||
|
||||
private:
|
||||
Friend& f;
|
||||
|
|
Loading…
Reference in New Issue
Block a user