Skip to content

Commit

Permalink
Merge branch 'bugfix/wrong-shared-objects' into 'devel'
Browse files Browse the repository at this point in the history
Fix flashing wrong shared objects in shared container after upload

Closes #1096 and #1103

See merge request sds-dev/sd-connect/swift-browser-ui!136
  • Loading branch information
mradavi committed Aug 16, 2023
2 parents edc0409 + b988747 commit 35ac177
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
20 changes: 14 additions & 6 deletions swift_browser_ui_frontend/src/common/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ const store = createStore({
actions: {
updateContainers: async function (
{ dispatch },
{ projectID, signal },
{ projectID, signal, routeContainer = undefined },
) {
const existingContainers = await getDB()
.containers.where({ projectID })
Expand Down Expand Up @@ -393,6 +393,15 @@ const store = createStore({
key = await getDB().containers.put(container);
}

if (routeContainer && container.owner) {
if (container.name !== routeContainer &&
container.name !== `${routeContainer}_segments`) {
//Update the object cache only for shared container and segments
//in current route to avoid objects flashing in UI
updateObjects = false;
}
}

if (updateObjects ||
sharingContainers.some(cont => cont === container.name)
) {
Expand All @@ -401,11 +410,10 @@ const store = createStore({
containers_to_update_objects.push({ container, key });
}
}

// Updating objects goes sequentially:
// Update all objects inside a segment_container first
// before updating objects inside original container
const dispatchUpdateOjects = async () => {
const dispatchUpdateObjects = async () => {
for (let i = 0; i < containers_to_update_objects.length; i++) {
const currentContainer = containers_to_update_objects[i];

Expand All @@ -432,7 +440,7 @@ const store = createStore({
}
};

if (containers_to_update_objects.length > 0) dispatchUpdateOjects();
if (containers_to_update_objects.length > 0) dispatchUpdateObjects();
},
updateContainerTags: async function (_, { projectID, containers, signal }) {
for (let i = 0; i < containers.length; i++) {
Expand Down Expand Up @@ -605,7 +613,7 @@ const store = createStore({
}
},
updateSharedObjects: async function (
{ commit, dispatch, state },
{ commit, dispatch },
{ projectID, owner, container, signal },
) {
const isSegmentsContainer = container.name.endsWith("_segments");
Expand Down Expand Up @@ -660,7 +668,7 @@ const store = createStore({
}
}

commit("updateObjects", [...state.objectCache, sharedObjects]);
commit("updateObjects", sharedObjects);

updateContainerLastmodified(projectID, container, sharedObjects);

Expand Down
1 change: 1 addition & 0 deletions swift_browser_ui_frontend/src/components/ObjectTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ export default {
await this.$store.dispatch("updateContainers", {
projectID: this.active.id,
signal: this.abortController.signal,
routeContainer: this.$route.params.container,
});
}, 3000);
},
Expand Down

0 comments on commit 35ac177

Please sign in to comment.