Skip to content

Commit 9ff61ab

Browse files
committed
added document store, download dowcument into selected directory on click on document message icon
1 parent 8c4f4a2 commit 9ff61ab

File tree

21 files changed

+94
-14
lines changed

21 files changed

+94
-14
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
accessing
2+
documentStore: aDocumentStore
3+
4+
documentStore := aDocumentStore
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
accessing
2+
documentStore
3+
4+
^ documentStore

packages/TelegramClient-Core.package/TCCCore.class/instance/initialize.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ initialize
1010
imageStore: (TCCImageStore newWith: self);
1111
videoStore: (TCCVideoStore newWith: self);
1212
stickerStore: (TCCStickerStore newWith: self);
13+
documentStore: (TCCDocumentStore newWith: self);
1314
callbackCounter: 0.
1415

1516
"Mac users report serious slowdowns when receiveLoop is running at lower priority"

packages/TelegramClient-Core.package/TCCCore.class/methodProperties.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"checkAuthenticationPassword:" : "aka 5/21/2022 11:31",
1515
"client" : "R.S 5/20/2020 16:08",
1616
"client:" : "pk 8/5/2021 16:39",
17+
"documentStore" : "JK 6/26/2024 14:19",
18+
"documentStore:" : "JK 6/26/2024 14:19",
1719
"freeClient" : "6/9/2021 14:12:18",
1820
"generateCallbackId" : "pk 8/5/2021 17:04",
1921
"getOwnProfile" : "pk 8/5/2021 17:05",
@@ -22,7 +24,7 @@
2224
"handlePendingEvent:" : "per 8/2/2021 15:05",
2325
"imageStore" : "pk 6/19/2021 17:15",
2426
"imageStore:" : "TR 6/22/2021 09:33",
25-
"initialize" : "JK 6/20/2024 22:16",
27+
"initialize" : "JK 6/26/2024 14:18",
2628
"initializeHandlers" : "RS 8/1/2021 12:53",
2729
"isClientAlive" : "js 5/28/2020 17:18",
2830
"loggedInUserId" : "pk 8/5/2021 17:04",

packages/TelegramClient-Core.package/TCCCore.class/properties.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"callbackCounter",
1616
"userStore",
1717
"videoStore",
18-
"stickerStore" ],
18+
"stickerStore",
19+
"documentStore" ],
1920
"name" : "TCCCore",
2021
"pools" : [
2122
],

packages/TelegramClient-Core.package/TCCDocumentMessage.class/class/newFrom..st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ newFrom: aJsonObject
33

44
^ self new
55
filename: ((aJsonObject at: 'document') at: 'file_name');
6+
documentId: (((aJsonObject at: 'document') at: 'document') at: 'id');
67
yourself
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
accessing
2+
documentId: aNumber
3+
4+
documentId := aNumber
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
accessing
2+
documentId
3+
4+
^ documentId
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"class" : {
3-
"newFrom:" : "JK 6/23/2024 11:52" },
3+
"newFrom:" : "JK 6/26/2024 14:23" },
44
"instance" : {
55
"asSnippet" : "AH 6/21/2024 13:54",
66
"asText" : "AH 6/21/2024 13:54",
7+
"documentId" : "JK 6/26/2024 14:14",
8+
"documentId:" : "JK 6/26/2024 14:14",
79
"filename" : "AH 6/21/2024 13:54",
810
"filename:" : "AH 6/21/2024 13:55" } }

packages/TelegramClient-Core.package/TCCDocumentMessage.class/properties.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
],
77
"commentStamp" : "<historical>",
88
"instvars" : [
9-
"filename" ],
9+
"filename",
10+
"documentId" ],
1011
"name" : "TCCDocumentMessage",
1112
"pools" : [
1213
],

packages/TelegramClient-Core.package/TCCDocumentStore.class/README.md

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
as yet unclassified
2+
getDocumentFor: aDocumentId
3+
4+
| promise |
5+
promise := self getDocumentPromiseFor: aDocumentId.
6+
promise wait.
7+
^ promise value
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
as yet unclassified
2+
getDocumentPromiseFor: aDocumentId
3+
4+
| promise |
5+
promise := self at: aDocumentId ifAbsent: [
6+
self at: aDocumentId put: Promise new.
7+
self requestFileFor: aDocumentId with: (self at: aDocumentId).
8+
self at: aDocumentId
9+
].
10+
^ promise
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"class" : {
3+
},
4+
"instance" : {
5+
"getDocumentFor:" : "JK 6/26/2024 14:17",
6+
"getDocumentPromiseFor:" : "JK 6/26/2024 14:17" } }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"category" : "TelegramClient-Core",
3+
"classinstvars" : [
4+
],
5+
"classvars" : [
6+
],
7+
"commentStamp" : "",
8+
"instvars" : [
9+
],
10+
"name" : "TCCDocumentStore",
11+
"pools" : [
12+
],
13+
"super" : "TCCFileStore",
14+
"type" : "normal" }

packages/TelegramClient-UI.package/TCUChatPollEditor.class/methodProperties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"class" : {
33
"newFor:withBounds:" : "jkon 6/17/2024 11:14" },
44
"instance" : {
5-
"addChoices" : " 6/24/2024 10:41:19",
5+
"addChoices" : "6/24/2024 10:41:19",
66
"addChoices:" : "jkon 6/19/2024 21:34",
77
"addConfirmButton:" : "jkon 6/18/2024 10:05",
88
"addInputFieldFor:" : "jkon 6/19/2024 21:44",

packages/TelegramClient-UI.package/TCUChatWindow.class/methodProperties.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"addChatTitle" : "RK 8/4/2021 12:06",
99
"addFileButton" : "ED 6/19/2024 10:59",
1010
"addHiddenInfoPage" : "per 6/15/2021 09:02",
11-
"addHiddenPollEditor" : " 6/24/2024 10:41:19",
11+
"addHiddenPollEditor" : "6/24/2024 10:41:19",
1212
"addInputBar" : "ED 6/19/2024 12:20",
1313
"addMemberCount" : "RK 8/4/2021 12:06",
1414
"addPollButton" : "jkon 6/18/2024 13:38",
@@ -45,7 +45,7 @@
4545
"sendButton" : "ek 6/19/2022 18:53",
4646
"sendButton:" : "ek 6/19/2022 18:53",
4747
"showInfoPage" : "per 5/30/2021 11:51",
48-
"showPollEditor" : " 6/24/2024 10:41:19",
48+
"showPollEditor" : "6/24/2024 10:41:19",
4949
"stickerButton" : "JK 5/21/2024 10:04",
5050
"stickerButton:" : "JK 5/21/2024 10:04",
5151
"stickerWindow" : "JK 5/29/2024 14:46",

packages/TelegramClient-UI.package/TCUChoice.class/methodProperties.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"class" : {
33
"newFor:" : "jkon 6/19/2024 18:26",
4-
"newFor:isExclusive:" : " 6/24/2024 10:41:19" },
4+
"newFor:isExclusive:" : "6/24/2024 10:41:19" },
55
"instance" : {
66
"addSelectionMorph" : "jkon 6/19/2024 18:32",
77
"addTextMorph" : "jkon 6/17/2024 15:32",
88
"content" : "jkon 6/17/2024 15:32",
99
"content:" : "jkon 6/17/2024 15:32",
1010
"initialize" : "jkon 6/18/2024 10:03",
11-
"isExclusive" : " 6/24/2024 10:41:19",
12-
"isExclusive:" : " 6/24/2024 10:41:19",
11+
"isExclusive" : "6/24/2024 10:41:19",
12+
"isExclusive:" : "6/24/2024 10:41:19",
1313
"isSelected" : "jkon 6/17/2024 14:52",
1414
"isSelected:" : "jkon 6/17/2024 14:52",
1515
"selectionMorph" : "jkon 6/17/2024 15:20",
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
constructing
22
addIcon
33

4-
| iconForm |
4+
| iconForm iconMorph|
55
iconForm := self class getIcon.
6-
iconForm := iconForm scaledToHeight: self class maxHeight.
7-
self addMorphBack: iconForm asMorph
6+
iconMorph := (iconForm scaledToHeight: self class maxHeight) asMorph.
7+
iconMorph on: #mouseDown send: #moveDocument to: self.
8+
self addMorphBack: iconMorph
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
constructing
2+
moveDocument
3+
4+
| sourceFile destinationFile sourceStream destinationStream |
5+
6+
sourceFile := self messageModel core documentStore getDocumentFor: self messageModel documentId.
7+
destinationFile := (DirectoryChooserDialog openOn:FileDirectory default label: 'Select Directory for download') pathName, '\', self messageModel filename.
8+
Transcript show: destinationFile.
9+
10+
sourceStream := StandardFileStream readOnlyFileNamed: sourceFile.
11+
destinationStream := StandardFileStream newFileNamed: destinationFile.
12+
destinationStream binary.
13+
[sourceStream atEnd] whileFalse: [
14+
destinationStream nextPutAll: (sourceStream next: 1024).
15+
].
16+
sourceStream close.
17+
destinationStream close.

packages/TelegramClient-UI.package/TCUDocumentMessage.class/methodProperties.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
"maxHeight" : "AH 6/21/2024 14:32" },
55
"instance" : {
66
"addContent" : "AH 6/21/2024 14:07",
7-
"addIcon" : "AH 6/21/2024 14:10" } }
7+
"addIcon" : "JK 6/26/2024 12:31",
8+
"moveDocument" : "JK 6/26/2024 14:23" } }

0 commit comments

Comments
 (0)