Closed darioielardi closed 4 years ago
I don't see the above code using feathers-offline-realtime. What am I missing?
Sorry for not being clear, the 'postClient' service is an offline realtime service, configured with optimistic mutator:
const posts = client.service('posts')
export const postsRealtime = new Realtime(posts, { uuid: true })
client.use('postsClient', optimisticMutator({ replicator: postsRealtime }))
postsRealtime.connect()
If I use the 'posts' service directly, this behavior does not occur.
Actual behavior
I have two redux-thunk actions: one to fetch my user's post list, and another one to create a post. Both use an offline service, configured as indicated in docs.
When I create a post, createPostSuccess is dispatched with the new post ( the local copy ) as the payload, and the reducer return [...state, action.payload], so everything works fine. But when I navigate to another route and then come back to posts page, the fetchPosts action is dispatched but as the payload it has the posts list with the new one created ( by the server ) AND the local copy of the same new post, so this new post is duplicated.
Expected behavior
When fetchPosts is dispatched, posts list is returned with the new post ( the one created by the server if there's connection or the local copy if there's not, NOT BOTH ).
I can't figure out what happen, any suggestion? Thanks for the great work.