Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always showing the same post items #9

Open
anoels opened this issue Mar 21, 2020 · 0 comments
Open

Always showing the same post items #9

anoels opened this issue Mar 21, 2020 · 0 comments

Comments

@anoels
Copy link

anoels commented Mar 21, 2020

Hello,

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!
            }
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant