mirror of
https://github.com/usatiuk/photos.git
synced 2025-10-28 23:37:48 +01:00
reset photos when logout
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { Reducer } from "redux";
|
import { Reducer } from "redux";
|
||||||
import { IPhotoReqJSON } from "~../../src/entity/Photo";
|
import { IPhotoReqJSON } from "~../../src/entity/Photo";
|
||||||
|
import { UserAction, UserTypes } from "~redux/user/actions";
|
||||||
import { PhotoAction, PhotoTypes } from "./actions";
|
import { PhotoAction, PhotoTypes } from "./actions";
|
||||||
|
|
||||||
export interface IPhotosState {
|
export interface IPhotosState {
|
||||||
@@ -18,9 +19,11 @@ const defaultPhotosState: IPhotosState = {
|
|||||||
|
|
||||||
export const photosReducer: Reducer<IPhotosState, PhotoAction> = (
|
export const photosReducer: Reducer<IPhotosState, PhotoAction> = (
|
||||||
state: IPhotosState = defaultPhotosState,
|
state: IPhotosState = defaultPhotosState,
|
||||||
action: PhotoAction,
|
action: PhotoAction | UserAction,
|
||||||
) => {
|
) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
case UserTypes.USER_LOGOUT:
|
||||||
|
return defaultPhotosState;
|
||||||
case PhotoTypes.PHOTOS_LOAD_START:
|
case PhotoTypes.PHOTOS_LOAD_START:
|
||||||
return {
|
return {
|
||||||
...defaultPhotosState,
|
...defaultPhotosState,
|
||||||
|
|||||||
Reference in New Issue
Block a user