perf: stop merging routers twice. (#21538)
* move away from merging twice * move to use loggedIn Router directly * fix router outputs types * fix mocks in create button with teasm tests --------- Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
1 parent
ed4b3f082a
commit
08e35e4698
13 files changed
+93
-82
No files matched your search
@@ -13,7 +13,9 @@ export function CreateButtonWithTeamsList(
|
||||
includeOrg?: boolean;
|
||||
}
|
||||
) {
|
||||
const query = trpc.viewer.teamsAndUserProfilesQuery.useQuery({ includeOrg: props.includeOrg });
|
||||
const query = trpc.viewer.loggedInViewerRouter.teamsAndUserProfilesQuery.useQuery({
|
||||
includeOrg: props.includeOrg,
|
||||
});
|
||||
if (!query.data) return null;
|
||||
|
||||
const teamsAndUserProfiles: Option[] = query.data
|
||||
|
||||
+21
-17
@@ -22,11 +22,13 @@ vi.mock("next/navigation", async (importOriginal) => {
|
||||
const runtimeMock = async (data: Array<any>) => {
|
||||
const updatedTrpc = {
|
||||
viewer: {
|
||||
teamsAndUserProfilesQuery: {
|
||||
useQuery() {
|
||||
return {
|
||||
data: data,
|
||||
};
|
||||
loggedInViewerRouter: {
|
||||
teamsAndUserProfilesQuery: {
|
||||
useQuery() {
|
||||
return {
|
||||
data: data,
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -51,18 +53,20 @@ describe("Create Button Tests", () => {
|
||||
vi.mock("@calcom/trpc/react", () => ({
|
||||
trpc: {
|
||||
viewer: {
|
||||
teamsAndUserProfilesQuery: {
|
||||
useQuery() {
|
||||
return {
|
||||
data: [
|
||||
{
|
||||
teamId: 1,
|
||||
name: "test",
|
||||
slug: "create-button-test",
|
||||
image: "image",
|
||||
},
|
||||
],
|
||||
};
|
||||
loggedInViewerRouter: {
|
||||
teamsAndUserProfilesQuery: {
|
||||
useQuery() {
|
||||
return {
|
||||
data: [
|
||||
{
|
||||
teamId: 1,
|
||||
name: "test",
|
||||
slug: "create-button-test",
|
||||
image: "image",
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -27,8 +27,10 @@ export function WebPushProvider({ children }: ProviderProps) {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [isSubscribed, setIsSubscribed] = useState(false);
|
||||
|
||||
const { mutate: addSubscription } = trpc.viewer.addNotificationsSubscription.useMutation();
|
||||
const { mutate: removeSubscription } = trpc.viewer.removeNotificationsSubscription.useMutation();
|
||||
const { mutate: addSubscription } =
|
||||
trpc.viewer.loggedInViewerRouter.addNotificationsSubscription.useMutation();
|
||||
const { mutate: removeSubscription } =
|
||||
trpc.viewer.loggedInViewerRouter.removeNotificationsSubscription.useMutation();
|
||||
|
||||
useEffect(() => {
|
||||
if (!("serviceWorker" in navigator)) return;
|
||||
|
||||
Reference in new issue
Block a user