Skip to content

Commit 5165245

Browse files
markeriksontimdorr
authored andcommitted
Clear posts on auth logout
# Conflicts: # src/features/posts/postsSlice.ts
1 parent fbcf522 commit 5165245

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/features/posts/postsSlice.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { sub } from 'date-fns'
33

44
import type { RootState } from '@/app/store'
55

6+
import { userLoggedOut } from '@/features/auth/authSlice'
7+
68
export interface Reactions {
79
thumbsUp: number
810
tada: number
@@ -88,6 +90,12 @@ const postsSlice = createSlice({
8890
}
8991
},
9092
},
93+
extraReducers: (builder) => {
94+
builder.addCase(userLoggedOut, (state) => {
95+
// Clear out the list of posts whenever the user logs out
96+
return []
97+
})
98+
},
9199
})
92100

93101
export const { postAdded, postUpdated, reactionAdded } = postsSlice.actions

0 commit comments

Comments
 (0)