mirror of https://github.com/procxx/kepka.git
Fix indexing of shared media.
Add new messages to shared media index even if !loadedAtBottom().
This commit is contained in:
parent
aebb40dc1e
commit
255dbf9405
|
@ -1989,45 +1989,49 @@ void ApiWrap::applyUpdatesNoPtsCheck(const MTPUpdates &updates) {
|
||||||
case mtpc_updateShortMessage: {
|
case mtpc_updateShortMessage: {
|
||||||
auto &d = updates.c_updateShortMessage();
|
auto &d = updates.c_updateShortMessage();
|
||||||
auto flags = mtpCastFlags(d.vflags.v) | MTPDmessage::Flag::f_from_id;
|
auto flags = mtpCastFlags(d.vflags.v) | MTPDmessage::Flag::f_from_id;
|
||||||
App::histories().addNewMessage(MTP_message(
|
App::histories().addNewMessage(
|
||||||
MTP_flags(flags),
|
MTP_message(
|
||||||
d.vid,
|
MTP_flags(flags),
|
||||||
d.is_out() ? MTP_int(Auth().userId()) : d.vuser_id,
|
d.vid,
|
||||||
MTP_peerUser(d.is_out() ? d.vuser_id : MTP_int(Auth().userId())),
|
d.is_out() ? MTP_int(Auth().userId()) : d.vuser_id,
|
||||||
d.vfwd_from,
|
MTP_peerUser(d.is_out() ? d.vuser_id : MTP_int(Auth().userId())),
|
||||||
d.vvia_bot_id,
|
d.vfwd_from,
|
||||||
d.vreply_to_msg_id,
|
d.vvia_bot_id,
|
||||||
d.vdate,
|
d.vreply_to_msg_id,
|
||||||
d.vmessage,
|
d.vdate,
|
||||||
MTP_messageMediaEmpty(),
|
d.vmessage,
|
||||||
MTPnullMarkup,
|
MTP_messageMediaEmpty(),
|
||||||
d.has_entities() ? d.ventities : MTPnullEntities,
|
MTPnullMarkup,
|
||||||
MTPint(),
|
d.has_entities() ? d.ventities : MTPnullEntities,
|
||||||
MTPint(),
|
MTPint(),
|
||||||
MTPstring(),
|
MTPint(),
|
||||||
MTPlong()), NewMessageUnread);
|
MTPstring(),
|
||||||
|
MTPlong()),
|
||||||
|
NewMessageUnread);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateShortChatMessage: {
|
case mtpc_updateShortChatMessage: {
|
||||||
auto &d = updates.c_updateShortChatMessage();
|
auto &d = updates.c_updateShortChatMessage();
|
||||||
auto flags = mtpCastFlags(d.vflags.v) | MTPDmessage::Flag::f_from_id;
|
auto flags = mtpCastFlags(d.vflags.v) | MTPDmessage::Flag::f_from_id;
|
||||||
App::histories().addNewMessage(MTP_message(
|
App::histories().addNewMessage(
|
||||||
MTP_flags(flags),
|
MTP_message(
|
||||||
d.vid,
|
MTP_flags(flags),
|
||||||
d.vfrom_id,
|
d.vid,
|
||||||
MTP_peerChat(d.vchat_id),
|
d.vfrom_id,
|
||||||
d.vfwd_from,
|
MTP_peerChat(d.vchat_id),
|
||||||
d.vvia_bot_id,
|
d.vfwd_from,
|
||||||
d.vreply_to_msg_id,
|
d.vvia_bot_id,
|
||||||
d.vdate,
|
d.vreply_to_msg_id,
|
||||||
d.vmessage,
|
d.vdate,
|
||||||
MTP_messageMediaEmpty(),
|
d.vmessage,
|
||||||
MTPnullMarkup,
|
MTP_messageMediaEmpty(),
|
||||||
d.has_entities() ? d.ventities : MTPnullEntities,
|
MTPnullMarkup,
|
||||||
MTPint(),
|
d.has_entities() ? d.ventities : MTPnullEntities,
|
||||||
MTPint(),
|
MTPint(),
|
||||||
MTPstring(),
|
MTPint(),
|
||||||
MTPlong()), NewMessageUnread);
|
MTPstring(),
|
||||||
|
MTPlong()),
|
||||||
|
NewMessageUnread);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateShortSentMessage: {
|
case mtpc_updateShortSentMessage: {
|
||||||
|
|
|
@ -904,26 +904,22 @@ namespace {
|
||||||
if (m.has_from_id() && peerId == Auth().userPeerId()) {
|
if (m.has_from_id() && peerId == Auth().userPeerId()) {
|
||||||
peerId = peerFromUser(m.vfrom_id);
|
peerId = peerFromUser(m.vfrom_id);
|
||||||
}
|
}
|
||||||
if (auto existing = App::histItemById(peerToChannel(peerId), m.vid.v)) {
|
if (const auto existing = App::histItemById(peerToChannel(peerId), m.vid.v)) {
|
||||||
auto text = qs(m.vmessage);
|
auto text = qs(m.vmessage);
|
||||||
auto entities = m.has_entities() ? TextUtilities::EntitiesFromMTP(m.ventities.v) : EntitiesInText();
|
auto entities = m.has_entities()
|
||||||
|
? TextUtilities::EntitiesFromMTP(m.ventities.v)
|
||||||
|
: EntitiesInText();
|
||||||
existing->setText({ text, entities });
|
existing->setText({ text, entities });
|
||||||
existing->updateMedia(m.has_media() ? (&m.vmedia) : nullptr);
|
existing->updateMedia(m.has_media() ? (&m.vmedia) : nullptr);
|
||||||
existing->updateReplyMarkup(m.has_reply_markup() ? (&m.vreply_markup) : nullptr);
|
existing->updateReplyMarkup(m.has_reply_markup()
|
||||||
|
? (&m.vreply_markup)
|
||||||
|
: nullptr);
|
||||||
existing->setViewsCount(m.has_views() ? m.vviews.v : -1);
|
existing->setViewsCount(m.has_views() ? m.vviews.v : -1);
|
||||||
existing->addToUnreadMentions(AddToUnreadMentionsMethod::New);
|
existing->indexAsNewItem();
|
||||||
if (auto sharedMediaTypes = existing->sharedMediaTypes()) {
|
|
||||||
Auth().storage().add(Storage::SharedMediaAddNew(
|
|
||||||
peerId,
|
|
||||||
sharedMediaTypes,
|
|
||||||
existing->id));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!existing->detached()) {
|
if (!existing->detached()) {
|
||||||
App::checkSavedGif(existing);
|
App::checkSavedGif(existing);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -544,27 +544,6 @@ const QDateTime &ChannelHistory::maxReadMessageDate() {
|
||||||
return _maxReadMessageDate;
|
return _maxReadMessageDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem *ChannelHistory::addNewChannelMessage(const MTPMessage &msg, NewMessageType type) {
|
|
||||||
if (type == NewMessageExisting) return addToHistory(msg);
|
|
||||||
|
|
||||||
return addNewToBlocks(msg, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
HistoryItem *ChannelHistory::addNewToBlocks(const MTPMessage &msg, NewMessageType type) {
|
|
||||||
if (!loadedAtBottom()) {
|
|
||||||
HistoryItem *item = addToHistory(msg);
|
|
||||||
if (item) {
|
|
||||||
setLastMessage(item);
|
|
||||||
if (type == NewMessageUnread) {
|
|
||||||
newItemAdded(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
return addNewToLastBlock(msg, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChannelHistory::cleared(bool leaveItems) {
|
void ChannelHistory::cleared(bool leaveItems) {
|
||||||
_joinedMessage = nullptr;
|
_joinedMessage = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -1115,28 +1094,26 @@ not_null<HistoryItem*> History::addNewService(MsgId msgId, QDateTime date, const
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem *History::addNewMessage(const MTPMessage &msg, NewMessageType type) {
|
HistoryItem *History::addNewMessage(const MTPMessage &msg, NewMessageType type) {
|
||||||
if (isChannel()) {
|
|
||||||
return asChannelHistory()->addNewChannelMessage(msg, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == NewMessageExisting) {
|
if (type == NewMessageExisting) {
|
||||||
return addToHistory(msg);
|
return addToHistory(msg);
|
||||||
}
|
}
|
||||||
if (!loadedAtBottom() || peer->migrateTo()) {
|
if (!loadedAtBottom() || peer->migrateTo()) {
|
||||||
const auto item = addToHistory(msg);
|
if (const auto item = addToHistory(msg)) {
|
||||||
if (item) {
|
|
||||||
setLastMessage(item);
|
setLastMessage(item);
|
||||||
if (type == NewMessageUnread) {
|
if (type == NewMessageUnread) {
|
||||||
newItemAdded(item);
|
newItemAdded(item);
|
||||||
}
|
}
|
||||||
|
return item;
|
||||||
}
|
}
|
||||||
return item;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return addNewToLastBlock(msg, type);
|
return addNewToLastBlock(msg, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem *History::addNewToLastBlock(const MTPMessage &msg, NewMessageType type) {
|
HistoryItem *History::addNewToLastBlock(const MTPMessage &msg, NewMessageType type) {
|
||||||
|
Expects(type != NewMessageExisting);
|
||||||
|
|
||||||
const auto applyServiceAction = (type == NewMessageUnread);
|
const auto applyServiceAction = (type == NewMessageUnread);
|
||||||
const auto detachExistingItem = (type != NewMessageLast);
|
const auto detachExistingItem = (type != NewMessageLast);
|
||||||
const auto item = createItem(msg, applyServiceAction, detachExistingItem);
|
const auto item = createItem(msg, applyServiceAction, detachExistingItem);
|
||||||
|
@ -1187,15 +1164,17 @@ void History::setUnreadMentionsCount(int count) {
|
||||||
|
|
||||||
bool History::addToUnreadMentions(
|
bool History::addToUnreadMentions(
|
||||||
MsgId msgId,
|
MsgId msgId,
|
||||||
AddToUnreadMentionsMethod method) {
|
UnreadMentionType type) {
|
||||||
auto allLoaded = _unreadMentionsCount ? (_unreadMentions.size() >= *_unreadMentionsCount) : false;
|
auto allLoaded = _unreadMentionsCount
|
||||||
|
? (_unreadMentions.size() >= *_unreadMentionsCount)
|
||||||
|
: false;
|
||||||
if (allLoaded) {
|
if (allLoaded) {
|
||||||
if (method == AddToUnreadMentionsMethod::New) {
|
if (type == UnreadMentionType::New) {
|
||||||
++*_unreadMentionsCount;
|
++*_unreadMentionsCount;
|
||||||
_unreadMentions.insert(msgId);
|
_unreadMentions.insert(msgId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (!_unreadMentions.empty() && method != AddToUnreadMentionsMethod::New) {
|
} else if (!_unreadMentions.empty() && type != UnreadMentionType::New) {
|
||||||
_unreadMentions.insert(msgId);
|
_unreadMentions.insert(msgId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1274,24 +1253,15 @@ not_null<HistoryItem*> History::addNewItem(not_null<HistoryItem*> adding, bool n
|
||||||
if (groupFrom != groupTill || groupFrom->groupId()) {
|
if (groupFrom != groupTill || groupFrom->groupId()) {
|
||||||
recountGrouping(groupFrom, groupTill);
|
recountGrouping(groupFrom, groupTill);
|
||||||
}
|
}
|
||||||
|
if (!newMsg && IsServerMsgId(adding->id)) {
|
||||||
if (IsServerMsgId(adding->id)) {
|
if (const auto sharedMediaTypes = adding->sharedMediaTypes()) {
|
||||||
adding->addToUnreadMentions(AddToUnreadMentionsMethod::New);
|
auto from = loadedAtTop() ? 0 : minMsgId();
|
||||||
if (auto sharedMediaTypes = adding->sharedMediaTypes()) {
|
auto till = loadedAtBottom() ? ServerMaxMsgId : maxMsgId();
|
||||||
if (newMsg) {
|
Auth().storage().add(Storage::SharedMediaAddExisting(
|
||||||
Auth().storage().add(Storage::SharedMediaAddNew(
|
peer->id,
|
||||||
peer->id,
|
sharedMediaTypes,
|
||||||
sharedMediaTypes,
|
adding->id,
|
||||||
adding->id));
|
{ from, till }));
|
||||||
} else {
|
|
||||||
auto from = loadedAtTop() ? 0 : minMsgId();
|
|
||||||
auto till = loadedAtBottom() ? ServerMaxMsgId : maxMsgId();
|
|
||||||
Auth().storage().add(Storage::SharedMediaAddExisting(
|
|
||||||
peer->id,
|
|
||||||
sharedMediaTypes,
|
|
||||||
adding->id,
|
|
||||||
{ from, till }));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (adding->from()->id) {
|
if (adding->from()->id) {
|
||||||
|
@ -1399,8 +1369,9 @@ void History::clearSendAction(not_null<UserData*> from) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::newItemAdded(HistoryItem *item) {
|
void History::newItemAdded(not_null<HistoryItem*> item) {
|
||||||
App::checkImageCacheSize();
|
App::checkImageCacheSize();
|
||||||
|
item->indexAsNewItem();
|
||||||
if (const auto from = item->from() ? item->from()->asUser() : nullptr) {
|
if (const auto from = item->from() ? item->from()->asUser() : nullptr) {
|
||||||
if (from == item->author()) {
|
if (from == item->author()) {
|
||||||
clearSendAction(from);
|
clearSendAction(from);
|
||||||
|
@ -1409,7 +1380,9 @@ void History::newItemAdded(HistoryItem *item) {
|
||||||
from->madeAction(itemServerTime.v);
|
from->madeAction(itemServerTime.v);
|
||||||
}
|
}
|
||||||
if (item->out()) {
|
if (item->out()) {
|
||||||
if (unreadBar) unreadBar->destroyUnreadBar();
|
if (unreadBar) {
|
||||||
|
unreadBar->destroyUnreadBar();
|
||||||
|
}
|
||||||
if (!item->unread()) {
|
if (!item->unread()) {
|
||||||
outboxRead(item);
|
outboxRead(item);
|
||||||
}
|
}
|
||||||
|
@ -1599,7 +1572,7 @@ void History::addOlderSlice(const QVector<MTPMessage> &slice) {
|
||||||
}
|
}
|
||||||
for (auto i = block->items.size(); i > 0; --i) {
|
for (auto i = block->items.size(); i > 0; --i) {
|
||||||
auto item = block->items[i - 1];
|
auto item = block->items[i - 1];
|
||||||
item->addToUnreadMentions(AddToUnreadMentionsMethod::Front);
|
item->addToUnreadMentions(UnreadMentionType::Existing);
|
||||||
if (item->from()->id) {
|
if (item->from()->id) {
|
||||||
if (lastAuthors) { // chats
|
if (lastAuthors) { // chats
|
||||||
if (auto user = item->from()->asUser()) {
|
if (auto user = item->from()->asUser()) {
|
||||||
|
@ -1768,9 +1741,9 @@ void History::checkAddAllToUnreadMentions() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for_const (auto block, blocks) {
|
for (const auto block : blocks) {
|
||||||
for_const (auto item, block->items) {
|
for (const auto item : block->items) {
|
||||||
item->addToUnreadMentions(AddToUnreadMentionsMethod::Back);
|
item->addToUnreadMentions(UnreadMentionType::Existing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2417,11 +2390,11 @@ int History::resizeGetHeight(int newWidth) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelHistory *History::asChannelHistory() {
|
ChannelHistory *History::asChannelHistory() {
|
||||||
return isChannel() ? static_cast<ChannelHistory*>(this) : 0;
|
return isChannel() ? static_cast<ChannelHistory*>(this) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChannelHistory *History::asChannelHistory() const {
|
const ChannelHistory *History::asChannelHistory() const {
|
||||||
return isChannel() ? static_cast<const ChannelHistory*>(this) : 0;
|
return isChannel() ? static_cast<const ChannelHistory*>(this) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
not_null<History*> History::migrateToOrMe() const {
|
not_null<History*> History::migrateToOrMe() const {
|
||||||
|
|
|
@ -173,10 +173,9 @@ struct Draft;
|
||||||
class HistoryMedia;
|
class HistoryMedia;
|
||||||
class HistoryMessage;
|
class HistoryMessage;
|
||||||
|
|
||||||
enum class AddToUnreadMentionsMethod {
|
enum class UnreadMentionType {
|
||||||
New, // when new message is added to history
|
New, // when new message is added to history
|
||||||
Front, // when old messages slice was received
|
Existing, // when some messages slice was received
|
||||||
Back, // when new messages slice was received and it is the last one, we index all media
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Dialogs {
|
namespace Dialogs {
|
||||||
|
@ -234,7 +233,7 @@ public:
|
||||||
void addOlderSlice(const QVector<MTPMessage> &slice);
|
void addOlderSlice(const QVector<MTPMessage> &slice);
|
||||||
void addNewerSlice(const QVector<MTPMessage> &slice);
|
void addNewerSlice(const QVector<MTPMessage> &slice);
|
||||||
|
|
||||||
void newItemAdded(HistoryItem *item);
|
void newItemAdded(not_null<HistoryItem*> item);
|
||||||
|
|
||||||
int countUnread(MsgId upTo);
|
int countUnread(MsgId upTo);
|
||||||
void updateShowFrom();
|
void updateShowFrom();
|
||||||
|
@ -369,7 +368,7 @@ public:
|
||||||
return (getUnreadMentionsCount() > 0);
|
return (getUnreadMentionsCount() > 0);
|
||||||
}
|
}
|
||||||
void setUnreadMentionsCount(int count);
|
void setUnreadMentionsCount(int count);
|
||||||
bool addToUnreadMentions(MsgId msgId, AddToUnreadMentionsMethod method);
|
bool addToUnreadMentions(MsgId msgId, UnreadMentionType type);
|
||||||
void eraseFromUnreadMentions(MsgId msgId);
|
void eraseFromUnreadMentions(MsgId msgId);
|
||||||
void addUnreadMentionsSlice(const MTPmessages_Messages &result);
|
void addUnreadMentionsSlice(const MTPmessages_Messages &result);
|
||||||
|
|
||||||
|
@ -609,11 +608,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class History;
|
friend class History;
|
||||||
HistoryItem* addNewChannelMessage(const MTPMessage &msg, NewMessageType type);
|
|
||||||
HistoryItem *addNewToBlocks(const MTPMessage &msg, NewMessageType type);
|
|
||||||
|
|
||||||
void checkMaxReadMessageDate();
|
void checkMaxReadMessageDate();
|
||||||
|
|
||||||
void cleared(bool leaveItems);
|
void cleared(bool leaveItems);
|
||||||
|
|
||||||
QDateTime _maxReadMessageDate;
|
QDateTime _maxReadMessageDate;
|
||||||
|
|
|
@ -350,6 +350,18 @@ Storage::SharedMediaTypesMask HistoryItem::sharedMediaTypes() const {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HistoryItem::indexAsNewItem() {
|
||||||
|
if (IsServerMsgId(id)) {
|
||||||
|
addToUnreadMentions(UnreadMentionType::New);
|
||||||
|
if (const auto types = sharedMediaTypes()) {
|
||||||
|
Auth().storage().add(Storage::SharedMediaAddNew(
|
||||||
|
history()->peer->id,
|
||||||
|
types,
|
||||||
|
id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryItem::previousItemChanged() {
|
void HistoryItem::previousItemChanged() {
|
||||||
Expects(!isLogEntry());
|
Expects(!isLogEntry());
|
||||||
recountDisplayDate();
|
recountDisplayDate();
|
||||||
|
|
|
@ -303,9 +303,6 @@ public:
|
||||||
bool isPost() const {
|
bool isPost() const {
|
||||||
return _flags & MTPDmessage::Flag::f_post;
|
return _flags & MTPDmessage::Flag::f_post;
|
||||||
}
|
}
|
||||||
bool indexInUnreadMentions() const {
|
|
||||||
return (id > 0);
|
|
||||||
}
|
|
||||||
bool isSilent() const {
|
bool isSilent() const {
|
||||||
return _flags & MTPDmessage::Flag::f_silent;
|
return _flags & MTPDmessage::Flag::f_silent;
|
||||||
}
|
}
|
||||||
|
@ -349,11 +346,12 @@ public:
|
||||||
virtual void updateReplyMarkup(const MTPReplyMarkup *markup) {
|
virtual void updateReplyMarkup(const MTPReplyMarkup *markup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void addToUnreadMentions(AddToUnreadMentionsMethod method) {
|
virtual void addToUnreadMentions(UnreadMentionType type) {
|
||||||
}
|
}
|
||||||
virtual void eraseFromUnreadMentions() {
|
virtual void eraseFromUnreadMentions() {
|
||||||
}
|
}
|
||||||
virtual Storage::SharedMediaTypesMask sharedMediaTypes() const;
|
virtual Storage::SharedMediaTypesMask sharedMediaTypes() const;
|
||||||
|
void indexAsNewItem();
|
||||||
|
|
||||||
virtual bool hasBubble() const {
|
virtual bool hasBubble() const {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1375,9 +1375,9 @@ void HistoryMessage::updateMedia(const MTPMessageMedia *media) {
|
||||||
setPendingInitDimensions();
|
setPendingInitDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryMessage::addToUnreadMentions(AddToUnreadMentionsMethod method) {
|
void HistoryMessage::addToUnreadMentions(UnreadMentionType type) {
|
||||||
if (indexInUnreadMentions() && mentionsMe() && isMediaUnread()) {
|
if (IsServerMsgId(id) && mentionsMe() && isMediaUnread()) {
|
||||||
if (history()->addToUnreadMentions(id, method)) {
|
if (history()->addToUnreadMentions(id, type)) {
|
||||||
Notify::peerUpdatedDelayed(
|
Notify::peerUpdatedDelayed(
|
||||||
history()->peer,
|
history()->peer,
|
||||||
Notify::PeerUpdate::Flag::UnreadMentionsChanged);
|
Notify::PeerUpdate::Flag::UnreadMentionsChanged);
|
||||||
|
|
|
@ -207,7 +207,7 @@ public:
|
||||||
setReplyMarkup(markup);
|
setReplyMarkup(markup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addToUnreadMentions(AddToUnreadMentionsMethod method) override;
|
void addToUnreadMentions(UnreadMentionType type) override;
|
||||||
void eraseFromUnreadMentions() override;
|
void eraseFromUnreadMentions() override;
|
||||||
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,17 @@ QString SendData::getLayoutDescription(const Result *owner) const {
|
||||||
return owner->_description;
|
return owner->_description;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendDataCommon::addToHistory(const Result *owner, History *history,
|
void SendDataCommon::addToHistory(
|
||||||
MTPDmessage::Flags flags, MsgId msgId, UserId fromId, MTPint mtpDate,
|
const Result *owner,
|
||||||
UserId viaBotId, MsgId replyToId, const QString &postAuthor, const MTPReplyMarkup &markup) const {
|
not_null<History*> history,
|
||||||
|
MTPDmessage::Flags flags,
|
||||||
|
MsgId msgId,
|
||||||
|
UserId fromId,
|
||||||
|
MTPint mtpDate,
|
||||||
|
UserId viaBotId,
|
||||||
|
MsgId replyToId,
|
||||||
|
const QString &postAuthor,
|
||||||
|
const MTPReplyMarkup &markup) const {
|
||||||
auto fields = getSentMessageFields();
|
auto fields = getSentMessageFields();
|
||||||
if (!fields.entities.v.isEmpty()) {
|
if (!fields.entities.v.isEmpty()) {
|
||||||
flags |= MTPDmessage::Flag::f_entities;
|
flags |= MTPDmessage::Flag::f_entities;
|
||||||
|
@ -64,8 +72,10 @@ UserId viaBotId, MsgId replyToId, const QString &postAuthor, const MTPReplyMarku
|
||||||
NewMessageUnread);
|
NewMessageUnread);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SendDataCommon::getErrorOnSend(const Result *owner, History *history) const {
|
QString SendDataCommon::getErrorOnSend(
|
||||||
if (auto megagroup = history->peer->asMegagroup()) {
|
const Result *owner,
|
||||||
|
not_null<History*> history) const {
|
||||||
|
if (const auto megagroup = history->peer->asMegagroup()) {
|
||||||
if (megagroup->restricted(ChannelRestriction::f_send_messages)) {
|
if (megagroup->restricted(ChannelRestriction::f_send_messages)) {
|
||||||
return lang(lng_restricted_send_message);
|
return lang(lng_restricted_send_message);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +111,11 @@ SendDataCommon::SentMTPMessageFields SendVenue::getSentMessageFields() const {
|
||||||
|
|
||||||
SendDataCommon::SentMTPMessageFields SendContact::getSentMessageFields() const {
|
SendDataCommon::SentMTPMessageFields SendContact::getSentMessageFields() const {
|
||||||
SentMTPMessageFields result;
|
SentMTPMessageFields result;
|
||||||
result.media = MTP_messageMediaContact(MTP_string(_phoneNumber), MTP_string(_firstName), MTP_string(_lastName), MTP_int(0));
|
result.media = MTP_messageMediaContact(
|
||||||
|
MTP_string(_phoneNumber),
|
||||||
|
MTP_string(_firstName),
|
||||||
|
MTP_string(_lastName),
|
||||||
|
MTP_int(0));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,14 +127,34 @@ QString SendContact::getLayoutDescription(const Result *owner) const {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendPhoto::addToHistory(const Result *owner, History *history,
|
void SendPhoto::addToHistory(
|
||||||
MTPDmessage::Flags flags, MsgId msgId, UserId fromId, MTPint mtpDate,
|
const Result *owner,
|
||||||
UserId viaBotId, MsgId replyToId, const QString &postAuthor, const MTPReplyMarkup &markup) const {
|
not_null<History*> history,
|
||||||
history->addNewPhoto(msgId, flags, viaBotId, replyToId, date(mtpDate), fromId, postAuthor, _photo, _caption, markup);
|
MTPDmessage::Flags flags,
|
||||||
|
MsgId msgId,
|
||||||
|
UserId fromId,
|
||||||
|
MTPint mtpDate,
|
||||||
|
UserId viaBotId,
|
||||||
|
MsgId replyToId,
|
||||||
|
const QString &postAuthor,
|
||||||
|
const MTPReplyMarkup &markup) const {
|
||||||
|
history->addNewPhoto(
|
||||||
|
msgId,
|
||||||
|
flags,
|
||||||
|
viaBotId,
|
||||||
|
replyToId,
|
||||||
|
date(mtpDate),
|
||||||
|
fromId,
|
||||||
|
postAuthor,
|
||||||
|
_photo,
|
||||||
|
_caption,
|
||||||
|
markup);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SendPhoto::getErrorOnSend(const Result *owner, History *history) const {
|
QString SendPhoto::getErrorOnSend(
|
||||||
if (auto megagroup = history->peer->asMegagroup()) {
|
const Result *owner,
|
||||||
|
not_null<History*> history) const {
|
||||||
|
if (const auto megagroup = history->peer->asMegagroup()) {
|
||||||
if (megagroup->restricted(ChannelRestriction::f_send_media)) {
|
if (megagroup->restricted(ChannelRestriction::f_send_media)) {
|
||||||
return lang(lng_restricted_send_media);
|
return lang(lng_restricted_send_media);
|
||||||
}
|
}
|
||||||
|
@ -128,14 +162,34 @@ QString SendPhoto::getErrorOnSend(const Result *owner, History *history) const {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendFile::addToHistory(const Result *owner, History *history,
|
void SendFile::addToHistory(
|
||||||
MTPDmessage::Flags flags, MsgId msgId, UserId fromId, MTPint mtpDate,
|
const Result *owner,
|
||||||
UserId viaBotId, MsgId replyToId, const QString &postAuthor, const MTPReplyMarkup &markup) const {
|
not_null<History*> history,
|
||||||
history->addNewDocument(msgId, flags, viaBotId, replyToId, date(mtpDate), fromId, postAuthor, _document, _caption, markup);
|
MTPDmessage::Flags flags,
|
||||||
|
MsgId msgId,
|
||||||
|
UserId fromId,
|
||||||
|
MTPint mtpDate,
|
||||||
|
UserId viaBotId,
|
||||||
|
MsgId replyToId,
|
||||||
|
const QString &postAuthor,
|
||||||
|
const MTPReplyMarkup &markup) const {
|
||||||
|
history->addNewDocument(
|
||||||
|
msgId,
|
||||||
|
flags,
|
||||||
|
viaBotId,
|
||||||
|
replyToId,
|
||||||
|
date(mtpDate),
|
||||||
|
fromId,
|
||||||
|
postAuthor,
|
||||||
|
_document,
|
||||||
|
_caption,
|
||||||
|
markup);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SendFile::getErrorOnSend(const Result *owner, History *history) const {
|
QString SendFile::getErrorOnSend(
|
||||||
if (auto megagroup = history->peer->asMegagroup()) {
|
const Result *owner,
|
||||||
|
not_null<History*> history) const {
|
||||||
|
if (const auto megagroup = history->peer->asMegagroup()) {
|
||||||
if (megagroup->restricted(ChannelRestriction::f_send_media)) {
|
if (megagroup->restricted(ChannelRestriction::f_send_media)) {
|
||||||
return lang(lng_restricted_send_media);
|
return lang(lng_restricted_send_media);
|
||||||
} else if (megagroup->restricted(ChannelRestriction::f_send_stickers)
|
} else if (megagroup->restricted(ChannelRestriction::f_send_stickers)
|
||||||
|
@ -150,13 +204,32 @@ QString SendFile::getErrorOnSend(const Result *owner, History *history) const {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendGame::addToHistory(const Result *owner, History *history,
|
void SendGame::addToHistory(
|
||||||
MTPDmessage::Flags flags, MsgId msgId, UserId fromId, MTPint mtpDate,
|
const Result *owner,
|
||||||
UserId viaBotId, MsgId replyToId, const QString &postAuthor, const MTPReplyMarkup &markup) const {
|
not_null<History*> history,
|
||||||
history->addNewGame(msgId, flags, viaBotId, replyToId, date(mtpDate), fromId, postAuthor, _game, markup);
|
MTPDmessage::Flags flags,
|
||||||
|
MsgId msgId,
|
||||||
|
UserId fromId,
|
||||||
|
MTPint mtpDate,
|
||||||
|
UserId viaBotId,
|
||||||
|
MsgId replyToId,
|
||||||
|
const QString &postAuthor,
|
||||||
|
const MTPReplyMarkup &markup) const {
|
||||||
|
history->addNewGame(
|
||||||
|
msgId,
|
||||||
|
flags,
|
||||||
|
viaBotId,
|
||||||
|
replyToId,
|
||||||
|
date(mtpDate),
|
||||||
|
fromId,
|
||||||
|
postAuthor,
|
||||||
|
_game,
|
||||||
|
markup);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SendGame::getErrorOnSend(const Result *owner, History *history) const {
|
QString SendGame::getErrorOnSend(
|
||||||
|
const Result *owner,
|
||||||
|
not_null<History*> history) const {
|
||||||
if (auto megagroup = history->peer->asMegagroup()) {
|
if (auto megagroup = history->peer->asMegagroup()) {
|
||||||
if (megagroup->restricted(ChannelRestriction::f_send_games)) {
|
if (megagroup->restricted(ChannelRestriction::f_send_games)) {
|
||||||
return lang(lng_restricted_send_inline);
|
return lang(lng_restricted_send_inline);
|
||||||
|
|
|
@ -41,10 +41,20 @@ public:
|
||||||
|
|
||||||
virtual bool isValid() const = 0;
|
virtual bool isValid() const = 0;
|
||||||
|
|
||||||
virtual void addToHistory(const Result *owner, History *history,
|
virtual void addToHistory(
|
||||||
MTPDmessage::Flags flags, MsgId msgId, UserId fromId, MTPint mtpDate,
|
const Result *owner,
|
||||||
UserId viaBotId, MsgId replyToId, const QString &postAuthor, const MTPReplyMarkup &markup) const = 0;
|
not_null<History*> history,
|
||||||
virtual QString getErrorOnSend(const Result *owner, History *history) const = 0;
|
MTPDmessage::Flags flags,
|
||||||
|
MsgId msgId,
|
||||||
|
UserId fromId,
|
||||||
|
MTPint mtpDate,
|
||||||
|
UserId viaBotId,
|
||||||
|
MsgId replyToId,
|
||||||
|
const QString &postAuthor,
|
||||||
|
const MTPReplyMarkup &markup) const = 0;
|
||||||
|
virtual QString getErrorOnSend(
|
||||||
|
const Result *owner,
|
||||||
|
not_null<History*> history) const = 0;
|
||||||
|
|
||||||
virtual bool hasLocationCoords() const {
|
virtual bool hasLocationCoords() const {
|
||||||
return false;
|
return false;
|
||||||
|
@ -69,11 +79,21 @@ public:
|
||||||
};
|
};
|
||||||
virtual SentMTPMessageFields getSentMessageFields() const = 0;
|
virtual SentMTPMessageFields getSentMessageFields() const = 0;
|
||||||
|
|
||||||
void addToHistory(const Result *owner, History *history,
|
void addToHistory(
|
||||||
MTPDmessage::Flags flags, MsgId msgId, UserId fromId, MTPint mtpDate,
|
const Result *owner,
|
||||||
UserId viaBotId, MsgId replyToId, const QString &postAuthor, const MTPReplyMarkup &markup) const override;
|
not_null<History*> history,
|
||||||
|
MTPDmessage::Flags flags,
|
||||||
|
MsgId msgId,
|
||||||
|
UserId fromId,
|
||||||
|
MTPint mtpDate,
|
||||||
|
UserId viaBotId,
|
||||||
|
MsgId replyToId,
|
||||||
|
const QString &postAuthor,
|
||||||
|
const MTPReplyMarkup &markup) const override;
|
||||||
|
|
||||||
QString getErrorOnSend(const Result *owner, History *history) const override;
|
QString getErrorOnSend(
|
||||||
|
const Result *owner,
|
||||||
|
not_null<History*> history) const override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -190,11 +210,21 @@ public:
|
||||||
return _photo != nullptr;
|
return _photo != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addToHistory(const Result *owner, History *history,
|
void addToHistory(
|
||||||
MTPDmessage::Flags flags, MsgId msgId, UserId fromId, MTPint mtpDate,
|
const Result *owner,
|
||||||
UserId viaBotId, MsgId replyToId, const QString &postAuthor, const MTPReplyMarkup &markup) const override;
|
not_null<History*> history,
|
||||||
|
MTPDmessage::Flags flags,
|
||||||
|
MsgId msgId,
|
||||||
|
UserId fromId,
|
||||||
|
MTPint mtpDate,
|
||||||
|
UserId viaBotId,
|
||||||
|
MsgId replyToId,
|
||||||
|
const QString &postAuthor,
|
||||||
|
const MTPReplyMarkup &markup) const override;
|
||||||
|
|
||||||
QString getErrorOnSend(const Result *owner, History *history) const override;
|
QString getErrorOnSend(
|
||||||
|
const Result *owner,
|
||||||
|
not_null<History*> history) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PhotoData *_photo;
|
PhotoData *_photo;
|
||||||
|
@ -214,11 +244,21 @@ public:
|
||||||
return _document != nullptr;
|
return _document != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addToHistory(const Result *owner, History *history,
|
void addToHistory(
|
||||||
MTPDmessage::Flags flags, MsgId msgId, UserId fromId, MTPint mtpDate,
|
const Result *owner,
|
||||||
UserId viaBotId, MsgId replyToId, const QString &postAuthor, const MTPReplyMarkup &markup) const override;
|
not_null<History*> history,
|
||||||
|
MTPDmessage::Flags flags,
|
||||||
|
MsgId msgId,
|
||||||
|
UserId fromId,
|
||||||
|
MTPint mtpDate,
|
||||||
|
UserId viaBotId,
|
||||||
|
MsgId replyToId,
|
||||||
|
const QString &postAuthor,
|
||||||
|
const MTPReplyMarkup &markup) const override;
|
||||||
|
|
||||||
QString getErrorOnSend(const Result *owner, History *history) const override;
|
QString getErrorOnSend(
|
||||||
|
const Result *owner,
|
||||||
|
not_null<History*> history) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DocumentData *_document;
|
DocumentData *_document;
|
||||||
|
@ -237,11 +277,21 @@ public:
|
||||||
return _game != nullptr;
|
return _game != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addToHistory(const Result *owner, History *history,
|
void addToHistory(
|
||||||
MTPDmessage::Flags flags, MsgId msgId, UserId fromId, MTPint mtpDate,
|
const Result *owner,
|
||||||
UserId viaBotId, MsgId replyToId, const QString &postAuthor, const MTPReplyMarkup &markup) const override;
|
not_null<History*> history,
|
||||||
|
MTPDmessage::Flags flags,
|
||||||
|
MsgId msgId,
|
||||||
|
UserId fromId,
|
||||||
|
MTPint mtpDate,
|
||||||
|
UserId viaBotId,
|
||||||
|
MsgId replyToId,
|
||||||
|
const QString &postAuthor,
|
||||||
|
const MTPReplyMarkup &markup) const override;
|
||||||
|
|
||||||
QString getErrorOnSend(const Result *owner, History *history) const override;
|
QString getErrorOnSend(
|
||||||
|
const Result *owner,
|
||||||
|
not_null<History*> history) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GameData *_game;
|
GameData *_game;
|
||||||
|
|
|
@ -2018,7 +2018,8 @@ void MainWidget::insertCheckedServiceNotification(const TextWithEntities &messag
|
||||||
MTPint(),
|
MTPint(),
|
||||||
MTPint(),
|
MTPint(),
|
||||||
MTPstring(),
|
MTPstring(),
|
||||||
MTPlong()), NewMessageUnread);
|
MTPlong()),
|
||||||
|
NewMessageUnread);
|
||||||
}
|
}
|
||||||
if (item) {
|
if (item) {
|
||||||
_history->peerMessagesUpdated(item->history()->peer->id);
|
_history->peerMessagesUpdated(item->history()->peer->id);
|
||||||
|
@ -4825,7 +4826,8 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
|
||||||
QString text;
|
QString text;
|
||||||
App::histSentDataByItem(randomId, peerId, text);
|
App::histSentDataByItem(randomId, peerId, text);
|
||||||
|
|
||||||
auto wasAlready = peerId && (App::histItemById(peerToChannel(peerId), d.vid.v) != nullptr);
|
const auto wasAlready = (peerId != 0)
|
||||||
|
&& (App::histItemById(peerToChannel(peerId), d.vid.v) != nullptr);
|
||||||
feedUpdate(MTP_updateMessageID(d.vid, MTP_long(randomId))); // ignore real date
|
feedUpdate(MTP_updateMessageID(d.vid, MTP_long(randomId))); // ignore real date
|
||||||
if (peerId) {
|
if (peerId) {
|
||||||
if (auto item = App::histItemById(peerToChannel(peerId), d.vid.v)) {
|
if (auto item = App::histItemById(peerToChannel(peerId), d.vid.v)) {
|
||||||
|
@ -4835,17 +4837,13 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
|
||||||
item->id,
|
item->id,
|
||||||
ApiWrap::RequestMessageDataCallback());
|
ApiWrap::RequestMessageDataCallback());
|
||||||
}
|
}
|
||||||
auto entities = d.has_entities() ? TextUtilities::EntitiesFromMTP(d.ventities.v) : EntitiesInText();
|
const auto entities = d.has_entities()
|
||||||
|
? TextUtilities::EntitiesFromMTP(d.ventities.v)
|
||||||
|
: EntitiesInText();
|
||||||
item->setText({ text, entities });
|
item->setText({ text, entities });
|
||||||
item->updateMedia(d.has_media() ? (&d.vmedia) : nullptr);
|
item->updateMedia(d.has_media() ? (&d.vmedia) : nullptr);
|
||||||
item->addToUnreadMentions(AddToUnreadMentionsMethod::New);
|
|
||||||
if (!wasAlready) {
|
if (!wasAlready) {
|
||||||
if (auto sharedMediaTypes = item->sharedMediaTypes()) {
|
item->indexAsNewItem();
|
||||||
Auth().storage().add(Storage::SharedMediaAddNew(
|
|
||||||
peerId,
|
|
||||||
sharedMediaTypes,
|
|
||||||
item->id));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,9 +86,9 @@ void SharedMedia::remove(SharedMediaRemoveOne &&query) {
|
||||||
auto type = static_cast<SharedMediaType>(index);
|
auto type = static_cast<SharedMediaType>(index);
|
||||||
if (query.types.test(type)) {
|
if (query.types.test(type)) {
|
||||||
peerIt->second[index].removeOne(query.messageId);
|
peerIt->second[index].removeOne(query.messageId);
|
||||||
_oneRemoved.fire(std::move(query));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_oneRemoved.fire(std::move(query));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue