auth: rename profile.data -> profile.current

This commit is contained in:
James Xylight committed 2025-07-12 10:26:45 -07:00
1 parent 1edad4ac60
commit 36a9631707
76 files changed
+233 -224

No files matched your search

+1 -1
View File
@@ -14,7 +14,7 @@
let loading = $state(false)
async function deleteImage(image: LocalImage) {
if (!profile.data?.jwt) return
if (!profile.current?.jwt) return
try {
loading = true
@@ -50,7 +50,7 @@
let editingLoad = $state(false)
async function save(type: 'reply' | 'edit') {
if (!profile.data?.jwt || newComment.length <= 0) return
if (!profile.current?.jwt || newComment.length <= 0) return
editingLoad = true
@@ -60,7 +60,7 @@
<Icon src={ChatBubbleOvalLeft} size="14" micro />
<span class="text-xs">{$t('comment.reply')}</span>
</Button>
{#if profile.data?.user && (amMod(profile.data?.user, comment.community) || isAdmin(profile.data.user))}
{#if profile.current?.user && (amMod(profile.current?.user, comment.community) || isAdmin(profile.current.user))}
<CommentModerationMenu bind:item={comment} />
{/if}
<Menu placement="bottom">
@@ -90,8 +90,8 @@
<Icon src={Square2Stack} mini size="16" />
<div>{$t('post.actions.more.share')}</div>
</MenuButton>
{#if profile.data?.jwt}
{#if comment.creator.id == profile.data.user?.local_user_view.person.id}
{#if profile.current?.jwt}
{#if comment.creator.id == profile.current.user?.local_user_view.person.id}
<MenuButton onclick={() => onedit?.(comment)}>
<Icon src={PencilSquare} mini size="16" />
<span>{$t('post.actions.more.edit')}</span>
@@ -99,7 +99,7 @@
{/if}
<MenuButton
onclick={async () => {
if (profile.data?.jwt)
if (profile.current?.jwt)
comment.saved = await save(comment, !comment.saved)
}}
>
@@ -108,11 +108,11 @@
{comment.saved ? $t('post.actions.unsave') : $t('post.actions.save')}
</span>
</MenuButton>
{#if profile.data?.user && profile.data.jwt && profile.data.user.local_user_view.person.id == comment.creator.id}
{#if profile.current?.user && profile.current.jwt && profile.current.user.local_user_view.person.id == comment.creator.id}
<MenuButton
color="danger-subtle"
onclick={async () => {
if (profile.data?.jwt)
if (profile.current?.jwt)
comment.comment.deleted = await deleteItem(
comment,
!comment.comment.deleted,
@@ -127,7 +127,7 @@
</span>
</MenuButton>
{/if}
{#if profile.data.jwt && profile.data.user?.local_user_view.person.id != comment.creator.id}
{#if profile.current.jwt && profile.current.user?.local_user_view.person.id != comment.creator.id}
<MenuButton onclick={() => report(comment)} color="danger-subtle">
<Icon src={Flag} mini size="16" />
<span>{$t('moderation.report')}</span>
@@ -51,7 +51,7 @@
let language: number | undefined = $state()
async function submit() {
if (!profile.data?.user || !profile.data?.jwt || value == '') return
if (!profile.current?.user || !profile.current?.jwt || value == '') return
loading = true
@@ -24,7 +24,7 @@
}: Props = $props()
const castVote = async (newVote: number) => {
if (!profile.data?.jwt) {
if (!profile.current?.jwt) {
toast({ content: $t('toast.loginVoteGate'), type: 'warning' })
return
}
@@ -113,7 +113,7 @@
})
async function subscribe() {
if (!profile.data?.jwt) return
if (!profile.current?.jwt) return
loading.subscribing = true
const subscribed =
community_view.subscribed == 'Subscribed' ||
@@ -227,7 +227,7 @@
{/if}
</div>
<div class="flex flex-row items-center gap-1 sticky bottom-0 w-full">
{#if profile.data?.jwt}
{#if profile.current?.jwt}
<Button
disabled={loading.subscribing}
loading={loading.subscribing}
@@ -252,7 +252,7 @@
: $t('cards.community.subscribe')}
</Button>
{/if}
{#if profile.data?.user && amMod(profile.data.user, community_view.community)}
{#if profile.current?.user && amMod(profile.current.user, community_view.community)}
<Button
href="/c/{fullCommunityName(
community_view.community.name,
@@ -278,7 +278,7 @@
<Icon src={Newspaper} size="16" mini />
{$t('cards.community.modlog')}
</MenuButton>
{#if profile.data?.jwt}
{#if profile.current?.jwt}
<MenuButton
color="danger-subtle"
size="lg"
@@ -292,7 +292,7 @@
? $t('cards.community.unblock')
: $t('cards.community.block')}
</MenuButton>
{#if profile.data?.user}
{#if profile.current?.user}
<MenuButton
color="danger-subtle"
size="lg"
@@ -304,7 +304,7 @@
{$t('cards.community.blockInstance')}
</MenuButton>
{/if}
{#if profile.data?.user && isAdmin(profile.data.user)}
{#if profile.current?.user && isAdmin(profile.current.user)}
<MenuButton
color="danger-subtle"
onclick={() =>
@@ -64,7 +64,7 @@
let formData = $state(passedFormData)
async function submit() {
if (!profile.data?.jwt) return
if (!profile.current?.jwt) return
if ((!edit && formData.name == '') || formData.displayName == '') return
formData.submitting = true
@@ -99,23 +99,23 @@
type: 'success',
})
if (profile.data.user) {
const c = profile.data.user.moderates
if (profile.current.user) {
const c = profile.current.user.moderates
.map(m => m.community.id)
.indexOf(res.community_view.community.id)
if (c != -1) {
profile.data.user.moderates[c] = {
profile.current.user.moderates[c] = {
community: res.community_view.community,
moderator: profile.data.user.local_user_view.person,
moderator: profile.current.user.local_user_view.person,
}
} else {
profile.data.user = {
...profile.data.user,
profile.current.user = {
...profile.current.user,
moderates: [
...profile.data.user.moderates,
...profile.current.user.moderates,
{
community: res.community_view.community,
moderator: profile.data.user.local_user_view.person,
moderator: profile.current.user.local_user_view.person,
},
],
}
@@ -115,7 +115,7 @@
</Expandable>
{/if}
<div class="flex items-center gap-2 h-max w-max">
{#if profile.data?.jwt}
{#if profile.current?.jwt}
<Subscribe
community={{
community: community,
@@ -153,7 +153,7 @@
</Subscribe>
{/if}
{#if profile.data?.user && profile.data.user.moderates
{#if profile.current?.user && profile.current.user.moderates
.map(c => c.community.id)
.includes(community.id)}
<Button
@@ -181,7 +181,7 @@
<Icon src={Newspaper} size="16" mini />
{$t('cards.community.modlog')}
</MenuButton>
{#if profile.data.user && amMod(profile.data.user, community)}
{#if profile.current.user && amMod(profile.current.user, community)}
<MenuButton
color="success-subtle"
href="/moderation?community={community.id}"
@@ -190,7 +190,7 @@
{$t('routes.moderation.feed')}
</MenuButton>
{/if}
{#if profile.data?.jwt}
{#if profile.current?.jwt}
<MenuButton
color="danger-subtle"
size="lg"
@@ -203,7 +203,7 @@
? $t('cards.community.unblock')
: $t('cards.community.block')}
</MenuButton>
{#if profile.data?.user}
{#if profile.current?.user}
<MenuButton
color="danger-subtle"
size="lg"
@@ -215,7 +215,7 @@
{$t('cards.community.blockInstance')}
</MenuButton>
{/if}
{#if profile.data?.user && isAdmin(profile.data.user)}
{#if profile.current?.user && isAdmin(profile.current.user)}
<MenuButton
color="danger-subtle"
onclick={() =>
@@ -155,7 +155,7 @@
<Subscribe {community}>
{#snippet children({ subscribe, subscribing })}
<Button
disabled={subscribing || !profile.data?.jwt}
disabled={subscribing || !profile.current?.jwt}
loading={subscribing}
onclick={async () => {
const res = await subscribe()
@@ -51,14 +51,14 @@
<Option value="Local" icon={MapPin}>{$t('filter.location.local')}</Option>
<Option
value="Subscribed"
disabled={profile.data?.jwt == undefined}
disabled={profile.current?.jwt == undefined}
icon={Newspaper}
>
{$t('filter.location.subscribed')}
</Option>
<Option
value="ModeratorView"
disabled={!profile.data?.jwt || !amModOfAny(profile.data?.user)}
disabled={!profile.current?.jwt || !amModOfAny(profile.current?.user)}
icon={ShieldCheck}
>
{$t('filter.location.moderator')}
@@ -23,7 +23,7 @@
avatar
avatarSize={20}
/>
{#if profile.data?.user?.local_user_view.person.id != message.recipient.id}
{#if profile.current?.user?.local_user_view.person.id != message.recipient.id}
to
<UserLink
showInstance={false}
@@ -32,7 +32,7 @@
)
async function upload() {
if (!profile.data?.jwt || image == null) return
if (!profile.current?.jwt || image == null) return
progress = 0
@@ -40,7 +40,7 @@
const uploaded = (
await Promise.all(
Array.from(image).map(i =>
uploadImage(i, profile.data.instance, profile.data.jwt!)
uploadImage(i, profile.current.instance, profile.current.jwt!)
.then(uploaded => {
progress += 1 / (image?.length ?? 0)
return uploaded
@@ -23,7 +23,7 @@
let loading = $state(false)
async function sendMessage() {
if (!profile.data?.jwt || message == '') return
if (!profile.current?.jwt || message == '') return
loading = true
@@ -45,7 +45,7 @@
})
async function submit() {
if (!item || !profile.data?.user || !profile.data?.jwt) return
if (!item || !profile.current?.user || !profile.current?.jwt) return
loading = true
@@ -34,9 +34,9 @@
<ShieldIcon filled width={14} />
</Button>
{/snippet}
{#if (profile.data?.user && amMod(profile.data.user, item.community)) || (profile.data?.user && isAdmin(profile.data.user))}
{#if (profile.current?.user && amMod(profile.current.user, item.community)) || (profile.current?.user && isAdmin(profile.current.user))}
<MenuDivider>
{#if !item.community.local && !amMod(profile.data.user, item.community)}
{#if !item.community.local && !amMod(profile.current.user, item.community)}
{$t('moderation.labelInstanceOnly')}
{:else}
{$t('moderation.label')}
@@ -52,7 +52,7 @@
: $t('moderation.remove')}
{/if}
</MenuButton>
{#if profile.data?.user && profile.data.user?.local_user_view.person.id != item.creator.id}
{#if profile.current?.user && profile.current.user?.local_user_view.person.id != item.creator.id}
<!--Comment made by someone else-->
<MenuButton
color="danger-subtle"
@@ -71,12 +71,12 @@
<MenuButton
color="success-subtle"
onclick={async () => {
if (!profile.data.jwt) return
if (!profile.current.jwt) return
item.comment = (
await feature(
!item.comment.distinguished,
item.comment,
profile.data.jwt,
profile.current.jwt,
)
).comment_view.comment
}}
@@ -104,7 +104,7 @@
</MenuButton>
{/if}
{#if profile.data?.user && isAdmin(profile.data.user)}
{#if profile.current?.user && isAdmin(profile.current.user)}
<MenuDivider>{$t('admin.label')}</MenuDivider>
<MenuButton color="danger-subtle" onclick={() => remove(item, true)}>
{#snippet prefix()}
@@ -32,7 +32,7 @@
let acting = $derived(locking || pinning)
async function lock(lock: boolean) {
if (!profile.data?.jwt || !isPostView(item)) return
if (!profile.current?.jwt || !isPostView(item)) return
locking = true
try {
@@ -53,7 +53,7 @@
}
async function pin(pinned: boolean, toInstance: boolean = false) {
if (!profile.data?.jwt || !isPostView(item)) return
if (!profile.current?.jwt || !isPostView(item)) return
pinning = true
@@ -88,9 +88,9 @@
<ShieldIcon filled width={16} />
</Button>
{/snippet}
{#if (profile.data?.user && amMod(profile.data.user, item.community)) || (profile.data?.user && isAdmin(profile.data.user))}
{#if (profile.current?.user && amMod(profile.current.user, item.community)) || (profile.current?.user && isAdmin(profile.current.user))}
<MenuDivider>
{#if !item.community.local && !amMod(profile.data.user, item.community)}
{#if !item.community.local && !amMod(profile.current.user, item.community)}
{$t('moderation.labelInstanceOnly')}
{:else}
{$t('moderation.label')}
@@ -124,7 +124,7 @@
? $t('moderation.unfeature')
: $t('moderation.feature')}
</span>
{#if isAdmin(profile.data.user)}
{#if isAdmin(profile.current.user)}
<span class="text-xs opacity-80">{$t('form.post.community')}</span>
{/if}
</div>
@@ -139,7 +139,7 @@
{item.post.removed ? $t('moderation.restore') : $t('moderation.remove')}
{/if}
</MenuButton>
{#if profile.data?.user && profile.data.user.local_user_view.person.id != item.creator.id}
{#if profile.current?.user && profile.current.user.local_user_view.person.id != item.creator.id}
<MenuButton
color="danger-subtle"
onclick={() =>
@@ -164,7 +164,7 @@
{$t('moderation.votes')}
</MenuButton>
{/if}
{#if profile.data?.user && isAdmin(profile.data.user)}
{#if profile.current?.user && isAdmin(profile.current.user)}
<MenuDivider>{$t('admin.label')}</MenuDivider>
<MenuButton
color="success-subtle"
@@ -76,7 +76,7 @@
async function remove() {
if (!item) return
if (!profile.data?.jwt) throw new Error('Unauthenticated')
if (!profile.current?.jwt) throw new Error('Unauthenticated')
loading = true
@@ -216,7 +216,7 @@
bind:value={reason}
/>
{#if !removed && profile.data?.user && (amMod(profile.data.user, item.community) || (isAdmin(profile.data.user) && item.community.local))}
{#if !removed && profile.current?.user && (amMod(profile.current.user, item.community) || (isAdmin(profile.current.user) && item.community.local))}
<Switch bind:checked={commentReason}>
{$t('moderation.removeSubmission.withReason')}
</Switch>
@@ -39,7 +39,7 @@
let reason = $state('')
async function report() {
if (!item || !profile.data?.jwt || reason == '') return
if (!item || !profile.current?.jwt || reason == '') return
loading = true
try {
+1 -1
View File
@@ -117,7 +117,7 @@
user={post.creator}
published={publishedToDate(post.post.published)}
{badges}
subscribed={profile.data?.user?.follows
subscribed={profile.current?.user?.follows
.map(c => c.community.id)
.includes(post.community.id)
? 'Subscribed'
@@ -117,8 +117,8 @@
score={post.counts.score}
upvotes={post.counts.upvotes}
downvotes={post.counts.downvotes}
showCounts={profile.data?.user?.local_user_view?.local_user?.show_scores ??
true}
showCounts={profile.current?.user?.local_user_view?.local_user
?.show_scores ?? true}
/>
<Button
@@ -160,7 +160,7 @@
{/snippet}
</Button>
{/if}
{#if profile.data?.user && (amMod(profile.data.user, post.community) || isAdmin(profile.data.user))}
{#if profile.current?.user && (amMod(profile.current.user, post.community) || isAdmin(profile.current.user))}
<ModerationMenu
size="custom"
color="ghost"
@@ -171,10 +171,10 @@
/>
{/if}
{#if profile.data?.jwt}
{#if profile.current?.jwt}
<Button
onclick={async () => {
if (!profile.data?.jwt) return
if (!profile.current?.jwt) return
saving = true
post.saved = await save(post, !post.saved)
saving = false
@@ -228,7 +228,7 @@
<MenuDivider>
{$t('post.actions.more.actions')}
</MenuDivider>
{#if profile.data?.user && profile.data?.jwt && profile.data.user.local_user_view.person.id == post.creator.id}
{#if profile.current?.user && profile.current?.jwt && profile.current.user.local_user_view.person.id == post.creator.id}
<MenuButton onclick={() => (editing = true)}>
{#snippet prefix()}
<Icon src={PencilSquare} size="16" micro />
@@ -236,10 +236,10 @@
{$t('post.actions.more.edit')}
</MenuButton>
{/if}
{#if profile.data?.jwt}
{#if profile.current?.jwt}
<MenuButton
onclick={async () => {
if (profile.data?.jwt)
if (profile.current?.jwt)
post.read = await markAsRead(post.post, !post.read)
}}
>
@@ -297,7 +297,7 @@
</div>
{/if}
</MenuButton>
{#if profile.data?.jwt}
{#if profile.current?.jwt}
<MenuButton
onclick={() => {
setSessionStorage('postDraft', {
@@ -326,10 +326,10 @@
{/snippet}
{$t('post.actions.more.crosspost')}
</MenuButton>
{#if profile.data.user && post.creator.id == profile.data.user.local_user_view.person.id}
{#if profile.current.user && post.creator.id == profile.current.user.local_user_view.person.id}
<MenuButton
onclick={async () => {
if (profile.data?.jwt)
if (profile.current?.jwt)
post.post.deleted = await deleteItem(post, !post.post.deleted)
}}
color="danger-subtle"
@@ -342,15 +342,15 @@
: $t('post.actions.more.delete')}
</MenuButton>
{/if}
{#if profile.data.user?.local_user_view.person.id != post.creator.id}
{#if profile.current.user?.local_user_view.person.id != post.creator.id}
{#if feature('hidePosts', site.data?.version)}
<MenuButton
onclick={async () => {
if (!profile.data?.jwt) return
if (!profile.current?.jwt) return
const hidden = await hidePost(
post.post.id,
!post.hidden,
profile.data?.jwt,
profile.current?.jwt,
)
post.hidden = hidden
if (hidden) onhide?.(hidden)
@@ -51,7 +51,7 @@
let loading = $state(false)
const castVote = async (newVote: number) => {
if (!profile.data?.jwt) {
if (!profile.current?.jwt) {
toast({ content: $t('toast.loginVoteGate'), type: 'warning' })
return
}
@@ -134,7 +134,7 @@
})
return
}
if (!data.title || !profile.data?.jwt) return
if (!data.title || !profile.current?.jwt) return
if (data.url && data.url != '') {
try {
new URL(data.url)
@@ -275,7 +275,7 @@
<ObjectAutocomplete
bind:q={communitySearch}
items={communities}
jwt={profile.data?.jwt}
jwt={profile.current?.jwt}
listing_type="All"
label={$t('form.post.community')}
required
@@ -42,7 +42,7 @@
).users.map(c => c.person)
if (hideOwnUser) {
const myself = profile.data.user?.local_user_view.person.id
const myself = profile.current.user?.local_user_view.person.id
return users.filter(c => c.id != myself)
}
return users