Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fetch-title'
Browse files Browse the repository at this point in the history
  • Loading branch information
sharunkumar committed Oct 28, 2023
2 parents 696dfcc + 2b6b525 commit 5a1790d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions src/features/post/new/PostEditorRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,19 +331,23 @@ export default function PostEditorRoot({
}

async function fetchPostTitle() {
let metadata;

try {
const { metadata } = await client.getSiteMetadata({
({ metadata } = await client.getSiteMetadata({
url,
});

if (metadata.title) {
setTitle(metadata.title?.slice(0, MAX_TITLE_LENGTH));
} else {
presentToast(problemFetchingTitle);
}
}));
} catch (error) {
presentToast(problemFetchingTitle);
throw error;
}

if (!metadata.title) {
presentToast(problemFetchingTitle);
return;
}

setTitle(metadata.title?.slice(0, MAX_TITLE_LENGTH));
}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/toastMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const problemBlockingUser: AppToastOptions = {

export const problemFetchingTitle: AppToastOptions = {
message: "Unable to fetch title",
color: "danger",
color: "warning",
};

export function buildBlocked(
Expand Down

0 comments on commit 5a1790d

Please sign in to comment.