Cleanup the store on the initial load call (#970)
This commit is contained in:
parent
1f36db5579
commit
9d4da24e6c
5 changed files with 14 additions and 0 deletions
|
@ -37,6 +37,8 @@ const boardsSlice = createSlice({
|
|||
},
|
||||
extraReducers: (builder) => {
|
||||
builder.addCase(initialReadOnlyLoad.fulfilled, (state, action) => {
|
||||
state.boards = {}
|
||||
state.templates = {}
|
||||
for (const block of action.payload) {
|
||||
if (block.type === 'board' && block.fields.isTemplate) {
|
||||
state.templates[block.id] = block as Board
|
||||
|
@ -46,6 +48,8 @@ const boardsSlice = createSlice({
|
|||
}
|
||||
})
|
||||
builder.addCase(initialLoad.fulfilled, (state, action) => {
|
||||
state.boards = {}
|
||||
state.templates = {}
|
||||
for (const block of action.payload.blocks) {
|
||||
if (block.type === 'board' && block.fields.isTemplate) {
|
||||
state.templates[block.id] = block as Board
|
||||
|
|
|
@ -57,6 +57,8 @@ const cardsSlice = createSlice({
|
|||
},
|
||||
extraReducers: (builder) => {
|
||||
builder.addCase(initialReadOnlyLoad.fulfilled, (state, action) => {
|
||||
state.cards = {}
|
||||
state.templates = {}
|
||||
for (const block of action.payload) {
|
||||
if (block.type === 'card' && block.fields.isTemplate) {
|
||||
state.templates[block.id] = block as Card
|
||||
|
@ -66,6 +68,8 @@ const cardsSlice = createSlice({
|
|||
}
|
||||
})
|
||||
builder.addCase(initialLoad.fulfilled, (state, action) => {
|
||||
state.cards = {}
|
||||
state.templates = {}
|
||||
for (const block of action.payload.blocks) {
|
||||
if (block.type === 'card' && block.fields.isTemplate) {
|
||||
state.templates[block.id] = block as Card
|
||||
|
|
|
@ -25,6 +25,7 @@ const commentsSlice = createSlice({
|
|||
},
|
||||
extraReducers: (builder) => {
|
||||
builder.addCase(initialReadOnlyLoad.fulfilled, (state, action) => {
|
||||
state.comments = {}
|
||||
for (const block of action.payload) {
|
||||
if (block.type === 'comment') {
|
||||
state.comments[block.id] = block as CommentBlock
|
||||
|
@ -32,6 +33,7 @@ const commentsSlice = createSlice({
|
|||
}
|
||||
})
|
||||
builder.addCase(initialLoad.fulfilled, (state, action) => {
|
||||
state.comments = {}
|
||||
for (const block of action.payload.blocks) {
|
||||
if (block.type === 'comment') {
|
||||
state.comments[block.id] = block as CommentBlock
|
||||
|
|
|
@ -26,6 +26,7 @@ const contentsSlice = createSlice({
|
|||
},
|
||||
extraReducers: (builder) => {
|
||||
builder.addCase(initialReadOnlyLoad.fulfilled, (state, action) => {
|
||||
state.contents = {}
|
||||
for (const block of action.payload) {
|
||||
if (block.type !== 'board' && block.type !== 'view' && block.type !== 'comment') {
|
||||
state.contents[block.id] = block as ContentBlock
|
||||
|
@ -33,6 +34,7 @@ const contentsSlice = createSlice({
|
|||
}
|
||||
})
|
||||
builder.addCase(initialLoad.fulfilled, (state, action) => {
|
||||
state.contents = {}
|
||||
for (const block of action.payload.blocks) {
|
||||
if (block.type !== 'board' && block.type !== 'view' && block.type !== 'comment') {
|
||||
state.contents[block.id] = block as ContentBlock
|
||||
|
|
|
@ -37,6 +37,7 @@ const viewsSlice = createSlice({
|
|||
},
|
||||
extraReducers: (builder) => {
|
||||
builder.addCase(initialReadOnlyLoad.fulfilled, (state, action) => {
|
||||
state.views = {}
|
||||
for (const block of action.payload) {
|
||||
if (block.type === 'view') {
|
||||
state.views[block.id] = block as BoardView
|
||||
|
@ -44,6 +45,7 @@ const viewsSlice = createSlice({
|
|||
}
|
||||
})
|
||||
builder.addCase(initialLoad.fulfilled, (state, action) => {
|
||||
state.views = {}
|
||||
for (const block of action.payload.blocks) {
|
||||
if (block.type === 'view') {
|
||||
state.views[block.id] = block as BoardView
|
||||
|
|
Loading…
Reference in a new issue