-
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.
Add synchronous interface to get a form from a local image file id (#403
) * add synchronous interface to get a form from an image file id * unify pendig request handling in core * enforce same promise in TCCUsers>>requestUserFor: * fix linter tests, allow for ignoring single methods with a comment * remove duplicate core setter of stores Co-authored-by: Tom Richter <tomrichter99@gmail.com>
- Loading branch information
1 parent
bd986b1
commit c015d8f
Showing
44 changed files
with
1,383 additions
and
22 deletions.
There are no files selected for viewing
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/TCCCore.class/instance/imageStore..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 | ||
imageStore: anImageStore | ||
|
||
imageStore := anImageStore. |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCCore.class/instance/imageStore.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 | ||
imageStore | ||
|
||
^ imageStore |
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
16 changes: 16 additions & 0 deletions
16
packages/TelegramClient-Core.package/TCCCore.class/instance/requestFile.with..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,16 @@ | ||
events | ||
requestFile: aFileId with: aCallbackID | ||
|
||
"documented here:" | ||
"https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1download_file.html" | ||
|
||
self client send: (TCCRequest | ||
newWithType: 'downloadFile' | ||
from: { | ||
'file_id'->aFileId. | ||
'priority'->32. | ||
'offset'->0. | ||
'limit'->0. | ||
'synchronous' -> true. | ||
'@extra'->aCallbackID | ||
}) |
3 changes: 1 addition & 2 deletions
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,5 +1,4 @@ | ||
accessing | ||
users: aDictionary | ||
|
||
users := aDictionary. | ||
self users core: self. | ||
users := aDictionary. |
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
"authHandler", | ||
"chatsHandler", | ||
"users", | ||
"imageStore", | ||
"chats", | ||
"loggedInUserID", | ||
"pendingRequests", | ||
|
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/TCCEvent.class/instance/extra..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 | ||
extra: aString | ||
|
||
extra := aString |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCEvent.class/instance/extra.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 | ||
extra | ||
|
||
^ extra |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCEvent.class/instance/hasExtra.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 | ||
hasExtra | ||
|
||
^ self extra notNil |
5 changes: 4 additions & 1 deletion
5
packages/TelegramClient-Core.package/TCCEvent.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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
{ | ||
"class" : { | ||
"newFromTDLibEvent:" : "pk 5/17/2021 20:25" }, | ||
"newFromTDLibEvent:" : "pk 6/19/2021 17:40" }, | ||
"instance" : { | ||
"extra" : "pk 6/19/2021 18:05", | ||
"extra:" : "pk 6/19/2021 17:39", | ||
"hasExtra" : "pk 6/19/2021 17:39", | ||
"isError" : "js 8/1/2020 12:32", | ||
"type" : "js 7/31/2020 22:28", | ||
"type:" : "js 7/31/2020 22:28" } } |
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-Core.package/TCCImageStore.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 @@ | ||
A TCCImageStore is a cache for local image files on disk with a synchronous interface. |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCImageStore.class/class/extractPathFrom..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 @@ | ||
utility | ||
extractPathFrom: anEvent | ||
|
||
^ (anEvent at: 'local') at: 'path' |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCImageStore.class/class/imageFormFrom..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 @@ | ||
utility | ||
imageFormFrom: aPath | ||
|
||
^ Form fromFileNamed: aPath |
6 changes: 6 additions & 0 deletions
6
packages/TelegramClient-Core.package/TCCImageStore.class/class/newWith..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 @@ | ||
instance creation | ||
newWith: aCore | ||
|
||
^ self new | ||
core: aCore; | ||
yourself |
4 changes: 4 additions & 0 deletions
4
packages/TelegramClient-Core.package/TCCImageStore.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/TCCImageStore.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 |
10 changes: 10 additions & 0 deletions
10
packages/TelegramClient-Core.package/TCCImageStore.class/instance/getFormFor..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 @@ | ||
accessing | ||
getFormFor: anImageId | ||
|
||
| promise | | ||
promise := self at: anImageId ifAbsent: | ||
[self at: anImageId put: Promise new. | ||
self requestImageFor: anImageId with: (self at: anImageId). | ||
self at: anImageId]. | ||
promise wait. | ||
^ self class imageFormFrom: promise value |
9 changes: 9 additions & 0 deletions
9
packages/TelegramClient-Core.package/TCCImageStore.class/instance/requestImageFor.with..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,9 @@ | ||
utility | ||
requestImageFor: anImageId with: aPromise | ||
|
||
| callbackID | | ||
callbackID := self core | ||
registerCallback: | ||
[:imageEvent | aPromise resolveWith: (self class extractPathFrom: imageEvent)]. | ||
|
||
self core requestFile: anImageId with: callbackID |
10 changes: 10 additions & 0 deletions
10
packages/TelegramClient-Core.package/TCCImageStore.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,10 @@ | ||
{ | ||
"class" : { | ||
"extractPathFrom:" : "pk 6/19/2021 16:23", | ||
"imageFormFrom:" : "pk 6/19/2021 16:25", | ||
"newWith:" : "pk 6/19/2021 18:09" }, | ||
"instance" : { | ||
"core" : "pk 6/19/2021 16:13", | ||
"core:" : "pk 6/19/2021 16:13", | ||
"getFormFor:" : "pk 6/19/2021 17:25", | ||
"requestImageFor:with:" : "pk 6/19/2021 16:26" } } |
14 changes: 14 additions & 0 deletions
14
packages/TelegramClient-Core.package/TCCImageStore.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-Core", | ||
"classinstvars" : [ | ||
], | ||
"classvars" : [ | ||
], | ||
"commentStamp" : "pk 6/19/2021 16:13", | ||
"instvars" : [ | ||
"core" ], | ||
"name" : "TCCImageStore", | ||
"pools" : [ | ||
], | ||
"super" : "Dictionary", | ||
"type" : "normal" } |
6 changes: 6 additions & 0 deletions
6
packages/TelegramClient-Core.package/TCCUsers.class/class/newWith..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 @@ | ||
instance creation | ||
newWith: aCore | ||
|
||
^ self new | ||
core: aCore; | ||
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
4 changes: 2 additions & 2 deletions
4
...CCUsers.class/instance/requestUserFor..st → ...rs.class/instance/requestUserFor.with..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 @@ | ||
utility | ||
requestUserFor: aUserId | ||
requestUserFor: aUserId with: aPromise | ||
|
||
| callbackID | | ||
callbackID := self core | ||
registerCallback: | ||
[:userEvent | (self at: aUserId) resolveWith: (TCCUser newFrom: userEvent)]. | ||
[:userEvent | aPromise resolveWith: (TCCUser newFrom: userEvent)]. | ||
|
||
self core requestUser: aUserId with: callbackID |
6 changes: 3 additions & 3 deletions
6
packages/TelegramClient-Core.package/TCCUsers.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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"class" : { | ||
}, | ||
"newWith:" : "pk 6/19/2021 17:20" }, | ||
"instance" : { | ||
"core" : "RK 5/19/2021 10:34", | ||
"core:" : "TR 6/15/2021 16:52", | ||
"getUserFor:" : "RK 5/19/2021 11:05", | ||
"requestUserFor:" : "pk 6/18/2021 09:47" } } | ||
"getUserFor:" : "pk 6/19/2021 17:48", | ||
"requestUserFor:with:" : "pk 6/19/2021 17:48" } } |
1 change: 1 addition & 0 deletions
1
packages/TelegramClientTests-Core.package/TCTCImageStoreTests.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 @@ | ||
A TCTCImageStoreTests tests wether the TCCImageStore works as it should. |
5 changes: 5 additions & 0 deletions
5
packages/TelegramClientTests-Core.package/TCTCImageStoreTests.class/instance/setUp.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,5 @@ | ||
running | ||
setUp | ||
|
||
super setUp. | ||
TCTMMocks writeMockImage. |
13 changes: 13 additions & 0 deletions
13
...elegramClientTests-Core.package/TCTCImageStoreTests.class/instance/testCanGetImageForm.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,13 @@ | ||
testing | ||
testCanGetImageForm | ||
|
||
| form | | ||
form := nil. | ||
|
||
self mockTeleClient onRequestType: 'downloadFile' respond: TCTMMocks mockImageResponseJson. | ||
|
||
[form := self core imageStore getFormFor: TCTMMocks mockImageId.] fork. | ||
1 seconds wait. | ||
|
||
self assert: form notNil. | ||
self assert: form isForm. |
9 changes: 9 additions & 0 deletions
9
...elegramClientTests-Core.package/TCTCImageStoreTests.class/instance/testCanGetImagePath.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,9 @@ | ||
testing | ||
testCanGetImagePath | ||
|
||
self mockTeleClient onRequestType: 'downloadFile' respond: TCTMMocks mockImageResponseJson. | ||
|
||
[self core imageStore getFormFor: TCTMMocks mockImageId.] fork. | ||
1 seconds wait. | ||
|
||
self assert: TCTMMocks mockImagePath equals: (self core imageStore at: TCTMMocks mockImageId) value. |
4 changes: 4 additions & 0 deletions
4
.../TelegramClientTests-Core.package/TCTCImageStoreTests.class/instance/testDidCreateFile.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 @@ | ||
testing | ||
testDidCreateFile | ||
|
||
self assert: (FileDirectory default isAFileNamed: TCTMMocks mockImagePath). |
8 changes: 8 additions & 0 deletions
8
packages/TelegramClientTests-Core.package/TCTCImageStoreTests.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" : { | ||
}, | ||
"instance" : { | ||
"setUp" : "pk 6/19/2021 17:37", | ||
"testCanGetImageForm" : "pk 6/19/2021 17:02", | ||
"testCanGetImagePath" : "pk 6/19/2021 17:24", | ||
"testDidCreateFile" : "pk 6/19/2021 17:35" } } |
14 changes: 14 additions & 0 deletions
14
packages/TelegramClientTests-Core.package/TCTCImageStoreTests.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" : "TelegramClientTests-Core", | ||
"classinstvars" : [ | ||
], | ||
"classvars" : [ | ||
], | ||
"commentStamp" : "pk 6/19/2021 18:08", | ||
"instvars" : [ | ||
], | ||
"name" : "TCTCImageStoreTests", | ||
"pools" : [ | ||
], | ||
"super" : "TCTCNoTdlibTestCase", | ||
"type" : "normal" } |
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
Oops, something went wrong.