I don't know where I am doing wrong at. The problem is that there is a timeline, showing all posts from users a user following, and a profile view, which needs to show only the current user's post. But it also shows the posts of the following users.
Should I make a separate reducer as well as action and state? The following is my current reducer.
enum PostsReducer {
static var reducer: Reducer<PostsState> {
return { action, state in
guard let action = action as? PostsAction else {
return state ?? PostsState()
}
var newState = state
switch action {
case let .updatePosts(userID, posts):
newState?.userPosts[userID] = posts
return newState!
case let .updateListener(userID, listener):
newState?.postsListeners?[userID] = listener
return newState!
case let .updateUserPosts(posts):
newState?.posts = posts
return newState!
case let .updateUserListener(listener):
newState?.userPostsListener = listener
return newState!
}
}
}
}