tolerate-fails-more

This commit is contained in:
Untone 2024-02-17 17:40:10 +03:00
parent e32e3d31ea
commit 3a6faa65a8
4 changed files with 4 additions and 4 deletions

View File

@ -77,7 +77,7 @@ export const FullArticle = (props: Props) => {
const { t, formatDate, lang } = useLocalize()
const { author, isAuthenticated, requireAuthentication } = useSession()
const formattedDate = createMemo(() => formatDate(new Date(props.article.published_at * 1000)))
const formattedDate = createMemo(() => formatDate(new Date((props.article?.published_at || 0) * 1000)))
const canEdit = () => props.article.authors?.some((a) => Boolean(a) && a?.slug === author()?.slug)
const mainTopic = createMemo(() => {

View File

@ -117,7 +117,7 @@ export const ArticleCard = (props: ArticleCardProps) => {
const { title, subtitle } = getTitleAndSubtitle(props.article)
const formattedDate = createMemo<string>(() =>
props.article.published_at ? formatDate(new Date(props.article.published_at * 1000)) : '',
props.article?.published_at ? formatDate(new Date(props.article.published_at * 1000)) : '',
)
const canEdit = () =>

View File

@ -164,7 +164,7 @@ export const EditorProvider = (props: { children: JSX.Element }) => {
const shout = await updateShout(formToSave, { publish: false })
removeDraftFromLocalStorage(formToSave.shoutId)
if (shout.published_at) {
if (shout?.published_at) {
openPage(router, 'article', { slug: shout.slug })
} else {
openPage(router, 'drafts')

View File

@ -7,7 +7,7 @@ export const byCreated = (a: Shout | Reaction, b: Shout | Reaction) => {
}
export const byPublished = (a: Shout, b: Shout) => {
return a.published_at - b.published_at
return (a?.published_at || 0) - (b?.published_at || 0)
}
export const byLength = (