Skip to content

Commit

Permalink
added document store, download dowcument into selected directory on c…
Browse files Browse the repository at this point in the history
…lick on document message icon
  • Loading branch information
jkubuni committed Jun 26, 2024
1 parent 8c4f4a2 commit 9ff61ab
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
documentStore: aDocumentStore

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

^ documentStore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ initialize
imageStore: (TCCImageStore newWith: self);
videoStore: (TCCVideoStore newWith: self);
stickerStore: (TCCStickerStore newWith: self);
documentStore: (TCCDocumentStore newWith: self);
callbackCounter: 0.

"Mac users report serious slowdowns when receiveLoop is running at lower priority"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"checkAuthenticationPassword:" : "aka 5/21/2022 11:31",
"client" : "R.S 5/20/2020 16:08",
"client:" : "pk 8/5/2021 16:39",
"documentStore" : "JK 6/26/2024 14:19",
"documentStore:" : "JK 6/26/2024 14:19",
"freeClient" : "6/9/2021 14:12:18",
"generateCallbackId" : "pk 8/5/2021 17:04",
"getOwnProfile" : "pk 8/5/2021 17:05",
Expand All @@ -22,7 +24,7 @@
"handlePendingEvent:" : "per 8/2/2021 15:05",
"imageStore" : "pk 6/19/2021 17:15",
"imageStore:" : "TR 6/22/2021 09:33",
"initialize" : "JK 6/20/2024 22:16",
"initialize" : "JK 6/26/2024 14:18",
"initializeHandlers" : "RS 8/1/2021 12:53",
"isClientAlive" : "js 5/28/2020 17:18",
"loggedInUserId" : "pk 8/5/2021 17:04",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"callbackCounter",
"userStore",
"videoStore",
"stickerStore" ],
"stickerStore",
"documentStore" ],
"name" : "TCCCore",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ newFrom: aJsonObject

^ self new
filename: ((aJsonObject at: 'document') at: 'file_name');
documentId: (((aJsonObject at: 'document') at: 'document') at: 'id');
yourself
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
documentId: aNumber

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

^ documentId
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"class" : {
"newFrom:" : "JK 6/23/2024 11:52" },
"newFrom:" : "JK 6/26/2024 14:23" },
"instance" : {
"asSnippet" : "AH 6/21/2024 13:54",
"asText" : "AH 6/21/2024 13:54",
"documentId" : "JK 6/26/2024 14:14",
"documentId:" : "JK 6/26/2024 14:14",
"filename" : "AH 6/21/2024 13:54",
"filename:" : "AH 6/21/2024 13:55" } }
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
],
"commentStamp" : "<historical>",
"instvars" : [
"filename" ],
"filename",
"documentId" ],
"name" : "TCCDocumentMessage",
"pools" : [
],
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
as yet unclassified
getDocumentFor: aDocumentId

| promise |
promise := self getDocumentPromiseFor: aDocumentId.
promise wait.
^ promise value
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
as yet unclassified
getDocumentPromiseFor: aDocumentId

| promise |
promise := self at: aDocumentId ifAbsent: [
self at: aDocumentId put: Promise new.
self requestFileFor: aDocumentId with: (self at: aDocumentId).
self at: aDocumentId
].
^ promise
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"class" : {
},
"instance" : {
"getDocumentFor:" : "JK 6/26/2024 14:17",
"getDocumentPromiseFor:" : "JK 6/26/2024 14:17" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "TelegramClient-Core",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "TCCDocumentStore",
"pools" : [
],
"super" : "TCCFileStore",
"type" : "normal" }
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"class" : {
"newFor:withBounds:" : "jkon 6/17/2024 11:14" },
"instance" : {
"addChoices" : " 6/24/2024 10:41:19",
"addChoices" : "6/24/2024 10:41:19",
"addChoices:" : "jkon 6/19/2024 21:34",
"addConfirmButton:" : "jkon 6/18/2024 10:05",
"addInputFieldFor:" : "jkon 6/19/2024 21:44",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"addChatTitle" : "RK 8/4/2021 12:06",
"addFileButton" : "ED 6/19/2024 10:59",
"addHiddenInfoPage" : "per 6/15/2021 09:02",
"addHiddenPollEditor" : " 6/24/2024 10:41:19",
"addHiddenPollEditor" : "6/24/2024 10:41:19",
"addInputBar" : "ED 6/19/2024 12:20",
"addMemberCount" : "RK 8/4/2021 12:06",
"addPollButton" : "jkon 6/18/2024 13:38",
Expand Down Expand Up @@ -45,7 +45,7 @@
"sendButton" : "ek 6/19/2022 18:53",
"sendButton:" : "ek 6/19/2022 18:53",
"showInfoPage" : "per 5/30/2021 11:51",
"showPollEditor" : " 6/24/2024 10:41:19",
"showPollEditor" : "6/24/2024 10:41:19",
"stickerButton" : "JK 5/21/2024 10:04",
"stickerButton:" : "JK 5/21/2024 10:04",
"stickerWindow" : "JK 5/29/2024 14:46",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"class" : {
"newFor:" : "jkon 6/19/2024 18:26",
"newFor:isExclusive:" : " 6/24/2024 10:41:19" },
"newFor:isExclusive:" : "6/24/2024 10:41:19" },
"instance" : {
"addSelectionMorph" : "jkon 6/19/2024 18:32",
"addTextMorph" : "jkon 6/17/2024 15:32",
"content" : "jkon 6/17/2024 15:32",
"content:" : "jkon 6/17/2024 15:32",
"initialize" : "jkon 6/18/2024 10:03",
"isExclusive" : " 6/24/2024 10:41:19",
"isExclusive:" : " 6/24/2024 10:41:19",
"isExclusive" : "6/24/2024 10:41:19",
"isExclusive:" : "6/24/2024 10:41:19",
"isSelected" : "jkon 6/17/2024 14:52",
"isSelected:" : "jkon 6/17/2024 14:52",
"selectionMorph" : "jkon 6/17/2024 15:20",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
constructing
addIcon

| iconForm |
| iconForm iconMorph|
iconForm := self class getIcon.
iconForm := iconForm scaledToHeight: self class maxHeight.
self addMorphBack: iconForm asMorph
iconMorph := (iconForm scaledToHeight: self class maxHeight) asMorph.
iconMorph on: #mouseDown send: #moveDocument to: self.
self addMorphBack: iconMorph
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
constructing
moveDocument

| sourceFile destinationFile sourceStream destinationStream |

sourceFile := self messageModel core documentStore getDocumentFor: self messageModel documentId.
destinationFile := (DirectoryChooserDialog openOn:FileDirectory default label: 'Select Directory for download') pathName, '\', self messageModel filename.
Transcript show: destinationFile.

sourceStream := StandardFileStream readOnlyFileNamed: sourceFile.
destinationStream := StandardFileStream newFileNamed: destinationFile.
destinationStream binary.
[sourceStream atEnd] whileFalse: [
destinationStream nextPutAll: (sourceStream next: 1024).
].
sourceStream close.
destinationStream close.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
"maxHeight" : "AH 6/21/2024 14:32" },
"instance" : {
"addContent" : "AH 6/21/2024 14:07",
"addIcon" : "AH 6/21/2024 14:10" } }
"addIcon" : "JK 6/26/2024 12:31",
"moveDocument" : "JK 6/26/2024 14:23" } }

0 comments on commit 9ff61ab

Please sign in to comment.