Skip to content

Commit

Permalink
Hinzufügen von TCCUserMessage und TCUUserMessage (#525)
Browse files Browse the repository at this point in the history
* introduce TCCUserMessage and TCUUserMessage

Co-authored-by: Jacob Schaefer <js.jacobschaefer@gmail.com>

* fix lint

Co-authored-by: Jacob Schaefer <js.jacobschaefer@gmail.com>

* more precise class comments

Co-authored-by: Jacob Schaefer <js.jacobschaefer@gmail.com>
  • Loading branch information
antonykamp and jacob271 authored Jul 18, 2022
1 parent d956cc5 commit 6cb3c19
Show file tree
Hide file tree
Showing 87 changed files with 151 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ loading
chatHistoryReceived: anEvent

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"addOldestMessage:" : "LR 6/11/2022 16:17",
"canSendMessages" : "5/11/2021 10:09:15",
"canSendMessages:" : "JB 8/4/2021 00:08",
"chatHistoryReceived:" : "aka 6/15/2022 11:52",
"chatHistoryReceived:" : "aka 7/14/2022 16:38",
"core" : "per 6/4/2021 16:00",
"core:" : "per 6/4/2021 15:58",
"fulfillMessageRequest:" : "LR 6/15/2022 10:11",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"messageDictionary",
"selectedReplyToMessageId",
"requestedMessages",
"photoId",
"isPinned"],
"photoId",
"isPinned" ],
"name" : "TCCChat",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ addNewMessage: aJsonObject

| chat message |
chat := self chats getChat: (aJsonObject at: 'chat_id').
message := TCCMessage newFromMessageEvent: aJsonObject in: chat with: self core.
message := TCCUserMessage newFromMessageEvent: aJsonObject in: chat with: self core.

chat addNewestMessage: message.
self core triggerEvent: #newMessageReceived with: message.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ answeredMessageReceived: aJsonObject

| chat message |
chat := self chats getChat: (aJsonObject at: 'chat_id').
message := TCCMessage newFromMessageEvent: aJsonObject in: chat with: self core.
message := TCCUserMessage newFromMessageEvent: aJsonObject in: chat with: self core.

chat addAnsweredMessage: message.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ updateLastMessage: anEvent
detect: [:e | ((e at: 'list') at: '@type') = 'chatListMain'])
at: 'order')].

chat lastMessage: (TCCMessage newFromMessageEvent: messageJson in: chat with: self core) asSnippet.
chat lastMessage: (TCCUserMessage newFromMessageEvent: messageJson in: chat with: self core) asSnippet.

self chats notify].
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
},
"instance" : {
"addChat:" : "js 6/18/2022 09:27",
"addNewMessage:" : "pk 8/5/2021 16:37",
"answeredMessageReceived:" : "JS 5/26/2022 15:58",
"addNewMessage:" : "aka 7/14/2022 16:38",
"answeredMessageReceived:" : "aka 7/14/2022 16:38",
"chatHistoryReceived:" : "pk 8/5/2021 16:37",
"chats" : "RS 8/1/2021 12:50",
"chats:" : "RS 8/1/2021 12:51",
Expand All @@ -16,4 +16,4 @@
"openNewChat:" : "pk 8/5/2021 16:38",
"searchChat:" : "pk 8/5/2021 16:38",
"updateChatPosition:" : "js 6/18/2022 11:04",
"updateLastMessage:" : "RS 8/1/2021 12:55" } }
"updateLastMessage:" : "aka 7/14/2022 16:38" } }
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
{
"class" : {
"maxReplySnippetSize" : "rgw 5/12/2022 16:05",
"newFromMessageEvent:in:with:" : "rgw 6/2/2022 09:01",
"newMessageWith:" : "pk 8/5/2021 16:53",
"timeStampToDateAndTime:" : "JB 5/16/2021 09:42" },
"newMessageWith:" : "aka 7/14/2022 16:43" },
"instance" : {
"asReplySnippet" : "rgw 5/12/2022 16:05",
"asSnippet" : "tom.richter 6/28/2021 15:05",
"asText" : "TR 6/20/2021 10:13",
"chat" : "pk 5/7/2021 12:06",
"chat:" : "pk 8/4/2021 11:40",
"chatId" : "pk 8/5/2021 17:06",
"core" : "pk 6/8/2021 09:24",
"core:" : "pk 6/8/2021 09:25",
"date" : "RK 5/7/2021 10:02",
"date:" : "pk 8/4/2021 11:40",
"id" : "js 8/1/2020 18:20",
"id:" : "pk 8/4/2021 11:41",
"isOutgoing" : "js 8/2/2020 22:00",
"isOutgoing:" : "pk 8/4/2021 11:42",
"isReply" : "rgw 5/12/2022 15:40",
"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",
"senderType" : "tom.richter 7/25/2021 10:42",
"senderType:" : "pk 8/4/2021 11:42",
"senderUser" : "JS 6/11/2022 09:49",
"shouldNotify" : "per 6/16/2021 17:35",
"userId" : "tom.richter 7/25/2021 11:17",
"userId:" : "pk 8/4/2021 11:42" } }
"chat" : "aka 7/14/2022 16:41",
"chat:" : "aka 7/14/2022 16:41",
"chatId" : "aka 7/14/2022 16:41",
"core" : "aka 7/14/2022 16:41",
"core:" : "aka 7/14/2022 16:41",
"date" : "aka 7/14/2022 16:40",
"date:" : "aka 7/14/2022 16:40",
"id" : "aka 7/14/2022 16:40",
"id:" : "aka 7/14/2022 16:40" } }
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
],
"classvars" : [
],
"commentStamp" : "RK 6/26/2021 11:36",
"commentStamp" : "js 7/18/2022 07:50",
"instvars" : [
"chat",
"id",
"isOutgoing",
"date",
"core",
"senderType",
"userId",
"replyToMessageId" ],
"core" ],
"name" : "TCCMessage",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"name" : "TCCNotLoadedMessage",
"pools" : [
],
"super" : "TCCMessage",
"super" : "TCCUserMessage",
"type" : "normal" }
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"name" : "TCCNotSupportedMessage",
"pools" : [
],
"super" : "TCCMessage",
"super" : "TCCUserMessage",
"type" : "normal" }
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"name" : "TCCPhotoMessage",
"pools" : [
],
"super" : "TCCMessage",
"super" : "TCCUserMessage",
"type" : "normal" }
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"name" : "TCCTextMessage",
"pools" : [
],
"super" : "TCCMessage",
"super" : "TCCUserMessage",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
super-dataclass for messages that can be created by users
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"class" : {
"maxReplySnippetSize" : "rgw 5/12/2022 16:05",
"newFromMessageEvent:in:with:" : "rgw 6/2/2022 09:01",
"timeStampToDateAndTime:" : "JB 5/16/2021 09:42" },
"instance" : {
"asReplySnippet" : "rgw 5/12/2022 16:05",
"asSnippet" : "tom.richter 6/28/2021 15:05",
"asText" : "TR 6/20/2021 10:13",
"isOutgoing" : "js 8/2/2020 22:00",
"isOutgoing:" : "pk 8/4/2021 11:42",
"isReply" : "rgw 5/12/2022 15:40",
"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",
"senderType" : "tom.richter 7/25/2021 10:42",
"senderType:" : "pk 8/4/2021 11:42",
"senderUser" : "JS 6/11/2022 09:49",
"shouldNotify" : "per 6/16/2021 17:35",
"userId" : "tom.richter 7/25/2021 11:17",
"userId:" : "pk 8/4/2021 11:42" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"category" : "TelegramClient-Core",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "js 7/18/2022 07:50",
"instvars" : [
"isOutgoing",
"senderType",
"userId",
"replyToMessageId" ],
"name" : "TCCUserMessage",
"pools" : [
],
"super" : "TCCMessage",
"type" : "normal" }
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ addAtBottom: aCoreMessage
(self isFromCurrentChat: aCoreMessage)
ifFalse: [ ^ self ].
wasFullyScrolledDown := self isFullyScrolledDown.
messageItem := TCUMessage newFrom: aCoreMessage.
messageItem := TCUUserMessage newFrom: aCoreMessage.
messageItem when: #requestScroll send: #requestScrollToMessage: to: self with: (aCoreMessage replyToMessageId).
wrapper := TCUMessageWrapper newFromMessage: messageItem withWidth: self scroller width.
self scroller addMorphBack: wrapper.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ addAtTop: aCoreMessage
| wrapper messageItem |
(self isFromCurrentChat: aCoreMessage) ifFalse: [^ self].

messageItem := TCUMessage newFrom: aCoreMessage.
messageItem := TCUUserMessage newFrom: aCoreMessage.
messageItem when: #requestScroll send: #requestScrollToMessage: to: self with: (aCoreMessage replyToMessageId).
wrapper := TCUMessageWrapper newFromMessage: messageItem withWidth: self scroller width.
self scroller addMorphFront: wrapper.
Expand Down
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:" : "LR 6/11/2022 10:45",
"addAtTop:" : "LR 6/11/2022 11:00",
"addAtBottom:" : "aka 7/14/2022 16:13",
"addAtTop:" : "aka 7/14/2022 16:13",
"addMessages" : "RS 7/17/2021 17:40",
"chat" : "js 7/31/2020 16:39",
"chat:" : "js 7/31/2020 16:39",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
class with basic building instructions for the different message types
abstract class for all types of messages that can be shown in a chat
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
accessing
messageModel: aCoreMessage

messageModel := aCoreMessage.
messageModel when: #answeredMessageReceived send: #answeredMessageReceived to: self
messageModel := aCoreMessage
Original file line number Diff line number Diff line change
@@ -1,33 +1,8 @@
{
"class" : {
"defaultBottomMargin" : "JB 5/30/2021 11:27",
"defaultHeight" : "JB 5/29/2021 20:44",
"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",
"defaultWidth" : "r.s 7/31/2020 14:19",
"newFrom:" : "tom.richter 6/28/2021 15:08" },
"defaultBottomMargin" : "aka 7/14/2022 16:20",
"defaultMargins" : "aka 7/14/2022 16:20",
"newFrom:" : "aka 7/14/2022 16:22" },
"instance" : {
"addContent" : "TR 6/20/2021 11:12",
"addDate" : "js 7/4/2022 15:24",
"addReplySnippet" : "LR 6/15/2022 11:21",
"addSender" : "js 7/4/2022 15:24",
"addText" : "RK 6/23/2021 11:46",
"answeredMessageReceived" : "rgw 6/2/2022 10:29",
"date" : "TR 6/20/2021 10:59",
"handlesMouseDown:" : "rgw 7/9/2022 10:06",
"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:" : "rgw 7/9/2022 10:08",
"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" } }
"messageModel" : "aka 7/14/2022 17:22",
"messageModel:" : "aka 7/14/2022 16:18" } }
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"classvars" : [
],
"commentStamp" : "RK 6/26/2021 11:39",
"commentStamp" : "js 7/18/2022 07:47",
"instvars" : [
"messageModel" ],
"name" : "TCUMessage",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"name" : "TCUPhotoMessage",
"pools" : [
],
"super" : "TCUMessage",
"super" : "TCUUserMessage",
"type" : "normal" }
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"name" : "TCUTextMessage",
"pools" : [
],
"super" : "TCUMessage",
"super" : "TCUUserMessage",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class with basic building instructions for the different message that are created by a user
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessing
messageModel: aCoreMessage

super messageModel: aCoreMessage.
messageModel when: #answeredMessageReceived send: #answeredMessageReceived to: self
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"class" : {
"defaultHeight" : "JB 5/29/2021 20:44",
"defaultLayoutInset" : "LR 6/11/2022 11:40",
"defaultPhotoSize" : "JS 6/11/2022 09:55",
"defaultTextMorph" : "rgw 6/16/2022 15:47",
"defaultWidth" : "r.s 7/31/2020 14:19" },
"instance" : {
"addContent" : "TR 6/20/2021 11:12",
"addDate" : "js 7/4/2022 15:24",
"addReplySnippet" : "LR 6/15/2022 11:21",
"addSender" : "js 7/4/2022 15:24",
"addText" : "RK 6/23/2021 11:46",
"answeredMessageReceived" : "rgw 6/2/2022 10:29",
"date" : "TR 6/20/2021 10:59",
"handlesMouseDown:" : "rgw 7/9/2022 10:06",
"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:" : "aka 7/14/2022 16:18",
"mouseDown:" : "rgw 7/9/2022 10:08",
"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" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "TelegramClient-UI",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "js 7/18/2022 07:51",
"instvars" : [
],
"name" : "TCUUserMessage",
"pools" : [
],
"super" : "TCUMessage",
"type" : "normal" }
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ testing
testMessage

| message |
message := TCCMessage newFromMessageEvent: (TCTMMocks mockMessageJsonFrom: self chat id) in: self chat with: nil.
message := TCCUserMessage newFromMessageEvent: (TCTMMocks mockMessageJsonFrom: self chat id) in: self chat with: nil.

self assert: TCTMMocks mockUser1 id equals: message userId.
self assert: TCTMMocks mockMessageId equals: message id.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"testHandleMessageRequestAlreadyLoaded" : "aka 6/15/2022 11:59",
"testId" : "pk 8/5/2021 17:13",
"testLastMessage" : "per 5/21/2021 16:31",
"testMessage" : "pk 8/5/2021 17:06",
"testMessage" : "aka 7/14/2022 16:57",
"testMessages" : "JS 5/26/2022 14:37",
"testMessagesSize" : "per 5/21/2021 16:30",
"testNullId" : "pk 8/5/2021 17:13",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ testMessageCorrectlyConstructedFromJson

chat := TCTMMocks mockPrivateChat.
messageEvent := TCTMMocks mockMessageJsonFrom: chat id.
message := TCCMessage newFromMessageEvent: messageEvent in: chat with: self core.
message := TCCUserMessage newFromMessageEvent: messageEvent in: chat with: self core.

self assert: TCTMMocks mockMessageId equals: message id.
self assert: TCTMMocks mockMessageDate equals: message date.
Expand Down
Loading

0 comments on commit 6cb3c19

Please sign in to comment.