Skip to content
Snippets Groups Projects
Unverified Commit 501f4d1a authored by Alexander Polyankin's avatar Alexander Polyankin Committed by GitHub
Browse files

Fix archiving and making bookmarked collections official (#24174)

parent 2b2f4667
Branches
Tags
No related merge requests found
import { assoc, dissoc } from "icepick";
import { assoc, updateIn, dissoc } from "icepick";
import _ from "underscore";
import { createSelector } from "reselect";
import { createEntity } from "metabase/lib/entities";
......@@ -47,15 +47,26 @@ const Bookmarks = createEntity({
},
reducer: (state = {}, { type, payload, error }) => {
if (type === Questions.actionTypes.UPDATE && payload?.object?.archived) {
const key = "card-" + payload?.object?.id;
const key = `card-${payload.object.id}`;
return dissoc(state, key);
}
if (type === Dashboards.actionTypes.UPDATE && payload?.object?.archived) {
const key = "dashboard-" + payload?.object?.id;
const key = `dashboard-${payload.object.id}`;
return dissoc(state, key);
}
if (type === Collections.actionTypes.UPDATE && payload?.object) {
const { id, authority_level } = payload.object;
const key = `collection-${id}`;
if (payload.object.archived) {
return dissoc(state, key);
} else {
return updateIn(state, [key], item => ({ ...item, authority_level }));
}
}
if (type === Bookmarks.actionTypes.REORDER) {
const indexes = payload.reduce((indexes, bookmark, index) => {
indexes[bookmark.id] = index;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment