Skip to content

Commit

Permalink
merge: #4025
Browse files Browse the repository at this point in the history
4025: fix(web): Ensure we don't serve the assetId from local storage r=stack72 a=stack72



Co-authored-by: stack72 <[email protected]>
  • Loading branch information
si-bors-ng[bot] and stack72 authored Jun 22, 2024
2 parents c6fc79d + 7fd0220 commit c0790d7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 28 deletions.
9 changes: 0 additions & 9 deletions app/web/src/store/asset.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { watch } from "vue";
import { defineStore } from "pinia";
import * as _ from "lodash-es";
import { addStoreHooks, ApiRequest } from "@si/vue-lib/pinia";
import storage from "local-storage-fallback"; // drop-in storage polyfill which falls back to cookies/memory
import { useWorkspacesStore } from "@/store/workspaces.store";
import { FuncKind } from "@/api/sdf/dal/func";
import { Visibility } from "@/api/sdf/dal/visibility";
Expand Down Expand Up @@ -106,8 +105,6 @@ export type AssetCreateRequest = Omit<
>;
export type AssetCloneRequest = Visibility & { id: AssetId };

const LOCAL_STORAGE_LAST_SELECTED_ASSET_ID_KEY = "si-open-asset-id";

export const assetDisplayName = (asset: Asset | AssetListEntry) =>
(asset.displayName ?? "").length === 0 ? asset.name : asset.displayName;

Expand Down Expand Up @@ -270,12 +267,6 @@ export const useAssetStore = () => {
}
},

getLastSelectedAssetId(): AssetId | undefined {
return storage.getItem(
LOCAL_STORAGE_LAST_SELECTED_ASSET_ID_KEY,
) as AssetId;
},

openFunc(assetId: AssetId, funcId: FuncId) {
const funcs = this.openAssetFuncIds[assetId] ?? [];
if (!funcs.includes(funcId)) {
Expand Down
36 changes: 19 additions & 17 deletions app/web/src/store/components.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,23 +530,25 @@ export const useComponentsStore = (forceChangeSetId?: ChangeSetId) => {
const schemaVariants = [];
for (const schema of this.schemas) {
for (const variant of schema.variants) {
if (!_.find(schemaVariants, { id: variant.id })) {
schemaVariants.push({
id: variant.id,
name: variant.name,
builtin: variant.builtin,
isDefault: true,
componentType: variant.componentType,
color: variant.color,
category: variant.category,
inputSockets: variant.inputSockets,
outputSockets: variant.outputSockets,
updated_at: variant.updated_at,
created_at: variant.created_at,
displayName: variant.displayName,
description: variant.description,
schemaName: schema.name,
});
if (variant.isDefault) {
if (!_.find(schemaVariants, { id: variant.id })) {
schemaVariants.push({
id: variant.id,
name: variant.name,
builtin: variant.builtin,
isDefault: true,
componentType: variant.componentType,
color: variant.color,
category: variant.category,
inputSockets: variant.inputSockets,
outputSockets: variant.outputSockets,
updated_at: variant.updated_at,
created_at: variant.created_at,
displayName: variant.displayName,
description: variant.description,
schemaName: schema.name,
});
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/web/src/store/func/funcs.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ export const useFuncStore = () => {
if (data.changeSetId !== selectedChangeSetId) return;
this.FETCH_FUNC_LIST();

const assetId = assetStore.getLastSelectedAssetId();
const assetId = assetStore.selectedAssetId;
if (
assetId &&
this.selectedFuncId &&
Expand All @@ -814,7 +814,7 @@ export const useFuncStore = () => {
this.FETCH_FUNC_LIST();

// Reload the last selected asset to ensure that its func list is up to date.
const assetId = assetStore.getLastSelectedAssetId();
const assetId = assetStore.selectedAssetId;
if (assetId) {
assetStore.LOAD_ASSET(assetId);
}
Expand Down

0 comments on commit c0790d7

Please sign in to comment.