refactor: rename

This commit is contained in:
三咲智子 2023-01-03 18:57:18 +08:00
parent 8af8abfc9f
commit 66295199b4
No known key found for this signature in database
GPG key ID: 69992F2250DFD93E
10 changed files with 15 additions and 15 deletions

View file

@ -3,7 +3,7 @@ setupPageHeader()
provideGlobalCommands() provideGlobalCommands()
// We want to trigger rerendering the page when account changes // We want to trigger rerendering the page when account changes
const key = computed(() => currentUser.value ? getUniqueUserId(currentUser.value) : '') const key = computed(() => getUniqueUserId(currentUser.value))
</script> </script>
<template> <template>

View file

@ -7,7 +7,7 @@ const { account, command, ...props } = defineProps<{
command?: boolean command?: boolean
}>() }>()
const isSelf = $computed(() => checkUser(currentUser.value) && currentUser.value.account.id === account.id) const isSelf = $computed(() => checkAuth(currentUser.value) && currentUser.value.account.id === account.id)
const enable = $computed(() => !isSelf && !isGuest.value) const enable = $computed(() => !isSelf && !isGuest.value)
const relationship = $computed(() => props.relationship || useRelationship(account).value) const relationship = $computed(() => props.relationship || useRelationship(account).value)

View file

@ -60,7 +60,7 @@ watchEffect(() => {
iconFields.value = icons iconFields.value = icons
}) })
const isSelf = $computed(() => checkUser(currentUser.value) && currentUser.value.account.id === account.id) const isSelf = $computed(() => checkAuth(currentUser.value) && currentUser.value.account.id === account.id)
</script> </script>
<template> <template>

View file

@ -7,7 +7,7 @@ const { account } = defineProps<{
}>() }>()
let relationship = $(useRelationship(account)) let relationship = $(useRelationship(account))
const isSelf = $computed(() => checkUser(currentUser.value) && currentUser.value.account.id === account.id) const isSelf = $computed(() => checkAuth(currentUser.value) && currentUser.value.account.id === account.id)
const masto = useMasto() const masto = useMasto()
const toggleMute = async () => { const toggleMute = async () => {

View file

@ -23,7 +23,7 @@ const clipboard = useClipboard()
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const isAuthor = $computed(() => checkUser(currentUser.value) && status.account.id === currentUser.value.account.id) const isAuthor = $computed(() => checkAuth(currentUser.value) && status.account.id === currentUser.value.account.id)
const { const {
toggle: _toggleTranslation, toggle: _toggleTranslation,

View file

@ -24,7 +24,7 @@ const account = isSelf ? computed(() => status.account) : useAccountById(status.
<template v-if="!collapsed"> <template v-if="!collapsed">
<AccountAvatar <AccountAvatar
v-if="isSelf || simplified v-if="isSelf || simplified
|| (checkUser(currentUser) && status.inReplyToAccountId === currentUser?.account.id)" || (checkAuth(currentUser) && status.inReplyToAccountId === currentUser?.account.id)"
:account="account" :link="false" w-5 h-5 mx-0.5 :account="account" :link="false" w-5 h-5 mx-0.5
/> />
<AccountInlineInfo v-else :account="account" :link="false" mx-0.5 /> <AccountInlineInfo v-else :account="account" :link="false" mx-0.5 />

View file

@ -97,7 +97,7 @@ async function subscribe(
async function unsubscribeFromBackend(fromSWPushManager: boolean, removePushNotification = true) { async function unsubscribeFromBackend(fromSWPushManager: boolean, removePushNotification = true) {
const cu = currentUser.value const cu = currentUser.value
if (checkUser(cu)) { if (checkAuth(cu)) {
await removePushNotifications(cu) await removePushNotifications(cu)
removePushNotification && await removePushNotificationData(cu, fromSWPushManager) removePushNotification && await removePushNotificationData(cu, fromSWPushManager)
} }
@ -105,7 +105,7 @@ async function unsubscribeFromBackend(fromSWPushManager: boolean, removePushNoti
async function removePushNotificationDataOnError(e: Error) { async function removePushNotificationDataOnError(e: Error) {
const cu = currentUser.value const cu = currentUser.value
if (checkUser(cu)) if (checkAuth(cu))
await removePushNotificationData(cu, true) await removePushNotificationData(cu, true)
throw e throw e

View file

@ -109,7 +109,7 @@ export const usePushManager = () => {
} }
const unsubscribe = async () => { const unsubscribe = async () => {
if (!isSupported || !isSubscribed || !checkUser(currentUser.value)) if (!isSupported || !isSubscribed || !checkAuth(currentUser.value))
return false return false
await removePushNotifications(currentUser.value) await removePushNotifications(currentUser.value)
@ -117,7 +117,7 @@ export const usePushManager = () => {
} }
const saveSettings = async (policy?: SubscriptionPolicy) => { const saveSettings = async (policy?: SubscriptionPolicy) => {
if (!checkUser(currentUser.value)) if (!checkAuth(currentUser.value))
return return
if (policy) if (policy)
@ -136,7 +136,7 @@ export const usePushManager = () => {
} }
const undoChanges = () => { const undoChanges = () => {
if (!checkUser(currentUser.value)) if (!checkAuth(currentUser.value))
return return
const current = pushNotificationData.value const current = pushNotificationData.value

View file

@ -70,8 +70,8 @@ export const currentServer = computed<string>(() => currentUser.value.server)
export const currentInstance = computed<null | Instance>(() => { export const currentInstance = computed<null | Instance>(() => {
return instances.value[currentServer.value] ?? null return instances.value[currentServer.value] ?? null
}) })
export const checkUser = (val: UserLogin | undefined): val is UserLogin<true> => !!(val && !val.guest) export const checkAuth = (val: UserLogin | undefined): val is UserLogin<true> => !!(val && !val.guest)
export const isGuest = computed(() => !checkUser(currentUser.value)) export const isGuest = computed(() => !checkAuth(currentUser.value))
export const getUniqueUserId = (user: UserLogin) => export const getUniqueUserId = (user: UserLogin) =>
user.guest ? `${GUEST_ID}@${user.server}` : user.account.id user.guest ? `${GUEST_ID}@${user.server}` : user.account.id
export const isSameUser = (a: UserLogin | undefined, b: UserLogin | undefined) => export const isSameUser = (a: UserLogin | undefined, b: UserLogin | undefined) =>
@ -264,7 +264,7 @@ export async function signout() {
if (!users.value.some((u, i) => u.server === currentUser.value.server && i !== index)) if (!users.value.some((u, i) => u.server === currentUser.value.server && i !== index))
delete instances.value[currentUser.value.server] delete instances.value[currentUser.value.server]
if (checkUser(currentUser.value)) { if (checkAuth(currentUser.value)) {
await removePushNotifications(currentUser.value) await removePushNotifications(currentUser.value)
await removePushNotificationData(currentUser.value) await removePushNotificationData(currentUser.value)
} }

View file

@ -24,7 +24,7 @@ const wideLayout = computed(() => route.meta.wideLayout ?? false)
<UserPicker v-if="showUserPicker" /> <UserPicker v-if="showUserPicker" />
<div v-else flex="~" items-center justify-between> <div v-else flex="~" items-center justify-between>
<NuxtLink <NuxtLink
v-if="checkUser(currentUser)" v-if="checkAuth(currentUser)"
hidden xl:block hidden xl:block
rounded-full text-start w-full rounded-full text-start w-full
hover:bg-active cursor-pointer transition-100 hover:bg-active cursor-pointer transition-100