MCPcopy Create free account
hub / github.com/dailydotdev/apps / BootDataProvider

Function BootDataProvider

packages/shared/src/contexts/BootProvider.tsx:115–417  ·  view source on GitHub ↗
({
  children,
  app,
  version,
  deviceId,
  localBootData,
  getRedirectUri,
  getPage,
}: BootDataProviderProps)

Source from the content-addressed store, hash-verified

113};
114
115export const BootDataProvider = ({
116 children,
117 app,
118 version,
119 deviceId,
120 localBootData,
121 getRedirectUri,
122 getPage,
123}: BootDataProviderProps): ReactElement => {
124 const queryClient = useQueryClient();
125
126 const [initialLoad, setInitialLoad] = useState<boolean>();
127 const [cachedBootData, setCachedBootData] = useState<Partial<Boot>>();
128
129 useEffect(() => {
130 if (localBootData) {
131 setCachedBootData(localBootData);
132
133 return;
134 }
135
136 const boot = getLocalBootData();
137
138 if (!boot) {
139 setCachedBootData(undefined);
140
141 return;
142 }
143
144 if (boot?.settings?.theme) {
145 applyTheme(themeModes[boot.settings.theme]);
146 }
147
148 setCachedBootData(boot);
149 }, [localBootData]);
150
151 const { hostGranted } = useHostStatus();
152 const isExtension = checkIsExtension();
153 const logged = cachedBootData?.user as LoggedUser;
154 const shouldRefetch = !!logged?.providers && !!logged?.id;
155 const lastAppliedChangeRef = useRef<Partial<BootCacheData>>();
156
157 const {
158 data: remoteData,
159 error,
160 refetch,
161 isFetched,
162 isError,
163 dataUpdatedAt,
164 } = useQuery<Partial<Boot>>({
165 queryKey: BOOT_QUERY_KEY,
166 queryFn: async () => {
167 const pathname = globalThis?.location?.pathname;
168 const result = await getBootData({ app, pathname });
169
170 return result;
171 },
172 refetchOnWindowFocus: shouldRefetch,

Callers

nothing calls this directly

Calls 15

applyThemeFunction · 0.90
useHostStatusFunction · 0.90
checkIsExtensionFunction · 0.90
getBootDataFunction · 0.90
useRefreshTokenFunction · 0.90
getApiErrorFunction · 0.90
generateQueryKeyFunction · 0.90
getDailyClientPlatformFunction · 0.90
isIOSNativeFunction · 0.90
isConnectionErrorFunction · 0.90
getLocalBootDataFunction · 0.85
useDebounceFnFunction · 0.85

Tested by

no test coverage detected