-
Notifications
You must be signed in to change notification settings - Fork 23
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
Load and Store Friend Schedules from Firebase #187
base: bog-changes-s23
Are you sure you want to change the base?
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a big change to all stages, but it is recommended to not use Effects to transform data.
Read more here - https://react.dev/learn/you-might-not-need-an-effect#how-to-remove-unnecessary-effects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this hook and the equivalent of this hook for schedules can be deleted if we use the use-immer
package. I think it would be a lot better for readability.
The code definitely works, but we need to do more investigation to re-evaluate the stage structure. There's definitely some useEffects which don't need to be there in both the friend stages and the schedule stages, but exactly pin pointing the inefficiencies will take more research in my opinion. |
Addressed in gt-scheduler/firebase-conf/pull/4, but commenting here for more visibility. For every request we're making to |
…site into Samarth/172-load-friend-schedules
Summary
Resolves #171 and #172
We now have a feature that allows users to share schedules with friends. This PR uses the list of friends and their respective versions for a particular term from the
friends
collection to fetch the friend schedules using a firebase cloud function (gt-scheduler/firebase-conf#1). Stages have been added to load this data and extract friend info to prepare data. This PR also creates a contextFriendContext
that holds the friend schedule data as well as relevant setters.Note
AppLoader
and to build theFriendContext
Checklist
Type:
ScheduleData
type.Context:
FriendScheduleContext
(usedFriendContext
instead) is created with appropriate variables and setter functions (similar toScheduleContext
).Hooks:
useRawScheduleDataFromFirebase
).useScheduleDataProducer
).Stages:
src/components/AppDataLoader/stages.tsx
:StageLoadRawFriendScheduleDataFromFirebase
- load data from Firebase using the right hook and pass the variables and setter functions to the producer stage load below (similar toStageLoadRawScheduleDataFromFirebase
)StageLoadFriendScheduleDataProducer
- receive the variables and setter functions, pass them into the Immer producer hook, then pass the results along toContextProvider
(similar toStageLoadScheduleDataProducer
).Feel free to create more (such as a group load like
GroupLoadScheduleData
) to organize your code better.src/components/AppDataLoader/index.tsx
correctly.How to Test
friends
collectionfunctions/src/fetch_friend_schedules.ts
in thegt-scheduler/firebase-config
repo and run the emulator\src\data\hooks\useRawFriendScheduleDataFromFirebaseFunction.ts
to the emulator function link in thegt-scheduler/website
repoFriendContext
anywhere in the code