Load and Store Friend Schedules from Firebase#187
Load and Store Friend Schedules from Firebase#187samarth52 wants to merge 12 commits intobog-changes-s23from
Conversation
|
yatharth-b
left a comment
There was a problem hiding this comment.
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.
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
friendscollection 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 contextFriendContextthat holds the friend schedule data as well as relevant setters.Note
AppLoaderand to build theFriendContextChecklist
Type:
ScheduleDatatype.Context:
FriendScheduleContext(usedFriendContextinstead) 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.tsxcorrectly.How to Test
friendscollectionfunctions/src/fetch_friend_schedules.tsin thegt-scheduler/firebase-configrepo and run the emulator\src\data\hooks\useRawFriendScheduleDataFromFirebaseFunction.tsto the emulator function link in thegt-scheduler/websiterepoFriendContextanywhere in the code