-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚡️ Fetch achievements data at iframe creation (#992)
* ⚡️ Fetch achievements data at iframe creation * 🔥 Remove useless useCallback dep * ⚡️ Move data from app component to context * 🐛 Fix pinned icons not updated when changing profile * 💄 Code style * ✨ Refetch events every 5 minutes
- Loading branch information
Showing
9 changed files
with
87 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { createContext, useState, ReactNode } from "react"; | ||
import { useAchievements } from "@/hooks/achievements"; | ||
|
||
type DataContextType = { | ||
trophies: ReturnType<typeof useAchievements>; | ||
setAccountAddress: (address: string | undefined) => void; | ||
}; | ||
|
||
const initialState: DataContextType = { | ||
trophies: { | ||
achievements: [], | ||
players: [], | ||
isLoading: false, | ||
}, | ||
setAccountAddress: () => {}, | ||
}; | ||
|
||
export const DataContext = createContext<DataContextType>(initialState); | ||
|
||
export function DataProvider({ children }: { children: ReactNode }) { | ||
const [accountAddress, setAccountAddress] = useState<string | undefined>( | ||
undefined, | ||
); | ||
|
||
const trophies = useAchievements(accountAddress); | ||
|
||
return ( | ||
<DataContext.Provider value={{ trophies, setAccountAddress }}> | ||
{children} | ||
</DataContext.Provider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { ConnectionContext } from "./connection"; | ||
export { DataContext } from "./data"; | ||
export { ThemeContext } from "./theme"; | ||
export { Provider } from "./provider"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters