Skip to content

Commit

Permalink
Beim Klick auf "Reply" scrollen (#504)
Browse files Browse the repository at this point in the history
* Adds scroll reply message by click
loading messages if necessary

Co-authored-by: antonykamp <[email protected]>

* Add Tests

Co-authored-by: antonykamp <[email protected]>

* Fix lint

Co-authored-by: lucasderreisende <[email protected]>

* Revert UI tests deletion

Co-authored-by: lucasderreisende <[email protected]>

* Fix lint (again)

* adapt to new tdlib version

Co-authored-by: lucasderreisende <[email protected]>

Co-authored-by: antonykamp <[email protected]>
Co-authored-by: Antony Kmap <[email protected]>
Co-authored-by: Richard Wohlbold <[email protected]>
  • Loading branch information
4 people authored Jul 1, 2022
1 parent 9b71702 commit a8588ff
Show file tree
Hide file tree
Showing 73 changed files with 420 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ loading
chatHistoryReceived: anEvent

(anEvent at: 'messages') do:
[:message | self addOldestMessage: (TCCMessage newFromMessageEvent: message in: self with: self core)].
[:message | self addOldestMessage: (TCCMessage newFromMessageEvent: message in: self with: self core).
self fulfillMessageRequest: (message at: 'id').
].

(self requestedMessages isEmpty) ifFalse: [self increaseNumberOfRequestedMessages.].

self waitingForUpdate: false.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
loading
fulfillMessageRequest: aMessageId

| fulfilledMessageRequests |

fulfilledMessageRequests := self requestedMessages select: [:req | req messageId = aMessageId].
fulfilledMessageRequests do: [:messageRequest | messageRequest completeRequest.].

self requestedMessages removeAll: fulfilledMessageRequests.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
controlling
handleMessageRequest: aMessageRequest

((self messageIds occurrencesOf: (aMessageRequest messageId)) ~= 0) ifTrue:
[aMessageRequest completeRequest.]
ifFalse:
[self requestedMessages add: aMessageRequest.
self loadChatHistory.]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
loading
increaseNumberOfRequestedMessages

self numberOfRequestedMessages: self numberOfRequestedMessages + self class defaultMessageLimit.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ initialize
position: self class defaultUnknownPosition;
numberOfRequestedMessages: self class defaultNumberOfRequestedMessages;
selectedReplyToMessageId: self class defaultSelectedReplyToMessageId;
isPinned: false.
requestedMessages: OrderedCollection new;
isPinned: false.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
requestedMessages: aList

requestedMessages := aList
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
requestedMessages

^ requestedMessages
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
stillRequestedMessages

^ self numberOfRequestedMessages - self numberOfMessages
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@
"instance" : {
"addAnsweredMessage:" : "JS 5/26/2022 16:41",
"addNewestMessage:" : "JS 5/26/2022 14:22",
"addOldestMessage:" : "JS 5/26/2022 14:23",
"addOldestMessage:" : "LR 6/11/2022 16:17",
"canSendMessages" : "5/11/2021 10:09:15",
"canSendMessages:" : "JB 8/4/2021 00:08",
"chatHistoryReceived:" : "rgw 5/12/2022 14:04",
"chatHistoryReceived:" : "aka 6/15/2022 11:52",
"core" : "per 6/4/2021 16:00",
"core:" : "per 6/4/2021 15:58",
"fulfillMessageRequest:" : "LR 6/15/2022 10:11",
"getMessageById:" : "JS 5/26/2022 14:49",
"handleMessageRequest:" : "LR 6/15/2022 11:14",
"hasPhoto" : "rgw 6/2/2022 15:20",
"id" : "rs 6/7/2020 22:20",
"id:" : "pk 8/4/2021 11:25",
"ifNotWaitingForUpdate:" : "js 8/2/2020 13:17",
"ifNotWaitingForUpdate:" : "LR 6/15/2022 10:12",
"increaseNumberOfRequestedMessages" : "LR 6/15/2022 10:12",
"infoLoaded" : "per 6/4/2021 15:59",
"infoLoaded:" : "per 6/4/2021 15:51",
"initialize" : "js 6/18/2022 10:48",
Expand All @@ -35,7 +38,7 @@
"lastMessage" : "rs 6/19/2020 17:33",
"lastMessage:" : "pk 8/4/2021 10:56",
"lastMessageId" : "JB 8/4/2021 00:10",
"loadChatHistory" : "RS 7/17/2021 11:49",
"loadChatHistory" : "LR 6/12/2022 17:48",
"loadInfo" : "per 6/15/2021 09:49",
"loadInfoIfNotLoaded" : "TR 6/13/2021 15:54",
"messageDictionary" : "JS 5/26/2022 14:19",
Expand All @@ -54,11 +57,13 @@
"position:" : "pk 8/6/2021 18:59",
"positionKnown" : "pk 8/6/2021 18:25",
"requestMessage:" : "JS 5/26/2022 14:48",
"requestMessages:" : "RS 7/31/2021 15:28",
"requestMessages:" : "LR 6/15/2022 10:12",
"requestedMessages" : "aka 6/15/2022 11:52",
"requestedMessages:" : "aka 6/15/2022 11:52",
"selectedReplyToMessageId" : "JS 5/20/2022 09:50",
"selectedReplyToMessageId:" : "JS 5/20/2022 11:38",
"sendMessage:" : "JS 5/20/2022 10:06",
"stillRequestedMessages" : "js 8/1/2020 18:05",
"stillRequestedMessages" : "LR 6/15/2022 10:12",
"title" : "rs 6/7/2020 22:24",
"title:" : "5/11/2021 10:09:15",
"waitingForUpdate" : "5/11/2021 10:09:15",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
"messageIds",
"messageDictionary",
"selectedReplyToMessageId",
"photoId",
"isPinned" ],
"requestedMessages",
"photoId",
"isPinned"],
"name" : "TCCChat",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"freeClient" : "6/9/2021 14:12:18",
"generateCallbackId" : "pk 8/5/2021 17:04",
"getOwnProfile" : "pk 8/5/2021 17:05",
"handleEvent:" : "rgw 6/2/2022 08:57",
"handleEvent:" : "LR 6/12/2022 14:28",
"handleMessageEvent:" : "rgw 5/12/2022 13:44",
"handlePendingEvent:" : "per 8/2/2021 15:05",
"imageStore" : "pk 6/19/2021 17:15",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"class" : {
"downloadUrl" : "r.s 7/13/2020 17:05",
"fileName" : "r.s 7/13/2020 17:05",
"moduleName" : "pk 8/5/2021 21:31",
"moduleName" : "LR 6/5/2022 11:00",
"newForCurrentOs" : "pk 8/5/2021 17:09" },
"instance" : {
"create" : "js 6/13/2020 12:53",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"isOutgoing" : "js 8/2/2020 22:00",
"isOutgoing:" : "pk 8/4/2021 11:42",
"isReply" : "rgw 5/12/2022 15:40",
"replyText" : "rgw 5/12/2022 15:35",
"replyText" : "LR 6/5/2022 11:12",
"replyToMessageId" : "rgw 5/12/2022 13:43",
"replyToMessageId:" : "rgw 5/12/2022 13:43",
"senderName" : "JS 6/11/2022 09:50",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Class with the id of a requested message. If request is completed, execute the completionMessage on the completionReceiver.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
completeRequest

self completionReceiver perform: (self completionMessage) with: (self messageId)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
completionMessage: aMessage

completionMessage := aMessage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
completionMessage

^ completionMessage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
completionReceiver: aReceiver

completionReceiver := aReceiver
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
completionReceiver

^ completionReceiver
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
messageId: aNumber

messageId := aNumber
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
messageId

^ messageId
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"class" : {
},
"instance" : {
"completeRequest" : "LR 6/5/2022 13:05",
"completionMessage" : "aka 6/15/2022 11:45",
"completionMessage:" : "aka 6/15/2022 11:45",
"completionReceiver" : "aka 6/15/2022 11:46",
"completionReceiver:" : "aka 6/15/2022 11:46",
"messageId" : "aka 6/15/2022 11:47",
"messageId:" : "aka 6/15/2022 11:47" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"category" : "TelegramClient-Core",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "aka 6/15/2022 12:07",
"instvars" : [
"messageId",
"completionReceiver",
"completionMessage" ],
"name" : "TCCMessageRequest",
"pools" : [
],
"super" : "Object",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"class" : {
"downloadArchive" : "pk 8/6/2021 15:28",
"downloadArchive" : "LR 6/5/2022 11:05",
"downloadUrl" : "rgw 6/13/2022 10:35",
"fileName" : "f.w. 7/15/2020 22:04",
"moduleName" : "js 8/2/2020 13:21" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
messages
addAtBottom: aCoreMessage

| wrapper wasFullyScrolledDown |
| wrapper wasFullyScrolledDown messageItem |

(self isFromCurrentChat: aCoreMessage)
ifFalse: [ ^ self ].
wasFullyScrolledDown := self isFullyScrolledDown.
wrapper := TCUMessageWrapper newFromMessage: (TCUMessage newFrom: aCoreMessage) withWidth: self scroller width.
messageItem := TCUMessage newFrom: aCoreMessage.
messageItem when: #requestScroll send: #requestScrollToMessage: to: self with: (aCoreMessage replyToMessageId).
wrapper := TCUMessageWrapper newFromMessage: messageItem withWidth: self scroller width.
self scroller addMorphBack: wrapper.
self items addLast: wrapper.
wasFullyScrolledDown
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
messages
addAtTop: aCoreMessage

| wrapper |
| wrapper messageItem |
(self isFromCurrentChat: aCoreMessage) ifFalse: [^ self].

wrapper := TCUMessageWrapper newFromMessage: (TCUMessage newFrom: aCoreMessage) withWidth: self scroller width.
messageItem := TCUMessage newFrom: aCoreMessage.
messageItem when: #requestScroll send: #requestScrollToMessage: to: self with: (aCoreMessage replyToMessageId).
wrapper := TCUMessageWrapper newFromMessage: messageItem withWidth: self scroller width.
self scroller addMorphFront: wrapper.
self items addFirst: wrapper.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
messages
requestScrollToMessage: aMessageId

| messageRequest |
messageRequest := TCCMessageRequest new messageId: aMessageId;
completionReceiver: self;
completionMessage: #scrollToMessage:;
yourself.
self chat handleMessageRequest: messageRequest
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
drawing
scrollToMessage: aMessageId

| messageItem messageIndex |
messageIndex := self chat messageIds reversed indexOf: aMessageId.
messageItem := self items at: messageIndex.
self scrollToShow: messageItem
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"defaultScrollOffsetBeforeLoading" : "JB 6/26/2021 10:15",
"defaultWidth" : "rgw 6/2/2022 15:39" },
"instance" : {
"addAtBottom:" : "JS 6/11/2022 11:14",
"addAtTop:" : "JS 6/11/2022 11:15",
"addAtBottom:" : "LR 6/11/2022 10:45",
"addAtTop:" : "LR 6/11/2022 11:00",
"addMessages" : "RS 7/17/2021 17:40",
"chat" : "js 7/31/2020 16:39",
"chat:" : "js 7/31/2020 16:39",
Expand All @@ -13,6 +13,8 @@
"initialize" : "RS 7/17/2021 17:40",
"isFromCurrentChat:" : "pk 8/5/2021 17:07",
"isFullyScrolledDown" : "JB 8/4/2021 11:15",
"requestScrollToMessage:" : "aka 6/15/2022 11:56",
"scrollToMessage:" : "aka 6/15/2022 12:01",
"scrollToNewestMessage" : "per 6/24/2021 23:14",
"showMessages" : "RS 7/17/2021 17:34",
"step" : "JB 7/19/2021 12:12" } }
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"defaultMinimumEmojiAmount" : "pk 7/17/2021 10:18",
"defaultOptionalCharacters" : "pk 7/6/2021 09:49",
"defaultTextHeight" : "7/17/2021 09:37:29",
"downloadArchive" : "pk 7/17/2021 09:49",
"downloadArchive" : "LR 6/5/2022 11:05",
"downloadUrl" : "RK 6/29/2021 11:30",
"embedEmojisInto:" : "pk 7/11/2021 19:17",
"emojiExists:" : "pk 7/11/2021 19:20",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
constructing
addReplySnippet

self addMorphBack: (self class defaultTextMorph
contents: self messageModel replyText;
hResizing: #spaceFill;
color: TCUDefaultValues colorLightGray;
yourself).
| replySnippet |

replySnippet := TCUReplySnippet newWith: (self messageModel replyText) coloredIn: self messageColor.
replySnippet when: #requestScroll send: #triggerRequestScroll to: self.

self addMorph: (replySnippet).
self addMorphBack: (RectangleMorph new
color: self messageColor;
borderWidth: 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
initialization
mouseDown: anEvent

^ self messageModel chat selectedReplyToMessageId: self messageModel id
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constructing
triggerRequestScroll

self triggerEvent: #requestScroll
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"class" : {
"defaultBottomMargin" : "JB 5/30/2021 11:27",
"defaultHeight" : "JB 5/29/2021 20:44",
"defaultLayoutInset" : "JB 5/29/2021 21:08",
"defaultLayoutInset" : "LR 6/11/2022 11:40",
"defaultMargins" : "JB 6/11/2021 18:36",
"defaultPhotoSize" : "JS 6/11/2022 09:55",
"defaultTextMorph" : "rgw 6/16/2022 15:47",
Expand All @@ -11,21 +11,24 @@
"instance" : {
"addContent" : "TR 6/20/2021 11:12",
"addDate" : "rgw 5/12/2022 15:54",
"addReplySnippet" : "rgw 5/12/2022 15:54",
"addReplySnippet" : "LR 6/15/2022 11:21",
"addSender" : "rgw 5/12/2022 15:54",
"addText" : "RK 6/23/2021 11:46",
"answeredMessageReceived" : "rgw 6/2/2022 10:29",
"date" : "TR 6/20/2021 10:59",
"initialize" : "rgw 6/2/2022 10:45",
"initialize" : "LR 6/11/2022 13:01",
"initializeDefaults" : "JS 6/11/2022 11:00",
"initializeSubmorphs" : "rgw 6/2/2022 10:26",
"isOutgoing" : "TR 6/20/2021 11:37",
"messageColor" : "JB 5/29/2021 21:06",
"messageDateText" : "JB 5/17/2021 10:04",
"messageModel" : "TR 6/20/2021 11:00",
"messageModel:" : "JS 5/26/2022 16:40",
"mouseDown:" : "JS 5/20/2022 09:52",
"mouseDown:" : "LR 6/5/2022 10:57",
"secondaryColor" : "rgw 5/12/2022 15:54",
"shrinkToContent" : "RK 8/4/2021 11:58",
"sender" : "TR 6/20/2021 10:59",
"senderId" : "8/5/2021 21:14:18",
"shrinkToContent" : "LR 6/11/2022 12:38",
"text" : "RK 6/29/2021 11:18",
"triggerRequestScroll" : "LR 6/5/2022 12:45",
"updateReplySnippet" : "rgw 6/2/2022 10:29" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Show the reply snippet on top of a referencing message.
Loading

0 comments on commit a8588ff

Please sign in to comment.