Skip to content

Commit

Permalink
remove GH api star check
Browse files Browse the repository at this point in the history
  • Loading branch information
vincanger committed Oct 30, 2023
1 parent f389ad2 commit 83e6237
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 52 deletions.
5 changes: 0 additions & 5 deletions wasp-ai/main.wasp
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,6 @@ query getStats {
]
}

query checkIfUserStarredWasp {
fn: import { checkIfUserStarredWasp } from "@server/operations.js",
entities: [Project]
}

query getNumProjects {
fn: import { getNumProjects } from "@server/operations.js",
entities: [
Expand Down
2 changes: 1 addition & 1 deletion wasp-ai/src/client/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function Header({ currentStatus, isStatusVisible, isUserPage, setIsLoginM
<RxQuestionMarkCircled className="text-base text-slate-600" />
</a>

<div className="relative group">
<div className="flex items-center relative group">
<button
onClick={() => {
if (!user) {
Expand Down
23 changes: 6 additions & 17 deletions wasp-ai/src/client/pages/MainPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import useAuth from "@wasp/auth/useAuth";
import { SignInButton as GitHubSignInButton } from "@wasp/auth/helpers/GitHub";
import { useQuery } from "@wasp/queries";
import getProjectsByUser from "@wasp/queries/getProjectsByUser";
import checkIfUserStarredWasp from "@wasp/queries/checkIfUserStarredWasp";

const MainPage = () => {
const [appName, setAppName] = useState("");
Expand All @@ -30,11 +29,6 @@ const MainPage = () => {
const history = useHistory();
const { data: user } = useAuth();
const { data: userProjects } = useQuery(getProjectsByUser, {}, { enabled: !!user });
const { data: hasUserStarredWasp } = useQuery(
checkIfUserStarredWasp,
{ username: user?.username },
{ enabled: !!user }
);

const availableCreativityLevels = useMemo(
() => [
Expand Down Expand Up @@ -85,10 +79,10 @@ const MainPage = () => {
const [appAuthMethod, setAppAuthMethod] = useState(availableAuthMethods[0]);

useEffect(() => {
if (!hasUserStarredWasp && userProjects?.length >= 1) {
if (userProjects?.length > 0 && userProjects.length % 2 === 0) {
setIsAskForStarsModalOpen(true);
}
}, [hasUserStarredWasp]);
}, [userProjects]);

useEffect(() => {
try {
Expand Down Expand Up @@ -252,28 +246,23 @@ export function AskForStarsModal({ isOpen, setIsOpen }) {
onClose={() => setIsOpen(false)}
title={<span>With Great Power Comes Great Responsibility! 🧙</span>}
>
<div className="mt-6 space-y-5">
<div className="mt-6 space-y-2">
<p className="text-base leading-relaxed text-gray-500">
We've made this tool completely <span className="font-semibold">free</span> and cover all the costs 😇
Mage is completely <span className="font-semibold">free</span> and we cover all the costs.
</p>

<p className="text-base leading-relaxed text-gray-500">
But you can still show your support by starring us on GitHub:
But if you enjoy using it, please consider starring the project on GitHub:
</p>
<a
href="https://github.com/wasp-lang/wasp"
target="_blank"
className="flex items-center justify-center underline text-pink-600 "
>
<div className="py-4 px-2 flex items-center justify-center bg-pink-50 text-pink-800 rounded-lg font-semibold tracking-wide w-full">
<div className="mt-4 py-4 px-2 flex items-center justify-center bg-pink-50 text-pink-800 rounded-lg font-semibold tracking-wide w-full">
<PiStarDuotone size="1.35rem" className="mr-3" /> Star Wasp on GitHub{" "}
<PiGithubLogoDuotone size="1.35rem" className="ml-3" />
</div>
</a>
<p className="text-base leading-relaxed text-gray-500">
This helps spread the word, so we can keep making Mage better.
</p>
<p className="text-base leading-relaxed text-gray-500">We'd very much appreciate it! 🧙</p>
</div>
</MyDialog>
);
Expand Down
2 changes: 1 addition & 1 deletion wasp-ai/src/client/pages/UserPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function UserPage({ user }) {
</tr>
</thead>
<tbody>
{projects?.length &&
{projects?.length > 0 &&
projects.map((project) => (
<tr className="bg-white border-t" key={project.id}>
<th
Expand Down
28 changes: 0 additions & 28 deletions wasp-ai/src/server/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,31 +224,3 @@ export const getProjectsByUser: GetProjectsByUser<void, Project[]> = async (_arg
},
});
};

import { CheckIfUserStarredWasp } from "@wasp/queries/types";

export const checkIfUserStarredWasp: CheckIfUserStarredWasp<{ username: string }, boolean> = async (
{ username },
context
) => {
if (!context.user) {
throw new HttpError(401, "Not authorized");
}
let status = false;
try {
const response = await fetch(`https://api.github.com/user/starred/wasp-lang/wasp`, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(username + ":" + process.env.GITHUB_PERSONAL_ACCESS_TOKEN),
},
});
console.log(response.status);
if (response.status === 204) {
status = true;
}
} catch (error) {
console.error("Error:", error);
} finally {
return status;
}
};

0 comments on commit 83e6237

Please sign in to comment.