web/satellite: fix demo-bucket creation issue
Store demo-bucket creation status in browser local store so that it's not created every time when user enters buckets screen. It will start working after first usage in new browser. So if user removes bucket in Chrome and opens Buckets screen in Firefox demo-bucket will be created but only once. Change-Id: I9f5811d97ab6208c5f757ededcd7c36cd864795c
This commit is contained in:
parent
16480c97da
commit
fc074b693b
@ -74,6 +74,7 @@ import { DEMO_BUCKET_NAME, OBJECTS_ACTIONS } from '@/store/modules/objects';
|
||||
import { AccessGrant, EdgeCredentials } from '@/types/accessGrants';
|
||||
import { MetaUtils } from '@/utils/meta';
|
||||
import { Validator } from '@/utils/validation';
|
||||
import { LocalData } from "@/utils/localData";
|
||||
|
||||
// @vue/component
|
||||
@Component({
|
||||
@ -132,12 +133,20 @@ export default class BucketsView extends Vue {
|
||||
await this.setAccess();
|
||||
await this.fetchBuckets();
|
||||
|
||||
if (!this.bucketsList.length) await this.createDemoBucket();
|
||||
const wasDemoBucketCreated = LocalData.getDemoBucketCreatedStatus();
|
||||
|
||||
if (this.bucketsList.length && !wasDemoBucketCreated) {
|
||||
LocalData.setDemoBucketCreatedStatus();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!wasDemoBucketCreated) await this.createDemoBucket();
|
||||
} catch (error) {
|
||||
await this.$notify.error(`Failed to setup Buckets view. ${error.message}`);
|
||||
} finally {
|
||||
this.isLoading = false;
|
||||
}
|
||||
|
||||
this.isLoading = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -262,6 +271,8 @@ export default class BucketsView extends Vue {
|
||||
await this.$store.dispatch(OBJECTS_ACTIONS.CREATE_DEMO_BUCKET);
|
||||
if (this.isNewObjectsFlow) {
|
||||
await this.$store.dispatch(OBJECTS_ACTIONS.FETCH_BUCKETS);
|
||||
|
||||
LocalData.setDemoBucketCreatedStatus();
|
||||
this.isRequestProcessing = false;
|
||||
|
||||
return;
|
||||
@ -273,6 +284,7 @@ export default class BucketsView extends Vue {
|
||||
return;
|
||||
}
|
||||
|
||||
LocalData.setDemoBucketCreatedStatus();
|
||||
this.isRequestProcessing = false;
|
||||
|
||||
this.openBucket(DEMO_BUCKET_NAME);
|
||||
|
@ -9,6 +9,7 @@ export class LocalData {
|
||||
private static selectedProjectId = 'selectedProjectId';
|
||||
private static userIdPassSalt = 'userIdPassSalt';
|
||||
private static serverSideEncryptionAcknowledge = 'serverSideEncryptionAcknowledge';
|
||||
private static demoBucketCreated = 'demoBucketCreated';
|
||||
|
||||
public static getUserId(): string | null {
|
||||
return localStorage.getItem(LocalData.userId);
|
||||
@ -50,6 +51,17 @@ export class LocalData {
|
||||
|
||||
localStorage.setItem(LocalData.userIdPassSalt, JSON.stringify(data));
|
||||
}
|
||||
|
||||
public static getDemoBucketCreatedStatus(): string | null {
|
||||
const status = localStorage.getItem(LocalData.demoBucketCreated);
|
||||
if (!status) return null;
|
||||
|
||||
return JSON.parse(status)
|
||||
}
|
||||
|
||||
public static setDemoBucketCreatedStatus(): void {
|
||||
localStorage.setItem(LocalData.demoBucketCreated, "true");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user