Skip to content

Commit

Permalink
Feature/group description (#379)
Browse files Browse the repository at this point in the history
* add initial version of Group description

(cherry-picked from commit f741db6)

* refactor info page description

(cherry-picked from commit ad3d81f)

* Solving merge conflicts

* Fixing formatting and corrected screenshot hash

* Adding screenshot test to expectedFailures for Squeak5.2

* Making TCCChat constructor better

Co-authored-by: Jannis Berndt <[email protected]>
  • Loading branch information
rsommerfeld and jb3rndt authored May 31, 2021
1 parent a167fe3 commit 34e76c1
Show file tree
Hide file tree
Showing 54 changed files with 281 additions and 66 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
instance creation
newFromChatEvent: anEvent

| chat |
chat := anEvent at: 'chat'.
^ self new
title: (chat at: 'title');
id: (chat at: 'id');
canSendMessages: ((chat at: 'permissions') at: 'can_send_messages');
type: ((chat at: 'type') at: '@type');
lastMessage: '';
yourself
| type |
type := ((anEvent at: 'chat') at: 'type') at: '@type'.

^ (((type = 'chatTypeSupergroup') or: (type = 'chatTypeBasicGroup'))
ifTrue: [TCCGroup new]
ifFalse: [self new])
initializeFromChatEvent: anEvent;
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
initialization
initializeFromChatEvent: anEvent

| chat |
chat := anEvent at: 'chat'.
self
title: (chat at: 'title');
id: (chat at: 'id');
canSendMessages: ((chat at: 'permissions') at: 'can_send_messages');
type: ((chat at: 'type') at: '@type');
lastMessage: ''
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
isGroup

^ false

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
initialization
accessing
isPrivate

^ (self type = 'chatTypePrivate')
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"class" : {
"newFromChatEvent:" : "TR 5/19/2021 13:42" },
"newFromChatEvent:" : "JB 5/31/2021 16:21" },
"instance" : {
"addNewestMessage:" : "js 8/2/2020 12:58",
"addOldestMessage:" : "js 8/2/2020 12:58",
Expand All @@ -11,12 +11,11 @@
"id:" : "5/11/2021 10:09:15",
"ifNotWaitingForUpdate:" : "js 8/2/2020 13:17",
"initialize" : "per 5/26/2021 14:02",
"isNotPrivate" : "TR 5/21/2021 15:36",
"initializeFromChatEvent:" : "JB 5/31/2021 16:19",
"isGroup" : "RS 5/29/2021 18:12",
"isPrivate" : "per 5/13/2021 08:48",
"lastMessage" : "rs 6/19/2020 17:33",
"lastMessage:" : "5/11/2021 10:09:15",
"memberCount" : "TR 5/21/2021 15:53",
"memberCount:" : "TR 5/21/2021 15:53",
"messages" : "R.S 6/1/2020 15:37",
"messages:" : "5/11/2021 10:09:15",
"numberOfMessages" : "js 8/1/2020 18:04",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"category" : "TelegramClient-Core",
"classinstvars" : [
"userI" ],
],
"classvars" : [
],
"commentStamp" : "js 6/13/2020 16:25",
Expand All @@ -15,8 +15,7 @@
"waitingForUpdate",
"numberOfRequestedMessages",
"type",
"canSendMessages",
"memberCount" ],
"canSendMessages" ],
"name" : "TCCChat",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ addChat: aChatEvent
| chat |
chat := TCCChat newFromChatEvent: aChatEvent.
(chat type = 'chatTypeSupergroup') ifTrue: [
self loadSuperGroupChatMemberCountFor: chat with: (((aChatEvent at: 'chat') at: 'type') at: 'supergroup_id').
self loadSuperGroupInfoFor: chat with: (((aChatEvent at: 'chat') at: 'type') at: 'supergroup_id').
].
(chat type = 'chatTypeBasicGroup') ifTrue: [
self loadBasicGroupChatMemberCountFor: chat with: (((aChatEvent at: 'chat') at: 'type') at: 'basic_group_id').
self loadBasicGroupInfoFor: chat with: (((aChatEvent at: 'chat') at: 'type') at: 'basic_group_id').
].

self app chats
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
events
loadBasicGroupInfoFor: aChat with: aBasicGroupId

self client send: (TCCRequest
newWithType: 'getBasicGroupFullInfo'
from: {
'basic_group_id'->aBasicGroupId.
'@extra'->aBasicGroupId}).

self app
registerCallback: [:aBasicGroupFullInfoEvent |
aChat
memberCount: (aBasicGroupFullInfoEvent at: 'members') size;
description: (aBasicGroupFullInfoEvent at: 'description').]
with: aBasicGroupId.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
events
loadSuperGroupInfoFor: aChat with: aSupergroupId

self client send: (TCCRequest
newWithType: 'getSupergroupFullInfo'
from: {
'supergroup_id'->aSupergroupId.
'@extra'->aSupergroupId}).

self app
registerCallback: [:aSupergroupFullInfoEvent |
aChat
memberCount: (aSupergroupFullInfoEvent at: 'member_count');
description: (aSupergroupFullInfoEvent at: 'description').]
with: aSupergroupId.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"class" : {
},
"instance" : {
"addChat:" : "TR 5/30/2021 13:15",
"addChat:" : "JB 5/31/2021 15:05",
"addNewMessage:from:" : "pk 5/17/2021 19:10",
"app" : "5/11/2021 10:09:15",
"app:" : "pk 5/17/2021 19:11",
Expand All @@ -12,8 +12,8 @@
"getChatHistoryFrom:with:limit:" : "js 8/2/2020 13:17",
"getChats" : "js 7/31/2020 22:50",
"handleNewMessage:from:" : "pk 5/17/2021 18:28",
"loadBasicGroupChatMemberCountFor:with:" : "per 5/26/2021 14:03",
"loadSuperGroupChatMemberCountFor:with:" : "per 5/26/2021 14:03",
"loadBasicGroupInfoFor:with:" : "JB 5/31/2021 15:09",
"loadSuperGroupInfoFor:with:" : "JB 5/31/2021 15:10",
"openNewChat:" : "pk 5/13/2021 12:45",
"remainingMessages" : "5/11/2021 10:09:15",
"remainingMessages:" : "js 8/1/2020 16:50",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
representing a Telegram superGroup or basicGroup
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
description: aString

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

^ description
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
initialization
initialize

super initialize.
self description: ''.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
isGroup

^ true
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
isPrivate

^ false
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"class" : {
},
"instance" : {
"description" : "RS 5/29/2021 18:44",
"description:" : "RS 5/29/2021 18:44",
"initialize" : "RS 5/29/2021 18:44",
"isGroup" : "RS 5/29/2021 18:13",
"isPrivate" : "RS 5/29/2021 17:38",
"memberCount" : "RS 5/29/2021 18:44",
"memberCount:" : "RS 5/29/2021 18:44" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"category" : "TelegramClient-Core",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "RS 5/29/2021 18:45",
"instvars" : [
"description",
"memberCount" ],
"name" : "TCCGroup",
"pools" : [
],
"super" : "TCCChat",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
isPrivate

^ false
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
},
"instance" : {
"id" : "rs 6/17/2020 22:31",
"isPrivate" : "RS 5/29/2021 18:12",
"messages" : "rs 7/4/2020 19:17" } }
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ failures
expectedFailures

^ Smalltalk version = 'Squeak5.2'
ifTrue: [#(testMessageUI)]
ifTrue: [#(testMessageUI testPrivateChatHasNoDescription)]
ifFalse: [#()]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ testCanCloseChatInfoPage

(self subject findByClass: TCUChatListItem) click.
titleBar := (self subject findByClass: TCUChatWindow) titleBar.
(self subject createWrapperFor: { titleBar } ) click.
(self subject createWrapperFor: { titleBar }) click.
self assert: (self subject findByClass: TCUChatInfoPage) visible.

(self subject findByName: 'infoBackButton') click.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
testing
testDoesDisplayGroupDescription

| titleBar groupChat |
self wantsToTest: (TCUMain newWithCore: self core).

[self core chats anySatisfy: [:c | c isGroup]]
whileFalse: [6 seconds wait.].
groupChat := (self core chats detect: [:chat | chat isGroup]).
groupChat description: TCTMocks mockDescription.

(self subject findByCriteria: [ :morph | (morph respondsTo: #chatID) and: [morph chatID = groupChat id]]) click.
titleBar := (self subject findByClass: TCUChatWindow) morphs collect: [:chatWindow | chatWindow titleBar].
(self subject createWrapperFor: titleBar) click.

self assertReading: groupChat description in: (self subject findByClass: TCUChatInfoPage).
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
testing
testPrivateChatHasNoDescription

| titleBar groupChat chatInfoPage |
self wantsToTest: (TCUMain newWithCore: self core).

[self core chats anySatisfy: [:c | c isPrivate]]
whileFalse: [6 seconds wait.].
groupChat := (self core chats detect: [:chat | chat isPrivate]).

(self subject findByCriteria: [ :morph | (morph respondsTo: #chatID) and: [morph chatID = groupChat id]]) click.
titleBar := (self subject findByClass: TCUChatWindow) morphs collect: [:chatWindow | chatWindow titleBar].
(self subject createWrapperFor: titleBar) click.

chatInfoPage := (self subject findByClass: TCUChatInfoPage) morphs anyOne.
self forceSaveScreenshotOf: chatInfoPage as: 'testPrivateChatHasNoDescription' in: self class defaultTestResultPath.
self assert: 236496437 equals: (self computeHashOf: (self takeScreenshotOf: chatInfoPage)).
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
"app:" : "RS 5/31/2021 07:52",
"core" : "pk 5/17/2021 15:28",
"core:" : "pk 5/30/2021 20:40",
"expectedFailures" : "RS 5/31/2021 07:36",
"expectedFailures" : "JB 5/31/2021 15:35",
"newMessageReceived:" : "pk 5/17/2021 19:20",
"receivedMessage" : "pk 5/17/2021 19:15",
"receivedMessage:" : "pk 5/17/2021 19:32",
"setUp" : "RS 5/31/2021 08:01",
"tearDown" : "RS 5/31/2021 07:33",
"testCanCloseChatInfoPage" : "RS 5/31/2021 07:39",
"testCanOpenChatInfoPage" : "RS 5/31/2021 07:39",
"testChatInfoPageIsHidden" : "RS 5/31/2021 07:34",
"testCanCloseChatInfoPage" : "JB 5/31/2021 10:19",
"testCanOpenChatInfoPage" : "JB 5/31/2021 09:50",
"testChatInfoPageIsHidden" : "JB 5/31/2021 09:49",
"testChatMemberCount" : "RS 5/31/2021 07:35",
"testDoesDisplayGroupDescription" : "JB 5/31/2021 15:10",
"testMessageAuthors" : "RS 5/31/2021 07:41",
"testMessageUI" : "RS 5/31/2021 07:36",
"testNotificationContainsMessage" : "RS 5/31/2021 07:36" } }
"testNotificationContainsMessage" : "RS 5/31/2021 07:36",
"testPrivateChatHasNoDescription" : "JB 5/31/2021 10:28" } }
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
chat
mockBasicGroupChat

^ TCCChat new
^ TCCGroup new
id: 2;
title: 'GroupMockChat';
type: 'chatTypeBasicGroup';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
chat
mockDescription

^ 'A very random demo description'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
chat
mockSupergroupChat

^ TCCChat new
^ TCCGroup new
id: 3;
title: 'SupergroupMockChat';
type: 'chatTypeSupergroup';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"class" : {
"mockBasicGroupChat" : "TR 5/30/2021 17:55",
"mockBasicGroupChat" : "JB 5/31/2021 10:15",
"mockChatID" : "RS 5/23/2021 17:32",
"mockChats" : "TR 5/27/2021 19:55",
"mockDescription" : "RS 5/29/2021 18:41",
"mockMessage" : "JB 5/24/2021 17:57",
"mockMessageEventFrom:" : "RS 5/23/2021 17:56",
"mockMessageID" : "pk 5/19/2021 11:36",
"mockMessageJsonFrom:" : "RS 5/23/2021 17:26",
"mockMessageText" : "pk 5/19/2021 11:38",
"mockPrivateChat" : "TR 5/30/2021 17:56",
"mockSupergroupChat" : "TR 5/30/2021 17:56",
"mockSupergroupChat" : "JB 5/31/2021 10:15",
"mockUserEvent" : "5/30/2021 21:44:49",
"mockUserFirstName" : "pk 5/19/2021 11:38",
"mockUserFullName" : "pk 5/19/2021 11:49",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
instance creation
newBounds: bounds
newFor: aChat withBounds: bounds

^ (super newBounds: bounds)
chat: aChat;
addInfoBar;
addContent;
yourself
Loading

0 comments on commit 34e76c1

Please sign in to comment.