Skip to content

Commit

Permalink
chore: add a user feedback in case if an error (#171)
Browse files Browse the repository at this point in the history
undefined
  • Loading branch information
a0m0rajab authored Jun 11, 2023
1 parent 8ce3724 commit 98d0681
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/popup/pages/posthighlight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,23 @@ const PostOnHighlight = ({ prUrl, prTitle }: { prUrl: string, prTitle: string })
const [highlightContent, setHighlightContent] = useState("");
const [isSendButtonEnabled, enableSendButton] = useState(true);

const generateAiDescription = async () => {
const toastId = toast.loading("Generating summary...");

const generateAiDescription = () => {
enableSendButton(false);
const description = await getAiDescription(prUrl);
const description = getAiDescription(prUrl);

toast.dismiss(toastId);
setHighlightContent(description);
enableSendButton(true);
toast.promise(description, {
loading: "Generating summary...",
success: data => {
enableSendButton(true);
setHighlightContent(data);

return "Successfully Generated Summary";
},
error: e => {
enableSendButton(true);
return `Uh oh, there was an error! ${e.message}`;
},
}).catch(console.error);
};


Expand Down

0 comments on commit 98d0681

Please sign in to comment.