AbhishekA
Convex Community2y ago
28 replies
Abhishek

Why my Convex simple query is taking too long?

Here is the next js log the GET req takes around 2233ms. Currently in dev mode

Is there a problem with my implementation or am I doing something wrong?

here is the component :

export default async function LinkedInConnectButton() {
  const token = await getAuthToken();
  const userAccessTokenExist = await fetchQuery(
    api.users.getUserToken,
    {},
    { token }
  );

  async function linkedInAction() {
    "use server";
    const redirectUrl = process.env.LINKEDIN_REDIRECT_URL;
    const oauthApi = `link`;
    redirect(oauthApi, RedirectType.push);
  }
  async function unlinkAction() {
    "use server";
    await fetchMutation(api.users.deleteUserToken, {}, { token });
    revalidatePath("/dashboard/settings");
  }

  return (
    <div className="flex justify-between items-center w-full py-3 px-6 rounded-sm border-t border-sky-500/20 bg-sky-500/20">
      <div className="flex items-center justify-center gap-2 text-sm">
        <Image src="/linkedin-icon.svg" alt="twitter" height={28} width={28} />
        <span className="text-md">LinkedIn</span>
      </div>
      {!userAccessTokenExist ? (
        <form action={linkedInAction}>
          <button className="group hover:bg-sky-500/80 rounded-md shadow-md bg-sky-500 text-white px-2 py-1.5 text-sm flex justify-between items-center gap-1 duration-150">
            <PlusCircleIcon
              height={20}
              widths={20}
              strokeWidth={1.5}
              color="white"
              fill="rgb(56 189 248 )"
              fillOpacity={50}
            />
            <span className="">Add Account</span>
          </button>
        </form>
      ) : (
        <form action={unlinkAction}>
          <UnLinkedbutton />
        </form>
      )}
    </div>
  );
}
image.png
Was this page helpful?