-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from biensupernice/chore/update-trpc
Update to tRPC v10
- Loading branch information
Showing
12 changed files
with
756 additions
and
950 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
import { inferQueryOutput, trpc } from "@/utils/trpc"; | ||
import { EpisodeRouter } from "@/server/router"; | ||
import { trpc } from "@/utils/trpc"; | ||
import { inferRouterOutputs } from "@trpc/server"; | ||
|
||
export type ITrack = inferQueryOutput<"episodes.all">[number]; | ||
export type RouterOutput = inferRouterOutputs<EpisodeRouter>; | ||
export type ITrack = RouterOutput["episodes.all"][number]; | ||
|
||
export function useEpisodes() { | ||
return trpc.useQuery(["episodes.all", { collective: "all" }], { | ||
refetchOnWindowFocus: false, | ||
}); | ||
return trpc["episodes.all"].useQuery( | ||
{ collective: "all" }, | ||
{ | ||
refetchOnWindowFocus: false, | ||
} | ||
); | ||
} | ||
|
||
export function useEpisode(id: string | undefined) { | ||
const { getQueryData } = trpc.useContext(); | ||
const utils = trpc.useUtils(); | ||
const getData = utils["episodes.all"].getData; | ||
|
||
if (!id) { | ||
return null; | ||
} | ||
const eps = getQueryData(["episodes.all"]) ?? []; | ||
const eps = getData() ?? []; | ||
|
||
return eps.filter((e) => e._id === id)?.[0] || null; | ||
} | ||
|
||
export function useGetEpisode(id: string) { | ||
const { getQueryData } = trpc.useContext(); | ||
const utils = trpc.useUtils(); | ||
const getData = utils["episodes.all"].getData; | ||
|
||
const eps = getQueryData(["episodes.all", { collective: "all" }]) ?? []; | ||
const eps = getData({ collective: "all" }) ?? []; | ||
return eps.filter((e) => e._id === id)[0]; | ||
} |
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
Oops, something went wrong.
8985ee3
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.
Deploy preview for soulector ready!
✅ Preview
https://soulector-3fzd4rpgv-jalvarado91.vercel.app
Built with commit 8985ee3.
This pull request is being automatically deployed with vercel-action