-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
show senders in chat messages (#387)
* show senders in chat messages * rebuild lost changes * fix tests, add TCCUser>>= and hash * Some formatting * fix linter test to allow for non-letter method names * Minor formatting * test message sender name in ui * Fixing Linter * Whoopsies * fix hash * test user hash and equality operator * minor formatting and redundant code removal * please linter * Removing defensive parenthesis Co-authored-by: Jannis Berndt <[email protected]>
- Loading branch information
Showing
56 changed files
with
206 additions
and
96 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...ler.class/instance/addNewMessage.from..st → ...sHandler.class/instance/addNewMessage..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
events | ||
addNewMessage: aMessageJSONObject from: aUser | ||
addNewMessage: aMessageJSONObject | ||
|
||
| chat message | | ||
chat := self core chats getChat: (aMessageJSONObject at: 'chat_id'). | ||
message := TCCMessage newFromMessageEvent: aMessageJSONObject in: chat from: aUser. | ||
message := TCCMessage newFromMessageEvent: aMessageJSONObject in: chat with: self core. | ||
|
||
chat addNewestMessage: message. | ||
self core triggerEvent: #newMessageReceived with: message. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCChatsHandler.class/instance/handleNewMessage..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
event handling | ||
handleNewMessage: aMessageJSONObject | ||
|
||
self addNewMessage: aMessageJSONObject |
4 changes: 0 additions & 4 deletions
4
...ages/TelegramClient-Core.package/TCCChatsHandler.class/instance/handleNewMessage.from..st
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
packages/TelegramClient-Core.package/TCCCore.class/instance/handleMessageEvent..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
events | ||
handleMessageEvent: anEvent | ||
|
||
| message userID | | ||
| message | | ||
message := anEvent at: 'message'. | ||
userID := (message at: 'sender') at: 'user_id'. | ||
[self chatsHandler handleNewMessage: message from: (self users getUserFor: userID)] fork | ||
self chatsHandler handleNewMessage: message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/TelegramClient-Core.package/TCCCore.class/instance/users..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
accessing | ||
users: aDictionary | ||
|
||
users := aDictionary | ||
users := aDictionary. | ||
self users core: self. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
packages/TelegramClient-Core.package/TCCMessage.class/class/newFromMessageEvent.in.from..st
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCMessage.class/instance/core..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
accessing | ||
core: aCore | ||
|
||
core := aCore |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCMessage.class/instance/core.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
accessing | ||
core | ||
|
||
^ core |
2 changes: 1 addition & 1 deletion
2
packages/TelegramClient-Core.package/TCCMessage.class/instance/sender.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
accessing | ||
sender | ||
|
||
^ sender | ||
^ self core users getUserFor: self senderID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/TelegramClient-Core.package/TCCUser.class/instance/^equals.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
comparing | ||
= aUser | ||
|
||
^ self species = aUser species | ||
and: [self firstName = aUser firstName] | ||
and: [self lastName = aUser lastName] | ||
and: [self id = aUser id] | ||
and: [self username = aUser username] |
2 changes: 1 addition & 1 deletion
2
packages/TelegramClient-Core.package/TCCUser.class/instance/fullName.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
accessing | ||
fullName | ||
|
||
^ (self firstName) , ' ' , (self lastName) | ||
^ self firstName , ' ' , self lastName |
7 changes: 7 additions & 0 deletions
7
packages/TelegramClient-Core.package/TCCUser.class/instance/hash.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
comparing | ||
hash | ||
|
||
^ ((self firstName hash | ||
bitXor: self lastName hash) | ||
bitXor: self id hash) | ||
bitXor: self username hash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ initialize | |
username: ''; | ||
firstName: ''; | ||
lastName: ''; | ||
id: -1 | ||
id: -1. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/TelegramClient-UI.package/TCUMessage.class/instance/addSender.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
drawing | ||
addSender | ||
|
||
self addMorphFront: (self defaultTextMorph | ||
contents: self sender fullName; | ||
color: self dateColor; | ||
margins: self defaultMargins; | ||
yourself). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ initialize | |
initializeDefaults; | ||
addText; | ||
addDate; | ||
addSender; | ||
shrinkToContent. |
2 changes: 1 addition & 1 deletion
2
...kage/TCCMessage.class/instance/sender..st → ...kage/TCUMessage.class/instance/sender..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
accessing | ||
sender: aUser | ||
|
||
sender := aUser. | ||
sender := aUser |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-UI.package/TCUMessage.class/instance/sender.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
accessing | ||
sender | ||
|
||
^ sender |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,8 @@ | |
"text", | ||
"senderID", | ||
"isOutgoing", | ||
"date" ], | ||
"date", | ||
"sender" ], | ||
"name" : "TCUMessage", | ||
"pools" : [ | ||
], | ||
|
2 changes: 1 addition & 1 deletion
2
packages/TelegramClient-UI.package/TCUNotification.class/instance/calculatePosition.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
accessing | ||
calculatePosition | ||
|
||
^ self currentWorld bottomRight - (self defaultWidth @ self defaultHeight) - (self defaultOffset) | ||
^ self currentWorld bottomRight - (self defaultWidth @ self defaultHeight) - self defaultOffset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...ntTests-Core.package/TCTCCoreTests.class/instance/testMessageSenderTriggersUserRequest.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
testing | ||
testMessageSenderTriggersUserRequest | ||
|
||
| messageEvent userJson | | ||
self core when: #newMessageReceived send: #newMessageReceived: to: self. | ||
self core chats add: TCTMMocks mockPrivateChat. | ||
|
||
self receivedMessage: nil. | ||
messageEvent := TCTMMocks mockMessageEventFrom: TCTMMocks mockPrivateChat id. | ||
|
||
self core handleEvent: messageEvent. | ||
1 seconds wait. | ||
|
||
userJson := TCTMMocks mockUserJson. | ||
self core client onRequestType: 'getUser' respond: userJson. | ||
|
||
self assert: self receivedMessage notNil. | ||
self assert: TCTMMocks mockUser fullName equals: self receivedMessage sender fullName. | ||
self assert: TCTMMocks mockPrivateChat id equals: self receivedMessage chat id. | ||
self assert: TCTMMocks mockMessageText equals: self receivedMessage message. |
21 changes: 0 additions & 21 deletions
21
...amClientTests-Core.package/TCTCCoreTests.class/instance/testMessageTriggersUserRequest.st
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.