Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Commit

Permalink
Fix upload file doesn't work when folder is not refreshed
Browse files Browse the repository at this point in the history
  • Loading branch information
Yamazaki93 committed Jun 23, 2019
1 parent 3b2a190 commit 9cb1531
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion app/frontend/src/app/aws-s3/services/s3.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class S3Service {
ItemAdded: EventEmitter<{ parents: string[], item: S3Item }> = new EventEmitter<{ parents: string[], item: S3Item }>();
DownloadPath: Observable<string>;
private _cachedItems: { [key: string]: S3Item[] } = {}
private _cachedAccounts: { [key: string]: IAccount } = {}
private _downloadPath = new BehaviorSubject('');
constructor(
private electron: ElectronService,
Expand All @@ -40,7 +41,7 @@ export class S3Service {
});
});
this.electron.onCD('S3-ObjectListed', (event: string, arg: any) => {
let items = []
let items: S3Item[] = []
if (arg.objects) {
items = arg.objects.map(_ => {
return {
Expand Down Expand Up @@ -69,6 +70,7 @@ export class S3Service {
}));
}
this._cachedItems[arg.parents.join('/')] = items;
this._cachedAccounts[arg.parents[0]] = arg.account;
this.ItemsEnumerated.emit({
account: arg.account,
parents: arg.parents,
Expand Down Expand Up @@ -109,6 +111,10 @@ export class S3Service {
return [];
}
}
getCachedAccount(key: string): IAccount {
let acc = this._cachedAccounts[key];
return acc;
}

listBuckets(account: IAccount) {
this.electron.send('S3-ListBuckets', account);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class FolderBrowserComponent extends SubscriptionComponent implements OnI
let segmentNames = segments.join('/');
this.currentPath = segmentNames;
this.items = this.s3.getCachedItems(this.currentPath);
this.account = this.s3.getCachedAccount(segments[0].path);
}));
this.recordSubscription(this.s3.RefreshingObjects.subscribe(res => {
let segmentNames = res.parents.join('/');
Expand All @@ -53,7 +54,6 @@ export class FolderBrowserComponent extends SubscriptionComponent implements OnI
}));
this.recordSubscription(this.s3.ItemsEnumerated.subscribe(result => {
this.account = result.account;
console.log(result);
let parents = result.parents.slice();
let parentPath = parents.join('/');
if (parentPath === this.currentPath) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "s3uploader",
"version": "0.1.0",
"version": "0.2.0-rc.0",
"description": "An UI for AWS S3",
"displayName": "S3Uploader",
"author": {
Expand Down Expand Up @@ -31,6 +31,7 @@
"build": {
"appId": "com.rhodiumcode.s3uploader",
"productName": "S3Uploader",
"generateUpdatesFilesForAllChannels": true,
"files": [
"**/*",
"!**/node_modules/*/{CHANGELOG.md,README.md,README,readme.md,readme}",
Expand Down

0 comments on commit 9cb1531

Please sign in to comment.