MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / refreshMessage

Method refreshMessage

Telegram/SourceFiles/data/data_groups.cpp:79–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79void Groups::refreshMessage(
80 not_null<HistoryItem*> item,
81 bool justRefreshViews) {
82 if (!isGrouped(item)) {
83 unregisterMessage(item);
84 _data->requestItemViewRefresh(item);
85 return;
86 }
87 if (!item->isRegular() && !item->isScheduled() && !item->isUploading()) {
88 return;
89 }
90 const auto groupId = item->groupId();
91 const auto i = _groups.find(groupId);
92 if (i == end(_groups)) {
93 registerMessage(item);
94 return;
95 }
96 auto &items = i->second.items;
97
98 if (justRefreshViews) {
99 refreshViews(items);
100 return;
101 }
102
103 const auto position = findPositionForItem(items, item);
104 auto current = ranges::find(items, item);
105 if (current == end(items)) {
106 items.insert(position, item);
107 } else if (position == current + 1) {
108 return;
109 } else if (position > current + 1) {
110 for (++current; current != position; ++current) {
111 std::swap(*(current - 1), *current);
112 }
113 } else if (position < current) {
114 for (; current != position; --current) {
115 std::swap(*(current - 1), *current);
116 }
117 } else {
118 Unexpected("Position of item in Groups::refreshMessage().");
119 }
120 refreshViews(items);
121}
122
123HistoryItemsList::const_iterator Groups::findPositionForItem(
124 const HistoryItemsList &group,

Callers 4

EditCaptionBoxFunction · 0.80
returnSavedMediaMethod · 0.80
setRealIdMethod · 0.80
refreshSentMediaMethod · 0.80

Calls 7

isRegularMethod · 0.80
isScheduledMethod · 0.80
isUploadingMethod · 0.80
groupIdMethod · 0.80
findMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected