| 158 | } |
| 159 | |
| 160 | void SetChatLinkDraft(not_null<PeerData*> peer, TextWithEntities draft) { |
| 161 | static const auto kInlineStart = QRegularExpression("^@[a-zA-Z0-9_]"); |
| 162 | if (kInlineStart.match(draft.text).hasMatch()) { |
| 163 | draft = TextWithEntities().append(' ').append(std::move(draft)); |
| 164 | } |
| 165 | |
| 166 | const auto textWithTags = TextWithTags{ |
| 167 | draft.text, |
| 168 | TextUtilities::ConvertEntitiesToTextTags(draft.entities) |
| 169 | }; |
| 170 | const auto cursor = MessageCursor{ |
| 171 | int(textWithTags.text.size()), |
| 172 | int(textWithTags.text.size()), |
| 173 | Ui::kQFixedMax |
| 174 | }; |
| 175 | const auto history = peer->owner().history(peer->id); |
| 176 | const auto topicRootId = MsgId(); |
| 177 | const auto monoforumPeerId = PeerId(); |
| 178 | history->setLocalDraft(std::make_unique<Draft>( |
| 179 | textWithTags, |
| 180 | FullReplyTo{ |
| 181 | .topicRootId = topicRootId, |
| 182 | .monoforumPeerId = monoforumPeerId, |
| 183 | }, |
| 184 | SuggestOptions(), |
| 185 | cursor, |
| 186 | WebPageDraft())); |
| 187 | history->clearLocalEditDraft(topicRootId, monoforumPeerId); |
| 188 | history->session().changes().entryUpdated( |
| 189 | history, |
| 190 | EntryUpdate::Flag::LocalDraftSet); |
| 191 | } |
| 192 | |
| 193 | } // namespace Data |
no test coverage detected