Handle new typing update in channels.

This commit is contained in:
John Preston 2020-09-18 14:51:06 +03:00
parent a287dec242
commit f53f934001

View file

@ -1541,14 +1541,8 @@ void Updates::feedUpdate(const MTPUpdate &update) {
case mtpc_updateChatUserTyping: {
auto &d = update.c_updateChatUserTyping();
const auto history = [&]() -> History* {
if (const auto chat = session().data().chatLoaded(d.vchat_id().v)) {
return session().data().historyLoaded(chat->id);
} else if (const auto channel = session().data().channelLoaded(d.vchat_id().v)) {
return session().data().historyLoaded(channel->id);
}
return nullptr;
}();
const auto history = session().data().historyLoaded(
peerFromChat(d.vchat_id()));
const auto user = (d.vuser_id().v == session().userId())
? nullptr
: session().data().userLoaded(d.vuser_id().v);
@ -1558,6 +1552,19 @@ void Updates::feedUpdate(const MTPUpdate &update) {
}
} break;
case mtpc_updateChannelUserTyping: {
const auto &d = update.c_updateChannelUserTyping();
const auto history = session().data().historyLoaded(
peerFromChannel(d.vchannel_id()));
const auto user = (d.vuser_id().v == session().userId())
? nullptr
: session().data().userLoaded(d.vuser_id().v);
if (history && user && !d.vtop_msg_id().value_or_empty()) {
const auto when = requestingDifference() ? 0 : base::unixtime::now();
session().data().registerSendAction(history, user, d.vaction(), when);
}
} break;
case mtpc_updateChatParticipants: {
session().data().applyUpdate(update.c_updateChatParticipants());
} break;