Skip to content

Commit 697d8a4

Browse files
committed
.
1 parent a406046 commit 697d8a4

2 files changed

Lines changed: 32 additions & 11 deletions

File tree

TMessagesProj/src/main/java/org/telegram/messenger/forkgram/AsCopyUtils.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ fun PerformForwardFromMyName(
6464
currentAccount: Int,
6565
parentFragment: BaseFragment?,
6666
notify: Boolean) {
67+
val isMonoForum = MessagesController.getInstance(currentAccount).isMonoForum(key)
68+
val monoForumPeerId = if (keyTopic != null && isMonoForum) DialogObject.getPeerDialogId(keyTopic.from_id) else 0L
6769

6870
val queue = ArrayList<() -> Unit>();
6971
val saveOriginalCaptions = (text == null)
@@ -101,6 +103,7 @@ fun PerformForwardFromMyName(
101103
parentFragment,
102104
copyText,
103105
notify,
106+
monoForumPeerId,
104107
deque)
105108
}
106109
}
@@ -122,7 +125,7 @@ fun PerformForwardFromMyName(
122125
val copyText = currentReplaceText();
123126
queue.add {
124127
val instance = SendMessagesHelper.getInstance(currentAccount);
125-
instance.processForwardFromMyName(copyMsg, key, 0, topicId, null, copyText, notify, topicId)
128+
instance.processForwardFromMyName(copyMsg, key, 0, 0, null, copyText, notify, topicId, monoForumPeerId)
126129
deque();
127130
}
128131
}
@@ -140,7 +143,8 @@ fun GroupItemsIntoAlbum(
140143
sendingMessageObjects: ArrayList<MessageObject>,
141144
currentAccount: Int,
142145
parentFragment: BaseFragment?,
143-
notify: Boolean) {
146+
notify: Boolean,
147+
monoForumPeerId: Long = 0L) {
144148
if (sendingMessageObjects.isEmpty()) {
145149
return;
146150
}
@@ -153,7 +157,7 @@ fun GroupItemsIntoAlbum(
153157
val objectsToDelay = sub(objectsToSend.size, sendingMessageObjects.size);
154158

155159
val finish = {
156-
GroupItemsIntoAlbum(key, reply, text, objectsToDelay, currentAccount, parentFragment, notify)
160+
GroupItemsIntoAlbum(key, reply, text, objectsToDelay, currentAccount, parentFragment, notify, monoForumPeerId)
157161
};
158162

159163
SendItemsAsAlbum(
@@ -164,6 +168,7 @@ fun GroupItemsIntoAlbum(
164168
parentFragment,
165169
text,
166170
notify,
171+
monoForumPeerId,
167172
finish)
168173
}
169174

@@ -211,12 +216,13 @@ fun SendItemsAsAlbum(
211216
fragment: BaseFragment?,
212217
replaceText: String?,
213218
notify: Boolean,
219+
monoForumPeerId: Long = 0L,
214220
finish: () -> Unit) {
215221
if (peer == 0L || messages.size > 10 || messages.isEmpty()) {
216222
return
217223
}
218224
val accountInstance = AccountInstance.getInstance(currentAccount)
219-
val lower_id = peer
225+
val lower_id = if (monoForumPeerId != 0L) monoForumPeerId else peer
220226
val sendToPeer: InputPeer =
221227
(if (lower_id != 0L) accountInstance.messagesController.getInputPeer(lower_id)
222228
else null)
@@ -306,7 +312,7 @@ fun SendItemsAsAlbum(
306312
showToast("Sorry, something went wrong.");
307313
return@handleMessages
308314
}
309-
SendItemsAsAlbum(currentAccount, messages, peer, reply, fragment, replaceText, notify, finish)
315+
SendItemsAsAlbum(currentAccount, messages, peer, reply, fragment, replaceText, notify, monoForumPeerId, finish)
310316
}
311317

312318
ForkApi.TLRPCMessages(currentAccount, messages, handleMessages);

TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,11 +1809,17 @@ public int getFillColor() {
18091809
: "")
18101810
: null;
18111811
if (hasComment && !nonText) {
1812-
SendMessagesHelper.getInstance(account).sendMessage(SendMessagesHelper.SendMessageParams.of(
1812+
boolean isMonoForum = MessagesController.getInstance(account).isMonoForum(key);
1813+
long monoForumPeerId = keyTopic != null && isMonoForum ? DialogObject.getPeerDialogId(keyTopic.from_id) : 0;
1814+
MessageObject replyTopMsg = keyTopic != null && !isMonoForum ? new MessageObject(account, keyTopic.topicStartMessage, false, false) : null;
1815+
if (replyTopMsg != null) {
1816+
replyTopMsg.isTopicMainMessage = true;
1817+
}
1818+
SendMessagesHelper.SendMessageParams params = SendMessagesHelper.SendMessageParams.of(
18131819
commentTextView.getText().toString(),
18141820
key,
1815-
null,
1816-
null,
1821+
replyTopMsg,
1822+
replyTopMsg,
18171823
null,
18181824
true,
18191825
null,
@@ -1822,17 +1828,26 @@ public int getFillColor() {
18221828
notify,
18231829
0,
18241830
null,
1825-
false));
1831+
false);
1832+
params.monoForumPeer = monoForumPeerId;
1833+
SendMessagesHelper.getInstance(account).sendMessage(params);
18261834
}
18271835
if (groupAnyItems) {
1836+
boolean isMonoForum = MessagesController.getInstance(account).isMonoForum(key);
1837+
long monoForumPeerId = keyTopic != null && isMonoForum ? DialogObject.getPeerDialogId(keyTopic.from_id) : 0;
1838+
int replyId = AsCopy.TakeReplyToDraft(key, keyTopic, account, true);
1839+
if (replyId == 0 && keyTopic != null && !isMonoForum) {
1840+
replyId = keyTopic.id;
1841+
}
18281842
AsCopy.GroupItemsIntoAlbum(
18291843
key,
1830-
AsCopy.TakeReplyToDraft(key, keyTopic, account, true),
1844+
replyId,
18311845
maybeReplaceText,
18321846
sendingMessageObjects,
18331847
account,
18341848
parentFragment,
1835-
notify);
1849+
notify,
1850+
monoForumPeerId);
18361851
onSend(selectedDialogs, selectedDialogs.size(), keyTopic, info);
18371852
dismiss();
18381853
return;

0 commit comments

Comments
 (0)