Skip to content

Commit

Permalink
Merge pull request #542 from hpi-swa-teaching/fix/overlapping-messages
Browse files Browse the repository at this point in the history
Make reply snippet update synchronous
  • Loading branch information
kohlros authored Aug 5, 2022
2 parents c8ea738 + 59c0421 commit 148c4f0
Show file tree
Hide file tree
Showing 28 changed files with 74 additions and 74 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
adding
addMessage: aMessage

self messageDictionary at: aMessage id ifAbsent: [
self messageDictionary at: aMessage id put: Promise new
].
(self messageDictionary at: aMessage id) resolveWith: aMessage
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ addNewestMessage: aMessage
(newDate > oldDate) ifTrue: [
aMessage isFirstMessageOfDay: true.
self lastMessage isLastMessageOfDay: true.
].
].
self messageIds ifEmpty: [aMessage isFirstMessageOfDay: false].
self messageIds addFirst: aMessage id.
self messageDictionary at: aMessage id put: aMessage.
self addMessage: aMessage.
self triggerEvent: #newMessage with: aMessage.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ addOldestMessage: aMessage
self oldestLoadedMessage isFirstMessageOfDay: true.
aMessage isLastMessageOfDay: true].
self messageIds add: aMessage id.
self messageDictionary at: aMessage id put: aMessage.
self addMessage: aMessage.
self triggerEvent: #loadedMessage with: aMessage.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
accessing
getMessageById: aNumber

^ self messageDictionary at: aNumber ifAbsent: [
self requestMessage: aNumber.
^TCCNotLoadedMessage new]
^ (self messageDictionary at: aNumber ifAbsent: [
self messageDictionary at: aNumber put: Promise new.
self requestMessage: aNumber.
self messageDictionary at: aNumber.
])
wait;
value
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
accessing
messages

^ self messageIds collect: [:aNumber | self messageDictionary at: aNumber]
^ self messageIds collect: [:aNumber |
(self messageDictionary at: aNumber)
wait;
value
]
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
"defaultUnknownPosition" : "RS 8/6/2021 10:38",
"newFromChatEvent:" : "RS 7/17/2021 17:07" },
"instance" : {
"addAnsweredMessage:" : "JS 5/26/2022 16:41",
"addNewestMessage:" : "js 8/4/2022 20:54",
"addOldestMessage:" : "aka 7/14/2022 14:26",
"addMessage:" : "rgw 8/5/2022 09:22",
"addNewestMessage:" : "rgw 8/5/2022 11:24",
"addOldestMessage:" : "rgw 8/5/2022 09:23",
"canSendMessages" : "5/11/2021 10:09:15",
"canSendMessages:" : "JB 8/4/2021 00:08",
"chatHistoryReceived:" : "js 7/31/2022 09:28",
"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",
"getMessageById:" : "rgw 8/5/2022 09:25",
"handleMessageRequest:" : "LR 6/15/2022 11:14",
"hasPhoto" : "rgw 6/2/2022 15:20",
"id" : "rs 6/7/2020 22:20",
Expand Down Expand Up @@ -53,7 +53,7 @@
"messageDictionary:" : "JS 5/26/2022 14:20",
"messageIds" : "JS 5/26/2022 14:20",
"messageIds:" : "JS 5/26/2022 14:20",
"messages" : "JS 5/26/2022 14:35",
"messages" : "rgw 8/5/2022 09:25",
"muted" : "per 6/16/2021 17:34",
"muted:" : "JB 8/4/2021 00:07",
"numberOfMessages" : "RS 7/31/2021 15:19",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ answeredMessageReceived: aJsonObject
chat := self chats getChat: (aJsonObject at: 'chat_id').
message := TCCMessage newFromMessageEvent: aJsonObject in: chat with: self core.

chat addAnsweredMessage: message.
chat addMessage: message.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"instance" : {
"addChat:" : "js 6/18/2022 09:27",
"addNewMessage:" : "js 7/31/2022 09:28",
"answeredMessageReceived:" : "js 7/31/2022 09:28",
"answeredMessageReceived:" : "rgw 8/5/2022 09:22",
"chatHistoryReceived:" : "pk 8/5/2021 16:37",
"chats" : "RS 8/1/2021 12:50",
"chats:" : "RS 8/1/2021 12:51",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@
"secondaryColor" : "rgw 5/12/2022 15:54",
"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" } }
"triggerRequestScroll" : "LR 6/5/2022 12:45" } }

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
testing
testAddMessage

| message |
message := TCCTextMessage new id: 13.
self chat addMessage: message.
self assert: 5 equals: self chat messages size.
self assert: message equals: (self chat getMessageById: 13)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@ testGetMessageById
| message |

message := self chat getMessageById: 16.
self assert: '4' equals: message asText.

message := self chat getMessageById: 17.
self assert: TCCNotLoadedMessage infoText equals: message asReplySnippet.
self assert: '4' equals: message asText
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ testMessages
messages := OrderedCollection newFrom: {message1. message2}.

self chat messageIds: messageIds.
self chat messageDictionary at: message1 id put: message1.
self chat messageDictionary at: message2 id put: message2.
self chat addMessage: message1.
self chat addMessage: message2.

self assert: messageIds equals: self chat messageIds.
self assert: message1 equals: (self chat messageDictionary at: message1 id).
self assert: message2 equals: (self chat messageDictionary at: message2 id).
self assert: message1 equals: (self chat messageDictionary at: message1 id) value.
self assert: message2 equals: (self chat messageDictionary at: message2 id) value.
self assert: messages equals: self chat messages
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"chat" : "LL 8/2/2020 20:25",
"chat:" : "LL 8/2/2020 20:26",
"setUp" : "aka 7/10/2022 12:22",
"testAddAnsweredMessage" : "JS 5/26/2022 15:05",
"testAddMessage" : "rgw 8/5/2022 09:47",
"testAddNewestMessage" : "aka 7/10/2022 12:30",
"testAddOldestMessage" : "aka 7/10/2022 12:31",
"testChatCorrectlyConstructedFromJson" : "js 6/18/2022 10:46",
"testChatNoPhotoCorrectlyConstructedFromJson" : "rgw 6/2/2022 16:17",
"testGetMessageById" : "JS 5/27/2022 19:32",
"testGetMessageById" : "rgw 8/5/2022 09:41",
"testHandleMessageRequest" : "aka 6/15/2022 11:54",
"testHandleMessageRequestAlreadyLoaded" : "aka 6/15/2022 11:59",
"testId" : "pk 8/5/2021 17:13",
Expand All @@ -21,7 +21,7 @@
"testLastMessage" : "aka 7/10/2022 11:12",
"testLastMessageDate" : "aka 7/10/2022 11:42",
"testMessage" : "js 7/31/2022 10:31",
"testMessages" : "JS 5/26/2022 14:37",
"testMessages" : "rgw 8/5/2022 09:42",
"testMessagesSize" : "per 5/21/2021 16:30",
"testNullId" : "pk 8/5/2021 17:13",
"testNullMessages" : "js 8/2/2020 21:17",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ testMessageReplyText
chat := (TCTMMocks mockPrivateChat core: self core).
originalMessage := TCTMMocks mockTextMessageWith: self core inChat: chat.
replyMessage := TCTMMocks mockTextReplyMessageWith: self core inChat: chat.
chat addNewestMessage: replyMessage.

self assert: TCCNotLoadedMessage infoText equals: replyMessage replyText.

chat addNewestMessage: originalMessage.
chat
addNewestMessage: replyMessage;
addNewestMessage: originalMessage.

self assert: replyMessage replyText equals: originalMessage asReplySnippet.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"testMessageHasTextRepresentation" : "tom.richter 6/26/2021 21:06",
"testMessageIsReply" : "rgw 5/12/2022 16:40",
"testMessageReplySnippetTruncates" : "js 7/31/2022 10:29",
"testMessageReplyText" : "LR 6/5/2022 11:14",
"testMessageReplyText" : "rgw 8/5/2022 09:44",
"testMessageShouldNotNotify" : "RS 7/17/2021 10:53",
"testMessageShouldNotify" : "RS 7/17/2021 10:53",
"testMessageWithMessageSenderChatCorrectlyConstructedFromJson" : "js 7/31/2022 10:29",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ mockNotSupportedMessageWith: aCore
userId: self mockUser1 id;
isOutgoing: false;
date: self mockMessageDate;
id: self mockMessageId
id: self mockMessageId;
replyToMessageId: 0
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ mockPhotoMessageWith: aCore
caption: self mockText;
width: self mockPhotoWidth;
height: self mockPhotoHeight;
fileId: self mockImageId
fileId: self mockImageId;
replyToMessageId: 0
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
"mockMessageTimestamp" : "RK 6/25/2021 15:14",
"mockMutedPrivateChat" : "per 6/18/2021 08:55",
"mockNotSupportedMessageJsonFrom:" : "tom.richter 6/28/2021 13:54",
"mockNotSupportedMessageWith:" : "JS 5/27/2022 11:13",
"mockNotSupportedMessageWith:" : "rgw 8/5/2022 10:23",
"mockPhotoHeight" : "tom.richter 6/28/2021 13:57",
"mockPhotoMessageJsonFrom:" : "tom.richter 6/28/2021 15:05",
"mockPhotoMessageWith:" : "JS 5/27/2022 11:13",
"mockPhotoMessageWith:" : "rgw 8/5/2022 10:22",
"mockPhotoWidth" : "tom.richter 6/28/2021 13:57",
"mockPrivateChat" : "LR 7/16/2022 12:03",
"mockPrivateChatLastMessageIsLoggedInUser" : "LR 7/16/2022 12:25",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
testing
testScrollToReferencedMessage

| referencedMessage referencingMessage referencedOffset replySnippet referencedTCUMessage |
referencedMessage := (TCTMMocks mockTextMessageWith: self core withId: 1) text: 'Referenced Message'.
referencingMessage := (TCTMMocks mockTextMessageWith: self core withId: 2 replyTo: 1) text: 'Referencing Message'.
| referencedMessage referencingMessage referencedOffset |
referencedMessage := (TCTMMocks mockTextMessageWith: self core withId: 1)
text: 'Referenced Message';
chat: self subject chat.
referencingMessage := (TCTMMocks mockTextMessageWith: self core withId: 2 replyTo: 1)
text: 'Referencing Message';
chat: self subject chat.
self subject chat addOldestMessage: referencedMessage.
self subject chat addNewestMessage: referencingMessage.

referencedTCUMessage := self subject scroller submorphs first.

self subject scrollToShow: referencedTCUMessage.
self subject scrollToShow: self subject scroller submorphs first.
referencedOffset := self subject vScrollBar value.
self subject scrollToNewestMessage.

replySnippet := self subject findByClass: TCUReplySnippet.
replySnippet click.
(self subject findByClass: TCUReplySnippet) click.

self assert: referencedOffset equals: self subject vScrollBar value.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"testDisplayedChatReceivesNewMessage" : "per 6/28/2021 16:23",
"testDoNotShowDateDivider" : "js 7/31/2022 19:11",
"testItemsHaveMessageId" : "js 7/31/2022 20:15",
"testScrollToReferencedMessage" : "js 7/31/2022 19:54" } }
"testScrollToReferencedMessage" : "rgw 8/5/2022 10:53" } }
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ testTextAndPhotoScaleCorrectlyLongCaption
photoMessage := TCTMMocks mockPhotoMessageWith: self core.
photoMessage caption: 'This is a very very very very veeeeeeeeeeery long caption with many irregularly sized words. It even consists of two sentences and definitely bothers the Linter.'.

self handleScreenShotTestFor: photoMessage with: 220726870 usedBy: 'testTextAndPhotoScaleCorrectly_longCaption'.
self handleScreenShotTestFor: photoMessage with: 45364912 usedBy: 'testTextAndPhotoScaleCorrectly_longCaption'.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ testTextAndPhotoScaleCorrectlyLongUserName
photoMessage := TCTMMocks mockPhotoMessageWith: self core.
photoMessage userId: TCTMMocks mockUser2 id.

self handleScreenShotTestFor: photoMessage with: 233114958 usedBy: 'testTextAndPhotoScaleCorrectly_longUserName'.
self handleScreenShotTestFor: photoMessage with: 127316392 usedBy: 'testTextAndPhotoScaleCorrectly_longUserName'.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ testTextAndPhotoScaleCorrectlyNoCaption
photoMessage := TCTMMocks mockPhotoMessageWith: self core.
photoMessage caption: ''.

self handleScreenShotTestFor: photoMessage with: 236500279 usedBy: 'testTextAndPhotoScaleCorrectly_noCaption'.
self handleScreenShotTestFor: photoMessage with: 2254673 usedBy: 'testTextAndPhotoScaleCorrectly_noCaption'.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ testTextAndPhotoScaleCorrectlyShortCaption
photoMessage := TCTMMocks mockPhotoMessageWith: self core.
photoMessage caption: 'vry shrt'.

self handleScreenShotTestFor: photoMessage with: 181862602 usedBy: 'testTextAndPhotoScaleCorrectly_shortCaption'.
self handleScreenShotTestFor: photoMessage with: 76064036 usedBy: 'testTextAndPhotoScaleCorrectly_shortCaption'.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"testMessageRequestsAnsweredMessage" : "JS 5/27/2022 19:20",
"testMessageShrinksCorrectly" : "tom.richter 6/26/2021 21:04",
"testMouseDownOnMessage" : "JS 5/22/2022 18:54",
"testTextAndPhotoScaleCorrectlyLongCaption" : "JS 5/27/2022 19:40",
"testTextAndPhotoScaleCorrectlyLongUserName" : "JS 5/27/2022 19:40",
"testTextAndPhotoScaleCorrectlyNoCaption" : "JS 5/27/2022 19:40",
"testTextAndPhotoScaleCorrectlyShortCaption" : "JS 5/27/2022 19:40",
"testTextAndPhotoScaleCorrectlyLongCaption" : "rgw 8/5/2022 10:33",
"testTextAndPhotoScaleCorrectlyLongUserName" : "rgw 8/5/2022 10:34",
"testTextAndPhotoScaleCorrectlyNoCaption" : "rgw 8/5/2022 10:34",
"testTextAndPhotoScaleCorrectlyShortCaption" : "rgw 8/5/2022 10:34",
"testTextMessageIsUserMessage" : "rgw 7/21/2022 15:58" } }

0 comments on commit 148c4f0

Please sign in to comment.