community-platform icon indicating copy to clipboard operation
community-platform copied to clipboard

refactor: convert discussion store to a service

Open mariojsnunes opened this issue 1 year ago • 2 comments

@thisislawatts the goal of this PR is to understand how hard it is to migrate stores to services. And it was straightforward... fetch and add are working. Maybe you could use this code on https://github.com/ONEARMY/community-platform/pull/3102?

Some notes:

  • need to decide what's the best approach to access the activeUser, here I passed it as an argument from the main component.
  • unsure if this is the best way to invoke firestore

About <DiscussionContainer /> I think we should refactor it to contain all the discussion related CRUD methods, to avoid all this: image But I understand it would only be possible when research and howto modules are also migrated.

mariojsnunes avatar Jan 06 '24 22:01 mariojsnunes

Thanks for sharing @mariojsnunes, would you be able to define what you mean by service here?

thisislawatts avatar Jan 07 '24 17:01 thisislawatts

Thanks for sharing @mariojsnunes, would you be able to define what you mean by service here?

Just a collection of methods for doing API requests (firestore in this case). Unlike a store, it doesn't keep state.

mariojsnunes avatar Jan 07 '24 18:01 mariojsnunes