mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 23:43:15 +01:00
chore: collections and items are in collapsed state on load
This commit is contained in:
parent
8d4c56dbd9
commit
b08ed62378
@ -14,6 +14,7 @@ import {
|
||||
findParentItemInCollection,
|
||||
transformCollectionToSaveToIdb,
|
||||
addDepth,
|
||||
collapseCollection,
|
||||
deleteItemInCollection,
|
||||
isItemARequest,
|
||||
isItemAFolder
|
||||
@ -34,6 +35,7 @@ export const collectionsSlice = createSlice({
|
||||
initialState,
|
||||
reducers: {
|
||||
_loadCollections: (state, action) => {
|
||||
each(action.payload.collections, (c) => collapseCollection(c));
|
||||
each(action.payload.collections, (c) => addDepth(c.items));
|
||||
state.collections = action.payload.collections;
|
||||
},
|
||||
|
@ -28,6 +28,22 @@ export const addDepth = (items = []) => {
|
||||
depth(items, 1);
|
||||
};
|
||||
|
||||
export const collapseCollection = (collection) => {
|
||||
collection.collapsed = true;
|
||||
|
||||
const collapseItem = (items) => {
|
||||
each(items, (i) => {
|
||||
i.collapsed = true;
|
||||
|
||||
if(i.items && i.items.length) {
|
||||
collapseItem(i.items);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
collapseItem(collection.items, 1);
|
||||
};
|
||||
|
||||
export const sortItems = (collection) => {
|
||||
const sort = (obj) => {
|
||||
if(obj.items && obj.items.length) {
|
||||
|
Loading…
Reference in New Issue
Block a user