fix: invalid dates
This commit is contained in:
1 parent
facb1081c9
commit
0d08df2ad5
7 files changed
+23
-19
No files matched your search
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
||||
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
import { getInstance } from '$lib/lemmy.js'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import type { CommentView } from 'lemmy-js-client'
|
||||
@@ -23,7 +24,7 @@
|
||||
deleted={false}
|
||||
featured={false}
|
||||
nsfw={comment.post.nsfw}
|
||||
published={new Date(comment.post.published + 'Z')}
|
||||
published={publishedToDate(comment.comment.published)}
|
||||
saved={false}
|
||||
community={community ? comment.community : undefined}
|
||||
/>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
import ExpandableImage from '$lib/components/ui/ExpandableImage.svelte'
|
||||
import { bestImageURL, postLink } from '$lib/components/lemmy/post/helpers.js'
|
||||
import Empty from '$lib/components/helper/Empty.svelte'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
|
||||
export let post: PostView
|
||||
export let actions: boolean = true
|
||||
@@ -48,7 +49,7 @@
|
||||
<PostMeta
|
||||
community={hideCommunity ? undefined : post.community}
|
||||
user={post.creator}
|
||||
published={new Date(post.post.published + 'Z')}
|
||||
published={publishedToDate(post.post.published)}
|
||||
upvotes={post.counts.upvotes}
|
||||
downvotes={post.counts.downvotes}
|
||||
deleted={post.post.deleted}
|
||||
|
||||
@@ -22,12 +22,7 @@
|
||||
{#if avatar}
|
||||
<Avatar url={user.avatar} alt={user.name} width={avatarSize} />
|
||||
{/if}
|
||||
<span
|
||||
class="flex flex-wrap gap-0"
|
||||
class:ml-0.5={avatar}
|
||||
class:text-red-500={user.admin}
|
||||
class:font-bold={user.admin}
|
||||
>
|
||||
<span class="flex flex-wrap gap-0" class:ml-0.5={avatar}>
|
||||
<span class:font-medium={showInstance}>
|
||||
{user.display_name || user.name}
|
||||
</span>
|
||||
@@ -38,11 +33,6 @@
|
||||
{/if}
|
||||
</span>
|
||||
{#if badges}
|
||||
{#if user.admin}
|
||||
<div class="text-red-500" title="Admin">
|
||||
<ShieldIcon width={12} filled />
|
||||
</div>
|
||||
{/if}
|
||||
{#if user.banned}
|
||||
<div class="text-red-500" title="Banned">
|
||||
<Icon src={NoSymbol} mini size="12" />
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { routes } from '$lib/util.js'
|
||||
|
||||
export let route: { id: string } | undefined = undefined
|
||||
|
||||
$: title = route ? routes[(route.id as keyof typeof routes) ?? ''] : ''
|
||||
</script>
|
||||
@@ -1,2 +1,9 @@
|
||||
export const publishedToDate = (published: string) =>
|
||||
published.endsWith('Z') ? new Date(published) : new Date(`${published}Z`)
|
||||
export const publishedToDate = (published: string): Date => {
|
||||
console.log(published)
|
||||
published.endsWith('Z')
|
||||
? console.log('includes a z. Not doing anything.')
|
||||
: console.log("doesn't include a z. adding it.")
|
||||
return published.endsWith('Z')
|
||||
? new Date(published)
|
||||
: new Date(`${published}Z`)
|
||||
}
|
||||
@@ -33,9 +33,6 @@
|
||||
class="flex items-center gap-1 text-green-600 dark:text-green-400 font-medium"
|
||||
>
|
||||
<UserLink showInstance={true} avatar user={item.moderator} />
|
||||
{#if !item.moderator.admin}
|
||||
<ShieldIcon filled width={16} />
|
||||
{/if}
|
||||
</span>
|
||||
{/if}
|
||||
{#if item.moderatee}
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { feature } from '$lib/version.js'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
|
||||
export let data
|
||||
|
||||
@@ -162,7 +163,7 @@
|
||||
featured={post.post_view.post.featured_community ||
|
||||
post.post_view.post.featured_local}
|
||||
nsfw={post.post_view.post.nsfw}
|
||||
published={new Date(post.post_view.post.published + 'Z')}
|
||||
published={publishedToDate(post.post_view.post.published)}
|
||||
saved={post.post_view.saved}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user