-
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.
Hinzufügen von Tag-Trenner (alias "day divider") (#524)
* add first prototype Co-authored-by: Jacob Schaefer <[email protected]> Co-authored-by: kohlros <[email protected]> * fix disappearing divider Co-authored-by: Jacob Schaefer <[email protected]> * revert change in testAddingOldMessageDoesNotScroll Co-authored-by: Jacob Schaefer <[email protected]> * refactor mockTextMessageWith:withDate: Co-authored-by: Jacob Schaefer <[email protected]> * scroll after adding divider to fix not ending up at the bottom when opening a chat * rename TCUInfoMessage to TCUDayDividerMessage Co-authored-by: Jacob Schaefer <[email protected]> * fix click on replied message Co-authored-by: Jacob Schaefer <[email protected]> * fix merge conflicts Co-authored-by: Jacob Schaefer <[email protected]> * remove leftovers of lastMessageSnippet Co-authored-by: Jacob Schaefer <[email protected]> * test addDayDividerAtTop Co-authored-by: Jacob Schaefer <[email protected]> Co-authored-by: kohlros <[email protected]>
- Loading branch information
1 parent
444899d
commit 867daf4
Showing
54 changed files
with
324 additions
and
30 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCChat.class/class/defaultLastMessageDate.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 @@ | ||
default values | ||
defaultLastMessageDate | ||
|
||
^ DateAndTime fromUnixTime: 0 |
7 changes: 7 additions & 0 deletions
7
packages/TelegramClient-Core.package/TCCChat.class/instance/addNewestMessage..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,6 +1,13 @@ | ||
adding | ||
addNewestMessage: aMessage | ||
|
||
| newDate oldDate | | ||
newDate := aMessage date asDate. | ||
oldDate := self lastMessageDate asDate. | ||
(newDate > oldDate) ifTrue: [ | ||
aMessage isFirstMessageOfDay: true. | ||
self lastMessage isLastMessageOfDay: true. | ||
]. | ||
self messageIds addFirst: aMessage id. | ||
self messageDictionary at: aMessage id put: aMessage. | ||
self triggerEvent: #newMessage with: aMessage. |
6 changes: 6 additions & 0 deletions
6
packages/TelegramClient-Core.package/TCCChat.class/instance/addOldestMessage..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,6 +1,12 @@ | ||
adding | ||
addOldestMessage: aMessage | ||
|
||
| newDate oldDate | | ||
newDate := aMessage date asDate. | ||
oldDate := self oldestLoadedMessageDate asDate. | ||
(newDate < oldDate) ifTrue: [ | ||
self oldestLoadedMessage isFirstMessageOfDay: true. | ||
aMessage isLastMessageOfDay: true]. | ||
self messageIds add: aMessage id. | ||
self messageDictionary at: aMessage id put: aMessage. | ||
self triggerEvent: #loadedMessage with: aMessage. |
7 changes: 7 additions & 0 deletions
7
packages/TelegramClient-Core.package/TCCChat.class/instance/lastMessage.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 @@ | ||
accessing | ||
lastMessage | ||
|
||
^ self messages | ||
ifEmpty: [ TCCNotLoadedMessage new | ||
date: self class defaultLastMessageDate] | ||
ifNotEmpty: [ self messages first ] |
6 changes: 6 additions & 0 deletions
6
packages/TelegramClient-Core.package/TCCChat.class/instance/lastMessageDate.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,6 @@ | ||
accessing | ||
lastMessageDate | ||
|
||
"Date of the latest received message." | ||
|
||
^ self lastMessage date |
7 changes: 7 additions & 0 deletions
7
packages/TelegramClient-Core.package/TCCChat.class/instance/oldestLoadedMessage.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 @@ | ||
accessing | ||
oldestLoadedMessage | ||
|
||
^ self messages | ||
ifEmpty: [ TCCNotLoadedMessage new | ||
date: self class defaultLastMessageDate] | ||
ifNotEmpty: [ self messages last ] |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCChat.class/instance/oldestLoadedMessageDate.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 | ||
oldestLoadedMessageDate | ||
|
||
^ self oldestLoadedMessage date |
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/TCCMessage.class/instance/initialize.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 @@ | ||
accessing | ||
initialize | ||
|
||
super initialize. | ||
|
||
self | ||
isFirstMessageOfDay: false; | ||
isLastMessageOfDay: false |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCMessage.class/instance/isFirstMessageOfDay..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 | ||
isFirstMessageOfDay: aBool | ||
|
||
isFirstMessageOfDay := aBool |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCMessage.class/instance/isFirstMessageOfDay.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 | ||
isFirstMessageOfDay | ||
|
||
^ isFirstMessageOfDay |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCMessage.class/instance/isLastMessageOfDay..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 | ||
isLastMessageOfDay: aBool | ||
|
||
isLastMessageOfDay := aBool |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCMessage.class/instance/isLastMessageOfDay.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 | ||
isLastMessageOfDay | ||
|
||
^ isLastMessageOfDay |
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
7 changes: 6 additions & 1 deletion
7
packages/TelegramClient-UI.package/TCUChatMessageList.class/instance/addAtTop..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
10 changes: 10 additions & 0 deletions
10
...elegramClient-UI.package/TCUChatMessageList.class/instance/addBottomDayDividerForDate..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,10 @@ | ||
stepping and presenter | ||
addBottomDayDividerForDate: aDate | ||
|
||
| divider wasFullyScrolledDown | | ||
wasFullyScrolledDown := self isFullyScrolledDown. | ||
divider := self createDayDividerForDate: aDate. | ||
self scroller addMorphBack: divider. | ||
self items addLast: divider. | ||
wasFullyScrolledDown | ||
ifTrue: [ self scrollToNewestMessage ] |
10 changes: 10 additions & 0 deletions
10
...s/TelegramClient-UI.package/TCUChatMessageList.class/instance/addTopDayDividerForDate..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,10 @@ | ||
stepping and presenter | ||
addTopDayDividerForDate: aDate | ||
|
||
| divider | | ||
divider := self createDayDividerForDate: aDate. | ||
self scroller addMorphFront: divider. | ||
self items addFirst: divider. | ||
self isFullyScrolledDown | ||
ifTrue: [self scrollToNewestMessage]. | ||
self scrollBy: 0 @ (divider height negated). |
12 changes: 12 additions & 0 deletions
12
...s/TelegramClient-UI.package/TCUChatMessageList.class/instance/createDayDividerForDate..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,12 @@ | ||
stepping and presenter | ||
createDayDividerForDate: aDate | ||
|
||
| messageItem | | ||
messageItem := TCUDayDividerMessage newFromDate: aDate. | ||
^ RectangleMorph new | ||
color: Color transparent; | ||
width: self scroller width; | ||
height: messageItem height; | ||
borderWidth: 0; | ||
addMorphCentered: messageItem; | ||
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
5 changes: 2 additions & 3 deletions
5
packages/TelegramClient-UI.package/TCUChatMessageList.class/instance/scrollToMessage..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 @@ | ||
drawing | ||
scrollToMessage: aMessageId | ||
|
||
| messageItem messageIndex | | ||
messageIndex := self chat messageIds reversed indexOf: aMessageId. | ||
messageItem := self items at: messageIndex. | ||
| messageItem | | ||
messageItem := self items detect: [:item | ((item isKindOf: TCUMessageWrapper)) and: [item messageId = aMessageId]]. | ||
self scrollToShow: messageItem |
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
1 change: 1 addition & 0 deletions
1
packages/TelegramClient-UI.package/TCUDayDividerMessage.class/README.md
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 @@ | ||
class for automatic generated info messages. |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-UI.package/TCUDayDividerMessage.class/class/defaultMargin.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 @@ | ||
defaults | ||
defaultMargin | ||
|
||
^ 20 |
7 changes: 7 additions & 0 deletions
7
packages/TelegramClient-UI.package/TCUDayDividerMessage.class/class/newFromDate..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 @@ | ||
instance creation | ||
newFromDate: aDate | ||
|
||
^ self basicNew | ||
content: aDate mmddyyyy; | ||
initialize; | ||
yourself |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-UI.package/TCUDayDividerMessage.class/instance/content..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 | ||
content: aString | ||
|
||
content := aString |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-UI.package/TCUDayDividerMessage.class/instance/content.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 | ||
content | ||
|
||
^ content |
14 changes: 14 additions & 0 deletions
14
packages/TelegramClient-UI.package/TCUDayDividerMessage.class/instance/initialize.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,14 @@ | ||
initialization | ||
initialize | ||
|
||
| textMorph | | ||
super initialize. | ||
|
||
textMorph := TextMorph new | ||
contents: self content; | ||
lock. | ||
self color: Color gray; | ||
width: textMorph width + self class defaultMargin; | ||
addMorphCentered: textMorph; | ||
useRoundedCorners; | ||
borderWidth: 0. |
8 changes: 8 additions & 0 deletions
8
packages/TelegramClient-UI.package/TCUDayDividerMessage.class/methodProperties.json
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 @@ | ||
{ | ||
"class" : { | ||
"defaultMargin" : "aka 7/14/2022 15:15", | ||
"newFromDate:" : "aka 7/14/2022 15:14" }, | ||
"instance" : { | ||
"content" : "aka 7/10/2022 12:37", | ||
"content:" : "aka 7/10/2022 12:37", | ||
"initialize" : "aka 7/14/2022 15:16" } } |
14 changes: 14 additions & 0 deletions
14
packages/TelegramClient-UI.package/TCUDayDividerMessage.class/properties.json
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,14 @@ | ||
{ | ||
"category" : "TelegramClient-UI", | ||
"classinstvars" : [ | ||
], | ||
"classvars" : [ | ||
], | ||
"commentStamp" : "aka 7/14/2022 15:07", | ||
"instvars" : [ | ||
"content" ], | ||
"name" : "TCUDayDividerMessage", | ||
"pools" : [ | ||
], | ||
"super" : "RectangleMorph", | ||
"type" : "normal" } |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-UI.package/TCUMessageWrapper.class/instance/messageId.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 | ||
messageId | ||
|
||
^ self message messageModel id |
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
4 changes: 3 additions & 1 deletion
4
...ges/TelegramClientTests-Core.package/TCTCChatTests.class/instance/testAddNewestMessage.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,5 +1,7 @@ | ||
testing | ||
testAddNewestMessage | ||
|
||
self chat addNewestMessage: (TCCTextMessage new text: 'test'). | ||
self chat addNewestMessage: (TCCTextMessage new | ||
text: 'test'; | ||
date: DateAndTime today). | ||
self assert: 'test' equals: self chat messages first asText. |
5 changes: 4 additions & 1 deletion
5
...ges/TelegramClientTests-Core.package/TCTCChatTests.class/instance/testAddOldestMessage.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,5 +1,8 @@ | ||
testing | ||
testAddOldestMessage | ||
|
||
self chat addOldestMessage: (TCCTextMessage new text: 'test'). | ||
self chat addOldestMessage: (TCCTextMessage new | ||
text: 'test'; | ||
date: (DateAndTime fromUnixTime: 0) | ||
). | ||
self assert: 'test' equals: self chat messages last asText. |
Oops, something went wrong.