refactor (client): replace confusing expressions like $i != null
This commit is contained in:
parent
7cd615f0f7
commit
8f956f4978
43 changed files with 184 additions and 186 deletions
|
@ -12,9 +12,6 @@ import { reloadChannel, unisonReload } from "@/scripts/unison-reload";
|
|||
|
||||
export type Account = firefish.entities.MeDetailed;
|
||||
|
||||
export const iAmModerator = $i != null && ($i.isAdmin || $i.isModerator);
|
||||
export const iAmAdmin = $i?.isAdmin;
|
||||
|
||||
export async function signout() {
|
||||
waiting();
|
||||
localStorage.removeItem("account");
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<i :class="icon('ph-dots-three-outline')"></i>
|
||||
</button>
|
||||
<button
|
||||
v-if="$i != null && $i.id != user.id"
|
||||
v-if="isSignedIn && $i.id != user.id"
|
||||
v-tooltip="full ? null : `${state} ${user.name || user.username}`"
|
||||
class="kpoogebi _button follow-button"
|
||||
:class="{
|
||||
|
@ -66,7 +66,7 @@ import type * as firefish from "firefish-js";
|
|||
import * as os from "@/os";
|
||||
import { stream } from "@/stream";
|
||||
import { i18n } from "@/i18n";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
import { getUserMenu } from "@/scripts/get-user-menu";
|
||||
import { useRouter } from "@/router";
|
||||
import { vibrate } from "@/scripts/vibrate";
|
||||
|
|
|
@ -35,9 +35,8 @@
|
|||
|
||||
<script lang="ts" setup>
|
||||
import { toUnicode } from "punycode";
|
||||
import {} from "vue";
|
||||
import { host as localHost } from "@/config";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
import { defaultStore } from "@/store";
|
||||
|
||||
const props = defineProps<{
|
||||
|
@ -53,7 +52,7 @@ const canonical =
|
|||
const url = `/${canonical}`;
|
||||
|
||||
const isMe =
|
||||
$i &&
|
||||
isSignedIn &&
|
||||
`@${props.username}@${toUnicode(props.host)}` ===
|
||||
`@${$i.username}@${toUnicode(localHost)}`.toLowerCase();
|
||||
</script>
|
||||
|
|
|
@ -225,7 +225,7 @@
|
|||
<XQuoteButton class="button" :note="appearNote" />
|
||||
<button
|
||||
v-if="
|
||||
$i != null &&
|
||||
isSignedIn &&
|
||||
isForeignLanguage &&
|
||||
translation == null
|
||||
"
|
||||
|
@ -294,7 +294,7 @@ import { userPage } from "@/filters/user";
|
|||
import * as os from "@/os";
|
||||
import { defaultStore, noteViewInterruptors } from "@/store";
|
||||
import { reactionPicker } from "@/scripts/reaction-picker";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
import { i18n } from "@/i18n";
|
||||
import { getNoteMenu } from "@/scripts/get-note-menu";
|
||||
import { useNoteCapture } from "@/scripts/use-note-capture";
|
||||
|
@ -353,7 +353,7 @@ const reactButton = ref<HTMLElement>();
|
|||
const appearNote = computed(() =>
|
||||
isRenote ? (note.value.renote as firefish.entities.Note) : note.value,
|
||||
);
|
||||
const isMyRenote = $i && $i.id === note.value.userId;
|
||||
const isMyRenote = isSignedIn && $i.id === note.value.userId;
|
||||
const showContent = ref(false);
|
||||
const isDeleted = ref(false);
|
||||
const muted = ref(
|
||||
|
|
|
@ -126,7 +126,7 @@
|
|||
<XQuoteButton class="button" :note="appearNote" />
|
||||
<button
|
||||
v-if="
|
||||
$i != null &&
|
||||
isSignedIn &&
|
||||
isForeignLanguage &&
|
||||
translation == null
|
||||
"
|
||||
|
@ -210,7 +210,7 @@ import { useRouter } from "@/router";
|
|||
import { userPage } from "@/filters/user";
|
||||
import * as os from "@/os";
|
||||
import { reactionPicker } from "@/scripts/reaction-picker";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
import { i18n } from "@/i18n";
|
||||
import { useNoteCapture } from "@/scripts/use-note-capture";
|
||||
import { defaultStore } from "@/store";
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<MkButton
|
||||
v-else-if="
|
||||
!showOnlyToRegister &&
|
||||
($i ? pushRegistrationInServer : pushSubscription)
|
||||
(isSignedIn ? pushRegistrationInServer : pushSubscription)
|
||||
"
|
||||
type="button"
|
||||
:primary="false"
|
||||
|
@ -31,7 +31,7 @@
|
|||
{{ i18n.ts.unsubscribePushNotification }}
|
||||
</MkButton>
|
||||
<MkButton
|
||||
v-else-if="$i && pushRegistrationInServer"
|
||||
v-else-if="isSignedIn && pushRegistrationInServer"
|
||||
disabled
|
||||
:rounded="rounded"
|
||||
:inline="inline"
|
||||
|
@ -56,7 +56,7 @@
|
|||
import { ref } from "vue";
|
||||
|
||||
import { getAccounts } from "@/account";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
import MkButton from "@/components/MkButton.vue";
|
||||
import { instance } from "@/instance";
|
||||
import { api, apiWithDialog, promiseDialog } from "@/os";
|
||||
|
@ -147,7 +147,7 @@ async function unsubscribe() {
|
|||
|
||||
pushRegistrationInServer.value = undefined;
|
||||
|
||||
if ($i && accounts.length >= 2) {
|
||||
if (isSignedIn && accounts.length >= 2) {
|
||||
apiWithDialog("sw/unregister", {
|
||||
i: $i.token,
|
||||
endpoint,
|
||||
|
@ -193,7 +193,12 @@ if (navigator.serviceWorker == null) {
|
|||
pushSubscription.value =
|
||||
await registration.value.pushManager.getSubscription();
|
||||
|
||||
if (instance.swPublickey && "PushManager" in window && $i && $i.token) {
|
||||
if (
|
||||
instance.swPublickey &&
|
||||
"PushManager" in window &&
|
||||
isSignedIn &&
|
||||
$i.token
|
||||
) {
|
||||
supported.value = true;
|
||||
|
||||
if (pushSubscription.value) {
|
||||
|
|
|
@ -28,7 +28,7 @@ import XDetails from "@/components/MkReactionsViewer.details.vue";
|
|||
import XReactionIcon from "@/components/MkReactionIcon.vue";
|
||||
import * as os from "@/os";
|
||||
import { useTooltip } from "@/scripts/use-tooltip";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { isSignedIn } from "@/reactiveAccount";
|
||||
|
||||
const props = defineProps<{
|
||||
reaction: string;
|
||||
|
@ -43,7 +43,7 @@ const emit = defineEmits<{
|
|||
|
||||
const buttonRef = ref<HTMLElement>();
|
||||
|
||||
const canToggle = computed(() => !props.reaction.match(/@\w/) && $i);
|
||||
const canToggle = computed(() => isSignedIn && !props.reaction.match(/@\w/));
|
||||
|
||||
const toggleReaction = () => {
|
||||
if (!canToggle.value) return;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<script lang="ts" setup>
|
||||
import { computed, ref } from "vue";
|
||||
import type * as firefish from "firefish-js";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
import XReaction from "@/components/MkReactionsViewer.reaction.vue";
|
||||
|
||||
const props = defineProps<{
|
||||
|
@ -30,7 +30,7 @@ const reactionsEl = ref<HTMLElement>();
|
|||
|
||||
const initialReactions = new Set(Object.keys(props.note.reactions));
|
||||
|
||||
const isMe = computed(() => $i && $i.id === props.note.userId);
|
||||
const isMe = computed(() => isSignedIn && $i.id === props.note.userId);
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -27,7 +27,7 @@ import Ripple from "@/components/MkRipple.vue";
|
|||
import XDetails from "@/components/MkUsersTooltip.vue";
|
||||
import { pleaseLogin } from "@/scripts/please-login";
|
||||
import * as os from "@/os";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
import { useTooltip } from "@/scripts/use-tooltip";
|
||||
import { i18n } from "@/i18n";
|
||||
import { defaultStore } from "@/store";
|
||||
|
@ -74,7 +74,7 @@ useTooltip(buttonRef, async (showing) => {
|
|||
|
||||
const hasRenotedBefore = ref(false);
|
||||
|
||||
if ($i != null) {
|
||||
if (isSignedIn) {
|
||||
os.api("notes/renotes", {
|
||||
noteId: props.note.id,
|
||||
userId: $i.id,
|
||||
|
|
|
@ -33,7 +33,7 @@ import XNotes from "@/components/MkNotes.vue";
|
|||
import MkInfo from "@/components/MkInfo.vue";
|
||||
import { stream } from "@/stream";
|
||||
import * as sound from "@/scripts/sound";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
import { i18n } from "@/i18n";
|
||||
import { defaultStore } from "@/store";
|
||||
import icon from "@/scripts/icon";
|
||||
|
@ -67,7 +67,7 @@ const prepend = (note) => {
|
|||
emit("note");
|
||||
|
||||
if (props.sound) {
|
||||
sound.play($i && note.userId === $i.id ? "noteMy" : "note");
|
||||
sound.play(isSignedIn && note.userId === $i.id ? "noteMy" : "note");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -211,19 +211,15 @@ import MkPushNotificationAllowButton from "@/components/MkPushNotificationAllowB
|
|||
import FormSwitch from "@/components/form/switch.vue";
|
||||
import { defaultStore } from "@/store";
|
||||
import { i18n } from "@/i18n";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { isModerator } from "@/reactiveAccount";
|
||||
import { instance } from "@/instance";
|
||||
import icon from "@/scripts/icon";
|
||||
|
||||
const isLocalTimelineAvailable =
|
||||
!instance.disableLocalTimeline ||
|
||||
($i != null && ($i.isModerator || $i.isAdmin));
|
||||
const isLocalTimelineAvailable = !instance.disableLocalTimeline || isModerator;
|
||||
const isRecommendedTimelineAvailable =
|
||||
!instance.disableRecommendedTimeline ||
|
||||
($i != null && ($i.isModerator || $i.isAdmin));
|
||||
!instance.disableRecommendedTimeline || isModerator;
|
||||
const isGlobalTimelineAvailable =
|
||||
!instance.disableGlobalTimeline ||
|
||||
($i != null && ($i.isModerator || $i.isAdmin));
|
||||
!instance.disableGlobalTimeline || isModerator;
|
||||
|
||||
const timelines = ["home"];
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
:class="{ detailed }"
|
||||
>
|
||||
<span
|
||||
v-if="$i && $i.id != user.id && user.isFollowed"
|
||||
v-if="isSignedIn && $i.id !== user.id && user.isFollowed"
|
||||
class="followed"
|
||||
>{{ i18n.ts.followsYou }}</span
|
||||
>
|
||||
|
@ -79,7 +79,10 @@
|
|||
</div>
|
||||
<div class="buttons">
|
||||
<slot>
|
||||
<MkFollowButton v-if="$i && user.id != $i.id" :user="user" />
|
||||
<MkFollowButton
|
||||
v-if="isSignedIn && user.id !== $i.id"
|
||||
:user="user"
|
||||
/>
|
||||
</slot>
|
||||
</div>
|
||||
</article>
|
||||
|
@ -94,6 +97,7 @@ import XShowMoreButton from "@/components/MkShowMoreButton.vue";
|
|||
import MkNumber from "@/components/MkNumber.vue";
|
||||
import { userPage } from "@/filters/user";
|
||||
import { i18n } from "@/i18n";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
|
||||
const props = defineProps<{
|
||||
user: firefish.entities.UserDetailed;
|
||||
|
|
|
@ -40,7 +40,7 @@ import directives from "@/directives";
|
|||
import { i18n } from "@/i18n";
|
||||
import { fetchInstance, instance } from "@/instance";
|
||||
import { alert, api, confirm, popup, post, toast } from "@/os";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
import { deviceKind } from "@/scripts/device-kind";
|
||||
import { getAccountFromId } from "@/scripts/get-account-from-id";
|
||||
import { makeHotkey } from "@/scripts/hotkey";
|
||||
|
@ -274,7 +274,7 @@ function checkForSplash() {
|
|||
}
|
||||
|
||||
if (
|
||||
$i &&
|
||||
isSignedIn &&
|
||||
defaultStore.state.tutorial === -1 &&
|
||||
!["/announcements", "/announcements/"].includes(window.location.pathname)
|
||||
) {
|
||||
|
@ -426,7 +426,7 @@ function checkForSplash() {
|
|||
s: search,
|
||||
};
|
||||
|
||||
if ($i) {
|
||||
if (isSignedIn) {
|
||||
// only add post shortcuts if logged in
|
||||
hotkeys["p|n"] = post;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import { computed, reactive } from "vue";
|
|||
import { ui } from "@/config";
|
||||
import { i18n } from "@/i18n";
|
||||
import * as os from "@/os";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
import icon from "@/scripts/icon";
|
||||
import { search } from "@/scripts/search";
|
||||
import { unisonReload } from "@/scripts/unison-reload";
|
||||
|
@ -11,21 +11,21 @@ export const navbarItemDef = reactive({
|
|||
notifications: {
|
||||
title: "notifications",
|
||||
icon: `${icon("ph-bell")}`,
|
||||
show: computed(() => $i != null),
|
||||
show: computed(() => isSignedIn),
|
||||
indicated: computed(() => $i?.hasUnreadNotification),
|
||||
to: "/my/notifications",
|
||||
},
|
||||
messaging: {
|
||||
title: "messaging",
|
||||
icon: `${icon("ph-chats-teardrop")}`,
|
||||
show: computed(() => $i != null),
|
||||
show: computed(() => isSignedIn),
|
||||
indicated: computed(() => $i?.hasUnreadMessagingMessage),
|
||||
to: "/my/messaging",
|
||||
},
|
||||
drive: {
|
||||
title: "drive",
|
||||
icon: `${icon("ph-cloud")}`,
|
||||
show: computed(() => $i != null),
|
||||
show: computed(() => isSignedIn),
|
||||
to: "/my/drive",
|
||||
},
|
||||
followRequests: {
|
||||
|
@ -54,19 +54,19 @@ export const navbarItemDef = reactive({
|
|||
lists: {
|
||||
title: "lists",
|
||||
icon: `${icon("ph-list-bullets")}`,
|
||||
show: computed(() => $i != null),
|
||||
show: computed(() => isSignedIn),
|
||||
to: "/my/lists",
|
||||
},
|
||||
antennas: {
|
||||
title: "antennas",
|
||||
icon: `${icon("ph-flying-saucer")}`,
|
||||
show: computed(() => $i != null),
|
||||
show: computed(() => isSignedIn),
|
||||
to: "/my/antennas",
|
||||
},
|
||||
favorites: {
|
||||
title: "favorites",
|
||||
icon: `${icon("ph-bookmark-simple")}`,
|
||||
show: computed(() => $i != null),
|
||||
show: computed(() => isSignedIn),
|
||||
to: "/my/favorites",
|
||||
},
|
||||
pages: {
|
||||
|
@ -82,7 +82,7 @@ export const navbarItemDef = reactive({
|
|||
clips: {
|
||||
title: "clips",
|
||||
icon: `${icon("ph-paperclip")}`,
|
||||
show: computed(() => $i != null),
|
||||
show: computed(() => isSignedIn),
|
||||
to: "/my/clips",
|
||||
},
|
||||
channels: {
|
||||
|
|
|
@ -190,7 +190,7 @@ import number from "@/filters/number";
|
|||
import { i18n } from "@/i18n";
|
||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||
import { deviceKind } from "@/scripts/device-kind";
|
||||
import { iAmModerator } from "@/account";
|
||||
import { isModerator } from "@/reactiveAccount";
|
||||
import { instance } from "@/instance";
|
||||
import { defaultStore } from "@/store";
|
||||
import icon from "@/scripts/icon";
|
||||
|
@ -215,7 +215,7 @@ const tabs = ["overview", "emojis", "charts"];
|
|||
const tab = ref(tabs[0]);
|
||||
watch(tab, () => syncSlide(tabs.indexOf(tab.value)));
|
||||
|
||||
if (iAmModerator) tabs.push("federation");
|
||||
if (isModerator) tabs.push("federation");
|
||||
|
||||
const initStats = () =>
|
||||
os.api("stats", {}).then((res) => {
|
||||
|
@ -242,7 +242,7 @@ const theTabs = [
|
|||
},
|
||||
];
|
||||
|
||||
if (iAmModerator) {
|
||||
if (isModerator) {
|
||||
theTabs.push({
|
||||
key: "federation",
|
||||
title: i18n.ts.federation,
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
</swiper-slide>
|
||||
<swiper-slide>
|
||||
<div v-if="info" class="_formRoot">
|
||||
<MkInfo v-if="!iAmAdmin" warn>{{
|
||||
<MkInfo v-if="!isAdmin" warn>{{
|
||||
i18n.ts.requireAdminForView
|
||||
}}</MkInfo>
|
||||
<MkKeyValue
|
||||
|
@ -172,14 +172,14 @@ import * as os from "@/os";
|
|||
import { i18n } from "@/i18n";
|
||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||
import { deviceKind } from "@/scripts/device-kind";
|
||||
import { iAmAdmin, iAmModerator } from "@/account";
|
||||
import { isAdmin, isModerator } from "@/reactiveAccount";
|
||||
import { defaultStore } from "@/store";
|
||||
import icon from "@/scripts/icon";
|
||||
import "swiper/scss";
|
||||
import "swiper/scss/virtual";
|
||||
|
||||
const tabs = ["overview"];
|
||||
if (iAmModerator) tabs.push("ip");
|
||||
if (isModerator) tabs.push("ip");
|
||||
tabs.push("raw");
|
||||
const tab = ref(tabs[0]);
|
||||
watch(tab, () => syncSlide(tabs.indexOf(tab.value)));
|
||||
|
@ -238,7 +238,7 @@ const headerTabs = computed(() => [
|
|||
title: i18n.ts.overview,
|
||||
icon: `${icon("ph-info")}`,
|
||||
},
|
||||
iAmModerator
|
||||
isModerator
|
||||
? {
|
||||
key: "ip",
|
||||
title: "IP",
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
>
|
||||
<div class="_title">
|
||||
<h3>
|
||||
<span v-if="$i && !announcement.isRead">
|
||||
<span v-if="isSignedIn && !announcement.isRead">
|
||||
🆕
|
||||
</span>
|
||||
{{ announcement.title }}
|
||||
|
@ -36,7 +36,10 @@
|
|||
:src="announcement.imageUrl"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="$i && !announcement.isRead" class="_footer">
|
||||
<div
|
||||
v-if="isSignedIn && !announcement.isRead"
|
||||
class="_footer"
|
||||
>
|
||||
<MkButton primary @click="read(announcement.id)"
|
||||
><i :class="icon('ph-check')"></i>
|
||||
{{ i18n.ts.gotIt }}</MkButton
|
||||
|
@ -56,6 +59,7 @@ import * as os from "@/os";
|
|||
import { i18n } from "@/i18n";
|
||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||
import icon from "@/scripts/icon";
|
||||
import { isSignedIn } from "@/reactiveAccount";
|
||||
|
||||
const pagination = {
|
||||
endpoint: "announcements" as const,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<template>
|
||||
<div v-if="$i && fetching" class="">
|
||||
<div v-if="isSignedIn && fetching" class="">
|
||||
<MkLoading />
|
||||
</div>
|
||||
<div v-else-if="$i">
|
||||
<div v-else-if="isSignedIn">
|
||||
<XForm
|
||||
v-if="state == 'waiting'"
|
||||
ref="form"
|
||||
|
@ -52,7 +52,7 @@ import MkSignin from "@/components/MkSignin.vue";
|
|||
import MkKeyValue from "@/components/MkKeyValue.vue";
|
||||
import * as os from "@/os";
|
||||
import { login } from "@/account";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { isSignedIn } from "@/reactiveAccount";
|
||||
import { i18n } from "@/i18n";
|
||||
|
||||
const props = defineProps<{
|
||||
|
@ -64,7 +64,7 @@ const fetching = ref(true);
|
|||
const auth_code = ref("");
|
||||
|
||||
onMounted(() => {
|
||||
if (!$i) return;
|
||||
if (!isSignedIn) return;
|
||||
|
||||
os.api("auth/session/show", { token: props.token })
|
||||
.then((sess: any) => {
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
import { computed, provide, ref, watch } from "vue";
|
||||
import type * as firefish from "firefish-js";
|
||||
import XNotes from "@/components/MkNotes.vue";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
import { i18n } from "@/i18n";
|
||||
import * as os from "@/os";
|
||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||
|
@ -51,7 +51,7 @@ const pagination = {
|
|||
};
|
||||
|
||||
const isOwned: boolean | null = computed<boolean | null>(
|
||||
() => $i && clip.value && $i.id === clip.value.userId,
|
||||
() => isSignedIn && clip.value && $i.id === clip.value.userId,
|
||||
);
|
||||
|
||||
watch(
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<XUserList :pagination="pinnedUsers" />
|
||||
</MkFolder>
|
||||
<MkFolder
|
||||
v-if="$i != null"
|
||||
v-if="isSignedIn"
|
||||
class="_gap"
|
||||
persist-key="explore-popular-users"
|
||||
>
|
||||
|
@ -31,7 +31,7 @@
|
|||
<XUserList :pagination="popularUsers" />
|
||||
</MkFolder>
|
||||
<MkFolder
|
||||
v-if="$i != null"
|
||||
v-if="isSignedIn"
|
||||
class="_gap"
|
||||
persist-key="explore-recently-updated-users"
|
||||
>
|
||||
|
@ -45,7 +45,7 @@
|
|||
<XUserList :pagination="recentlyUpdatedUsers" />
|
||||
</MkFolder>
|
||||
<MkFolder
|
||||
v-if="$i != null"
|
||||
v-if="isSignedIn"
|
||||
class="_gap"
|
||||
persist-key="explore-recently-registered-users"
|
||||
>
|
||||
|
@ -103,7 +103,7 @@
|
|||
<XUserList :pagination="tagUsers" />
|
||||
</MkFolder>
|
||||
|
||||
<template v-if="tag == null && $i != null">
|
||||
<template v-if="tag == null && isSignedIn">
|
||||
<MkFolder class="_gap">
|
||||
<template #header
|
||||
><i
|
||||
|
@ -146,7 +146,7 @@ import MkFolder from "@/components/MkFolder.vue";
|
|||
import MkTab from "@/components/MkTab.vue";
|
||||
import * as os from "@/os";
|
||||
import { i18n } from "@/i18n";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { isSignedIn } from "@/reactiveAccount";
|
||||
import icon from "@/scripts/icon";
|
||||
|
||||
const props = defineProps<{
|
||||
|
|
|
@ -58,7 +58,9 @@
|
|||
</div>
|
||||
<div class="other">
|
||||
<button
|
||||
v-if="$i && $i.id === post.user.id"
|
||||
v-if="
|
||||
isSignedIn && $i.id === post.user.id
|
||||
"
|
||||
v-tooltip="i18n.ts.edit"
|
||||
v-click-anime
|
||||
class="_button"
|
||||
|
@ -161,6 +163,7 @@ import { definePageMetadata } from "@/scripts/page-metadata";
|
|||
import { shareAvailable } from "@/scripts/share-available";
|
||||
import { defaultStore } from "@/store";
|
||||
import icon from "@/scripts/icon";
|
||||
import { isSignedIn } from "@/reactiveAccount";
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
|
@ -350,8 +353,5 @@ definePageMetadata(
|
|||
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
||||
grid-gap: 12px;
|
||||
margin: var(--margin);
|
||||
|
||||
> .post {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
}}</template>
|
||||
</MkKeyValue>
|
||||
|
||||
<FormSection v-if="iAmAdmin">
|
||||
<FormSection v-if="isAdmin">
|
||||
<template #label>Moderation</template>
|
||||
<FormSuspense :p="init">
|
||||
<FormSwitch
|
||||
|
@ -346,11 +346,10 @@ import MkLink from "@/components/MkLink.vue";
|
|||
import MkButton from "@/components/MkButton.vue";
|
||||
import FormSection from "@/components/form/section.vue";
|
||||
import MkKeyValue from "@/components/MkKeyValue.vue";
|
||||
import MkSelect from "@/components/form/select.vue";
|
||||
import FormSwitch from "@/components/form/switch.vue";
|
||||
import * as os from "@/os";
|
||||
import number from "@/filters/number";
|
||||
import { iAmAdmin } from "@/account";
|
||||
import { isAdmin } from "@/reactiveAccount";
|
||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||
import { deviceKind } from "@/scripts/device-kind";
|
||||
import { defaultStore } from "@/store";
|
||||
|
@ -376,7 +375,7 @@ const props = defineProps<{
|
|||
}>();
|
||||
|
||||
const tabs = ["overview"];
|
||||
if (iAmAdmin) tabs.push("chart", "users", "raw");
|
||||
if (isAdmin) tabs.push("chart", "users", "raw");
|
||||
const tab = ref(tabs[0]);
|
||||
watch(tab, () => syncSlide(tabs.indexOf(tab.value)));
|
||||
|
||||
|
@ -389,7 +388,7 @@ const isSilenced = ref(false);
|
|||
const faviconUrl = ref(null);
|
||||
|
||||
const usersPagination = {
|
||||
endpoint: iAmAdmin ? "admin/show-users" : ("users" as const),
|
||||
endpoint: isAdmin ? "admin/show-users" : ("users" as const),
|
||||
limit: 10,
|
||||
params: {
|
||||
sort: "+updatedAt",
|
||||
|
@ -400,7 +399,7 @@ const usersPagination = {
|
|||
};
|
||||
|
||||
async function fetch() {
|
||||
if (iAmAdmin)
|
||||
if (isAdmin)
|
||||
meta.value = (await os.api("admin/meta")) as AugmentedInstanceMetadata;
|
||||
instance.value = (await os.api("federation/show-instance", {
|
||||
host: props.host,
|
||||
|
@ -485,7 +484,7 @@ const theTabs = [
|
|||
},
|
||||
];
|
||||
|
||||
if (iAmAdmin) {
|
||||
if (isAdmin) {
|
||||
theTabs.push(
|
||||
{
|
||||
key: "chart",
|
||||
|
|
|
@ -51,7 +51,9 @@
|
|||
><i :class="icon('ph-code')"
|
||||
/></MkA>
|
||||
<template
|
||||
v-if="$i && $i.id === page.userId"
|
||||
v-if="
|
||||
isSignedIn && $i.id === page.userId
|
||||
"
|
||||
>
|
||||
<MkA
|
||||
v-tooltip="i18n.ts._pages.editPage"
|
||||
|
@ -159,7 +161,7 @@
|
|||
</div>
|
||||
<!-- <div class="links">
|
||||
<MkA :to="`/@${username}/pages/${pageName}/view-source`" class="link">{{ i18n.ts._pages.viewSource }}</MkA>
|
||||
<template v-if="$i && $i.id === page.userId">
|
||||
<template v-if="isSignedIn && $i.id === page.userId">
|
||||
<MkA :to="`/pages/edit/${page.id}`" class="link">{{ i18n.ts._pages.editThisPage }}</MkA>
|
||||
<button v-if="$i.pinnedPageId === page.id" class="link _textButton" @click="pin(false)">{{ i18n.ts.unpin }}</button>
|
||||
<button v-else class="link _textButton" @click="pin(true)">{{ i18n.ts.pin }}</button>
|
||||
|
@ -213,6 +215,7 @@ import { definePageMetadata } from "@/scripts/page-metadata";
|
|||
import { shareAvailable } from "@/scripts/share-available";
|
||||
import { defaultStore } from "@/store";
|
||||
import icon from "@/scripts/icon";
|
||||
import { isSignedIn } from "@/reactiveAccount";
|
||||
|
||||
const props = defineProps<{
|
||||
pageName: string;
|
||||
|
|
|
@ -159,13 +159,13 @@
|
|||
<MkKeyValue oneline style="margin: 1em 0">
|
||||
<template #key>isModerator</template>
|
||||
<template #value>{{
|
||||
$i.isModerator ? i18n.ts.yes : i18n.ts.no
|
||||
isModerator ? i18n.ts.yes : i18n.ts.no
|
||||
}}</template>
|
||||
</MkKeyValue>
|
||||
<MkKeyValue oneline style="margin: 1em 0">
|
||||
<template #key>isAdmin</template>
|
||||
<template #value>{{
|
||||
$i.isAdmin ? i18n.ts.yes : i18n.ts.no
|
||||
isAdmin ? i18n.ts.yes : i18n.ts.no
|
||||
}}</template>
|
||||
</MkKeyValue>
|
||||
</FormSection>
|
||||
|
@ -179,7 +179,7 @@ import MkKeyValue from "@/components/MkKeyValue.vue";
|
|||
import * as os from "@/os";
|
||||
import number from "@/filters/number";
|
||||
import bytes from "@/filters/bytes";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isAdmin, isModerator } from "@/reactiveAccount";
|
||||
import { i18n } from "@/i18n";
|
||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||
import icon from "@/scripts/icon";
|
||||
|
|
|
@ -85,15 +85,15 @@ import { defaultStore } from "@/store";
|
|||
import MkChart from "@/components/MkChart.vue";
|
||||
import { i18n } from "@/i18n";
|
||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
import icon from "@/scripts/icon";
|
||||
|
||||
const fetching = ref(true);
|
||||
const usage = ref<any>(null);
|
||||
const capacity = ref<any>(null);
|
||||
const uploadFolder = ref<any>(null);
|
||||
const alwaysMarkNsfw = ref<boolean>($i != null && $i.alwaysMarkNsfw);
|
||||
const autoSensitive = ref<boolean>($i != null && $i.autoSensitive);
|
||||
const alwaysMarkNsfw = ref<boolean>(isSignedIn && $i.alwaysMarkNsfw);
|
||||
const autoSensitive = ref<boolean>(isSignedIn && $i.autoSensitive);
|
||||
|
||||
const meterStyle = computed(() => {
|
||||
return {
|
||||
|
|
|
@ -65,7 +65,7 @@ import * as os from "@/os";
|
|||
import { ColdDeviceStorage, defaultStore } from "@/store";
|
||||
import { unisonReload } from "@/scripts/unison-reload";
|
||||
import { stream } from "@/stream";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { isSignedIn } from "@/reactiveAccount";
|
||||
import { i18n } from "@/i18n";
|
||||
import { host, version } from "@/config";
|
||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||
|
@ -163,7 +163,7 @@ interface Profile {
|
|||
};
|
||||
}
|
||||
|
||||
const connection = $i && stream.useChannel("main");
|
||||
const connection = isSignedIn && stream.useChannel("main");
|
||||
|
||||
const profiles = ref<Record<string, Profile> | null>(null);
|
||||
|
||||
|
|
|
@ -74,24 +74,28 @@ import * as os from "@/os";
|
|||
import { defaultStore } from "@/store";
|
||||
import { i18n } from "@/i18n";
|
||||
import { instance } from "@/instance";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn, isModerator } from "@/reactiveAccount";
|
||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||
import { deviceKind } from "@/scripts/device-kind";
|
||||
import icon from "@/scripts/icon";
|
||||
import "swiper/scss";
|
||||
import "swiper/scss/virtual";
|
||||
|
||||
if (defaultStore.reactiveState.tutorial.value !== -1) {
|
||||
if (isSignedIn && defaultStore.reactiveState.tutorial.value !== -1) {
|
||||
os.popup(XTutorial, {}, {}, "closed");
|
||||
}
|
||||
|
||||
const isLocalTimelineAvailable =
|
||||
!instance.disableLocalTimeline ||
|
||||
($i != null && ($i.isModerator || $i.isAdmin));
|
||||
const isRecommendedTimelineAvailable = !instance.disableRecommendedTimeline;
|
||||
(!instance.disableLocalTimeline &&
|
||||
(isSignedIn || instance.enableGuestTimeline)) ||
|
||||
isModerator;
|
||||
const isSocialTimelineAvailable = isLocalTimelineAvailable && isSignedIn;
|
||||
const isRecommendedTimelineAvailable =
|
||||
!instance.disableRecommendedTimeline && isSignedIn;
|
||||
const isGlobalTimelineAvailable =
|
||||
!instance.disableGlobalTimeline ||
|
||||
($i != null && ($i.isModerator || $i.isAdmin));
|
||||
(!instance.disableGlobalTimeline &&
|
||||
(isSignedIn || instance.enableGuestTimeline)) ||
|
||||
isModerator;
|
||||
const keymap = {
|
||||
t: focus,
|
||||
};
|
||||
|
|
|
@ -181,7 +181,7 @@
|
|||
<FormSwitch
|
||||
v-if="
|
||||
user.host == null &&
|
||||
$i.isAdmin &&
|
||||
isAdmin &&
|
||||
(moderator || !user.isAdmin)
|
||||
"
|
||||
v-model="moderator"
|
||||
|
@ -204,7 +204,7 @@
|
|||
{{ i18n.ts.reflectMayTakeTime }}
|
||||
<div class="_formBlock">
|
||||
<FormButton
|
||||
v-if="user.host == null && iAmModerator"
|
||||
v-if="user.host == null && isModerator"
|
||||
inline
|
||||
style="margin-bottom: 0.4rem"
|
||||
@click="resetPassword"
|
||||
|
@ -212,14 +212,14 @@
|
|||
{{ i18n.ts.resetPassword }}</FormButton
|
||||
>
|
||||
<FormButton
|
||||
v-if="user.host == null && iAmModerator"
|
||||
v-if="user.host == null && isModerator"
|
||||
inline
|
||||
@click="sendModMail"
|
||||
><i :class="icon('ph-warning-diamond')"></i>
|
||||
{{ i18n.ts.sendModMail }}</FormButton
|
||||
>
|
||||
<FormButton
|
||||
v-if="user.host == null && $i.isAdmin"
|
||||
v-if="user.host == null && isAdmin"
|
||||
inline
|
||||
danger
|
||||
@click="delete2fa"
|
||||
|
@ -227,7 +227,7 @@
|
|||
{{ i18n.ts.delete2fa }}</FormButton
|
||||
>
|
||||
<FormButton
|
||||
v-if="user.host == null && $i.isAdmin"
|
||||
v-if="user.host == null && isAdmin"
|
||||
inline
|
||||
danger
|
||||
@click="deletePasskeys"
|
||||
|
@ -235,7 +235,7 @@
|
|||
{{ i18n.ts.deletePasskeys }}</FormButton
|
||||
>
|
||||
<FormButton
|
||||
v-if="$i.isAdmin"
|
||||
v-if="isAdmin"
|
||||
inline
|
||||
primary
|
||||
danger
|
||||
|
@ -253,14 +253,14 @@
|
|||
</FormTextarea>
|
||||
<FormFolder class="_formBlock">
|
||||
<template #label>IP</template>
|
||||
<MkInfo v-if="!iAmAdmin" warn>{{
|
||||
<MkInfo v-if="!isAdmin" warn>{{
|
||||
i18n.ts.requireAdminForView
|
||||
}}</MkInfo>
|
||||
<MkInfo v-else
|
||||
>The date is the IP address was first
|
||||
acknowledged.</MkInfo
|
||||
>
|
||||
<template v-if="iAmAdmin && ips">
|
||||
<template v-if="isAdmin && ips">
|
||||
<div
|
||||
v-for="record in ips"
|
||||
:key="record.ip"
|
||||
|
@ -346,7 +346,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div v-else-if="tab === 'raw'" class="_formRoot">
|
||||
<MkObjectView v-if="info && $i.isAdmin" tall :value="info">
|
||||
<MkObjectView v-if="info && isAdmin" tall :value="info">
|
||||
</MkObjectView>
|
||||
|
||||
<MkObjectView tall :value="user"> </MkObjectView>
|
||||
|
@ -369,7 +369,6 @@ import FormButton from "@/components/MkButton.vue";
|
|||
import FormInput from "@/components/form/input.vue";
|
||||
import FormFolder from "@/components/form/folder.vue";
|
||||
import MkKeyValue from "@/components/MkKeyValue.vue";
|
||||
import MkSelect from "@/components/form/select.vue";
|
||||
import FormSuspense from "@/components/form/suspense.vue";
|
||||
import MkFileListForAdmin from "@/components/MkFileListForAdmin.vue";
|
||||
import MkInfo from "@/components/MkInfo.vue";
|
||||
|
@ -378,7 +377,7 @@ import { url } from "@/config";
|
|||
import { acct, userPage } from "@/filters/user";
|
||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||
import { i18n } from "@/i18n";
|
||||
import { iAmAdmin, iAmModerator } from "@/account";
|
||||
import { isAdmin, isModerator } from "@/reactiveAccount";
|
||||
import { instance } from "@/instance";
|
||||
import icon from "@/scripts/icon";
|
||||
|
||||
|
@ -407,7 +406,7 @@ const filesPagination = {
|
|||
};
|
||||
|
||||
function createFetcher() {
|
||||
if (iAmModerator) {
|
||||
if (isModerator) {
|
||||
return () =>
|
||||
Promise.all([
|
||||
os.api("users/show", {
|
||||
|
@ -416,7 +415,7 @@ function createFetcher() {
|
|||
os.api("admin/show-user", {
|
||||
userId: props.userId,
|
||||
}),
|
||||
iAmAdmin
|
||||
isAdmin
|
||||
? os.api("admin/get-user-ips", {
|
||||
userId: props.userId,
|
||||
})
|
||||
|
@ -640,7 +639,7 @@ const headerTabs = computed(() =>
|
|||
title: i18n.ts.overview,
|
||||
icon: `${icon("ph-info")}`,
|
||||
},
|
||||
iAmModerator
|
||||
isModerator
|
||||
? {
|
||||
key: "moderation",
|
||||
title: i18n.ts.moderation,
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
:user="user"
|
||||
:nowrap="true"
|
||||
/>
|
||||
<div v-if="$i?.isModerator || $i?.isAdmin">
|
||||
<div v-if="isModerator">
|
||||
<span
|
||||
v-if="user.isSilenced"
|
||||
style="
|
||||
|
@ -67,8 +67,8 @@
|
|||
</div>
|
||||
<span
|
||||
v-if="
|
||||
$i &&
|
||||
$i.id != user.id &&
|
||||
isSignedIn &&
|
||||
$i.id !== user.id &&
|
||||
user.isFollowed
|
||||
"
|
||||
class="followed"
|
||||
|
@ -131,14 +131,14 @@
|
|||
/>
|
||||
<span
|
||||
v-if="
|
||||
$i &&
|
||||
$i.id != user.id &&
|
||||
isSignedIn &&
|
||||
$i.id !== user.id &&
|
||||
user.isFollowed
|
||||
"
|
||||
class="followed"
|
||||
>{{ i18n.ts.followsYou }}</span
|
||||
>
|
||||
<div v-if="$i?.isModerator || $i?.isAdmin">
|
||||
<div v-if="isModerator">
|
||||
<span
|
||||
v-if="user.isSilenced"
|
||||
style="color: var(--warn); padding: 5px"
|
||||
|
@ -339,7 +339,7 @@
|
|||
/>
|
||||
</div>
|
||||
<MkInfo
|
||||
v-else-if="$i && $i.id === user.id"
|
||||
v-else-if="isSignedIn && $i.id === user.id"
|
||||
style="margin: 12px 0"
|
||||
>{{ i18n.ts.userPagePinTip }}</MkInfo
|
||||
>
|
||||
|
@ -392,7 +392,7 @@ import { userPage } from "@/filters/user";
|
|||
import { defaultStore } from "@/store";
|
||||
import * as os from "@/os";
|
||||
import { i18n } from "@/i18n";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn, isModerator } from "@/reactiveAccount";
|
||||
import { host } from "@/config";
|
||||
import icon from "@/scripts/icon";
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ import * as os from "@/os";
|
|||
import { useRouter } from "@/router";
|
||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||
import { i18n } from "@/i18n";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
import icon from "@/scripts/icon";
|
||||
|
||||
const XHome = defineAsyncComponent(() => import("./home.vue"));
|
||||
|
@ -88,7 +88,7 @@ const headerTabs = computed(() =>
|
|||
title: i18n.ts.overview,
|
||||
icon: `${icon("ph-user")}`,
|
||||
},
|
||||
...(($i && $i.id === user.value.id) ||
|
||||
...((isSignedIn && $i.id === user.value.id) ||
|
||||
user.value.publicReactions
|
||||
? [
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ import type { Ref } from "vue";
|
|||
import { onUnmounted, ref, watch } from "vue";
|
||||
import { api } from "./os";
|
||||
import { stream } from "./stream";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
|
||||
type StateDef = Record<
|
||||
string,
|
||||
|
@ -16,7 +16,7 @@ type StateDef = Record<
|
|||
|
||||
type ArrayElement<A> = A extends readonly (infer T)[] ? T : never;
|
||||
|
||||
const connection = $i && stream.useChannel("main");
|
||||
const connection = isSignedIn && stream.useChannel("main");
|
||||
|
||||
export class Storage<T extends StateDef> {
|
||||
public readonly key: string;
|
||||
|
@ -42,12 +42,12 @@ export class Storage<T extends StateDef> {
|
|||
const deviceState = JSON.parse(
|
||||
localStorage.getItem(this.keyForLocalStorage) || "{}",
|
||||
);
|
||||
const deviceAccountState = $i
|
||||
const deviceAccountState = isSignedIn
|
||||
? JSON.parse(
|
||||
localStorage.getItem(`${this.keyForLocalStorage}::${$i.id}`) || "{}",
|
||||
)
|
||||
: {};
|
||||
const registryCache = $i
|
||||
const registryCache = isSignedIn
|
||||
? JSON.parse(
|
||||
localStorage.getItem(`${this.keyForLocalStorage}::cache::${$i.id}`) ||
|
||||
"{}",
|
||||
|
@ -64,7 +64,7 @@ export class Storage<T extends StateDef> {
|
|||
state[k] = deviceState[k];
|
||||
} else if (
|
||||
v.where === "account" &&
|
||||
$i &&
|
||||
isSignedIn &&
|
||||
Object.prototype.hasOwnProperty.call(registryCache, k)
|
||||
) {
|
||||
state[k] = registryCache[k];
|
||||
|
@ -84,7 +84,7 @@ export class Storage<T extends StateDef> {
|
|||
this.state = state as any;
|
||||
this.reactiveState = reactiveState as any;
|
||||
|
||||
if ($i) {
|
||||
if (isSignedIn) {
|
||||
// なぜかsetTimeoutしないとapi関数内でエラーになる(おそらく循環参照してることに原因がありそう)
|
||||
window.setTimeout(() => {
|
||||
api("i/registry/get-all", { scope: ["client", this.key] }).then(
|
||||
|
@ -168,7 +168,7 @@ export class Storage<T extends StateDef> {
|
|||
break;
|
||||
}
|
||||
case "deviceAccount": {
|
||||
if ($i == null) break;
|
||||
if (!isSignedIn) break;
|
||||
const deviceAccountState = JSON.parse(
|
||||
localStorage.getItem(`${this.keyForLocalStorage}::${$i.id}`) || "{}",
|
||||
);
|
||||
|
@ -180,7 +180,7 @@ export class Storage<T extends StateDef> {
|
|||
break;
|
||||
}
|
||||
case "account": {
|
||||
if ($i == null) break;
|
||||
if (!isSignedIn) break;
|
||||
const cache = JSON.parse(
|
||||
localStorage.getItem(`${this.keyForLocalStorage}::cache::${$i.id}`) ||
|
||||
"{}",
|
||||
|
|
|
@ -7,3 +7,7 @@ const accountData = localStorage.getItem("account");
|
|||
export const $i = accountData
|
||||
? reactive(JSON.parse(accountData) as Account)
|
||||
: null;
|
||||
|
||||
export const isSignedIn = $i != null;
|
||||
export const isModerator = $i != null && ($i.isModerator || $i.isAdmin);
|
||||
export const isAdmin = $i != null && $i.isAdmin;
|
||||
|
|
|
@ -1,21 +1,9 @@
|
|||
import type { AsyncComponentLoader } from "vue";
|
||||
import { defineAsyncComponent, inject } from "vue";
|
||||
import { iAmModerator } from "@/account";
|
||||
import { $i, isModerator } from "@/reactiveAccount";
|
||||
import { Router } from "@/nirax";
|
||||
import MkError from "@/pages/_error_.vue";
|
||||
import MkLoading from "@/pages/_loading_.vue";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
// import { api } from "@/os";
|
||||
|
||||
// function getGuestTimelineStatus() {
|
||||
// api("meta", {
|
||||
// detail: false,
|
||||
// }).then((meta) => {
|
||||
// return meta.enableGuestTimeline;
|
||||
// });
|
||||
// }
|
||||
|
||||
// const guestTimeline = getGuestTimelineStatus();
|
||||
|
||||
const page = (loader: AsyncComponentLoader<any>) =>
|
||||
defineAsyncComponent({
|
||||
|
@ -430,13 +418,13 @@ export const routes = [
|
|||
},
|
||||
{
|
||||
path: "/admin/file/:fileId",
|
||||
component: iAmModerator
|
||||
component: isModerator
|
||||
? page(() => import("./pages/admin-file.vue"))
|
||||
: page(() => import("./pages/not-found.vue")),
|
||||
},
|
||||
{
|
||||
path: "/admin",
|
||||
component: iAmModerator
|
||||
component: isModerator
|
||||
? page(() => import("./pages/admin/index.vue"))
|
||||
: page(() => import("./pages/not-found.vue")),
|
||||
children: [
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import type { Ref } from "vue";
|
||||
import { defineAsyncComponent } from "vue";
|
||||
import type * as firefish from "firefish-js";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn, isModerator } from "@/reactiveAccount";
|
||||
import { i18n } from "@/i18n";
|
||||
import { instance } from "@/instance";
|
||||
import * as os from "@/os";
|
||||
|
@ -217,18 +217,18 @@ export function getNoteMenu(props: {
|
|||
props.isDeleted.value = true;
|
||||
}
|
||||
|
||||
async function promote(): Promise<void> {
|
||||
const { canceled, result: days } = await os.inputNumber({
|
||||
title: i18n.ts.numberOfDays,
|
||||
});
|
||||
// async function promote(): Promise<void> {
|
||||
// const { canceled, result: days } = await os.inputNumber({
|
||||
// title: i18n.ts.numberOfDays,
|
||||
// });
|
||||
|
||||
if (canceled) return;
|
||||
// if (canceled) return;
|
||||
|
||||
os.apiWithDialog("admin/promo/create", {
|
||||
noteId: appearNote.id,
|
||||
expiresAt: Date.now() + 86400000 * days,
|
||||
});
|
||||
}
|
||||
// os.apiWithDialog("admin/promo/create", {
|
||||
// noteId: appearNote.id,
|
||||
// expiresAt: Date.now() + 86400000 * days,
|
||||
// });
|
||||
// }
|
||||
|
||||
function share(): void {
|
||||
navigator.share({
|
||||
|
@ -270,13 +270,12 @@ export function getNoteMenu(props: {
|
|||
}
|
||||
|
||||
let menu;
|
||||
if ($i) {
|
||||
if (isSignedIn) {
|
||||
const statePromise = os.api("notes/state", {
|
||||
noteId: appearNote.id,
|
||||
});
|
||||
|
||||
const isAppearAuthor = appearNote.userId === $i.id;
|
||||
const isModerator = $i.isAdmin || $i.isModerator;
|
||||
|
||||
menu = [
|
||||
...(props.currentClipPage?.value.userId === $i.id
|
||||
|
@ -397,7 +396,7 @@ export function getNoteMenu(props: {
|
|||
],
|
||||
},
|
||||
/*
|
||||
...($i.isModerator || $i.isAdmin ? [
|
||||
...(isModerator ? [
|
||||
null,
|
||||
{
|
||||
icon: `${icon('ph-megaphone-simple')}`,
|
||||
|
|
|
@ -5,15 +5,12 @@ import copyToClipboard from "@/scripts/copy-to-clipboard";
|
|||
import { host } from "@/config";
|
||||
import * as os from "@/os";
|
||||
import { userActions } from "@/store";
|
||||
import { iAmModerator } from "@/account";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isModerator, isSignedIn } from "@/reactiveAccount";
|
||||
import { mainRouter } from "@/router";
|
||||
import type { Router } from "@/nirax";
|
||||
import icon from "@/scripts/icon";
|
||||
|
||||
export function getUserMenu(user, router: Router = mainRouter) {
|
||||
const meId = $i ? $i.id : null;
|
||||
|
||||
async function pushList() {
|
||||
const t = i18n.ts.selectList; // なぜか後で参照すると null になるので最初にメモリに確保しておく
|
||||
const lists = await os.api("users/lists/list");
|
||||
|
@ -282,7 +279,7 @@ export function getUserMenu(user, router: Router = mainRouter) {
|
|||
os.post({ specified: user });
|
||||
},
|
||||
},
|
||||
meId !== user.id
|
||||
$i.id !== user.id
|
||||
? {
|
||||
type: "link",
|
||||
icon: `${icon("ph-chats-teardrop")}`,
|
||||
|
@ -305,7 +302,7 @@ export function getUserMenu(user, router: Router = mainRouter) {
|
|||
text: i18n.ts.addToList,
|
||||
action: pushList,
|
||||
},
|
||||
meId !== user.id
|
||||
$i.id !== user.id
|
||||
? {
|
||||
icon: `${icon("ph-users-three")}`,
|
||||
text: i18n.ts.inviteToGroup,
|
||||
|
@ -320,7 +317,7 @@ export function getUserMenu(user, router: Router = mainRouter) {
|
|||
},
|
||||
] as any;
|
||||
|
||||
if ($i && meId !== user.id) {
|
||||
if (isSignedIn && $i.id !== user.id) {
|
||||
menu = menu.concat([
|
||||
{
|
||||
icon: user.isMuted ? "ph-eye ph-lg" : "ph-eye-slash ph-lg",
|
||||
|
@ -354,7 +351,7 @@ export function getUserMenu(user, router: Router = mainRouter) {
|
|||
},
|
||||
]);
|
||||
|
||||
if (iAmModerator) {
|
||||
if (isModerator) {
|
||||
menu = menu.concat([
|
||||
null,
|
||||
{
|
||||
|
@ -371,7 +368,7 @@ export function getUserMenu(user, router: Router = mainRouter) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($i && meId === user.id) {
|
||||
if (isSignedIn && $i.id === user.id) {
|
||||
menu = menu.concat([
|
||||
null,
|
||||
{
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { defineAsyncComponent } from "vue";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { isSignedIn } from "@/reactiveAccount";
|
||||
import { i18n } from "@/i18n";
|
||||
import { popup } from "@/os";
|
||||
import { vibrate } from "@/scripts/vibrate";
|
||||
|
||||
export function pleaseLogin(path?: string) {
|
||||
if ($i) return;
|
||||
if (isSignedIn) return;
|
||||
vibrate(100);
|
||||
|
||||
popup(
|
||||
|
|
|
@ -2,7 +2,7 @@ import type { Ref } from "vue";
|
|||
import { onUnmounted } from "vue";
|
||||
import type * as firefish from "firefish-js";
|
||||
import { stream } from "@/stream";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
import * as os from "@/os";
|
||||
|
||||
export function useNoteCapture(props: {
|
||||
|
@ -11,7 +11,7 @@ export function useNoteCapture(props: {
|
|||
isDeletedRef: Ref<boolean>;
|
||||
}) {
|
||||
const note = props.note;
|
||||
const connection = $i ? stream : null;
|
||||
const connection = isSignedIn ? stream : null;
|
||||
|
||||
async function onStreamNoteUpdated(noteData): Promise<void> {
|
||||
const { type, id, body } = noteData;
|
||||
|
@ -34,7 +34,7 @@ export function useNoteCapture(props: {
|
|||
|
||||
note.value.reactions[reaction] = currentCount + 1;
|
||||
|
||||
if ($i && body.userId === $i.id) {
|
||||
if (isSignedIn && body.userId === $i.id) {
|
||||
note.value.myReaction = reaction;
|
||||
}
|
||||
break;
|
||||
|
@ -48,7 +48,7 @@ export function useNoteCapture(props: {
|
|||
|
||||
note.value.reactions[reaction] = Math.max(0, currentCount - 1);
|
||||
|
||||
if ($i && body.userId === $i.id) {
|
||||
if (isSignedIn && body.userId === $i.id) {
|
||||
note.value.myReaction = undefined;
|
||||
}
|
||||
break;
|
||||
|
@ -62,7 +62,7 @@ export function useNoteCapture(props: {
|
|||
choices[choice] = {
|
||||
...choices[choice],
|
||||
votes: choices[choice].votes + 1,
|
||||
...($i && body.userId === $i.id
|
||||
...(isSignedIn && body.userId === $i.id
|
||||
? {
|
||||
isVoted: true,
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import type { Theme } from "./scripts/theme";
|
||||
import { api } from "@/os";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
|
||||
const lsCacheKey = $i ? `themes:${$i.id}` : "";
|
||||
const lsCacheKey = isSignedIn ? `themes:${$i.id}` : "";
|
||||
|
||||
export function getThemes(): Theme[] {
|
||||
return JSON.parse(localStorage.getItem(lsCacheKey) || "[]");
|
||||
}
|
||||
|
||||
export async function fetchThemes(): Promise<void> {
|
||||
if ($i == null) return;
|
||||
if (!isSignedIn) return;
|
||||
|
||||
try {
|
||||
const themes = await api("i/registry/get", {
|
||||
|
|
|
@ -22,7 +22,7 @@ import { swInject } from "./sw-inject";
|
|||
import { popup, popups } from "@/os";
|
||||
import { uploads } from "@/scripts/upload";
|
||||
import * as sound from "@/scripts/sound";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
import { stream } from "@/stream";
|
||||
|
||||
const XStreamIndicator = defineAsyncComponent(
|
||||
|
@ -55,7 +55,7 @@ const onNotification = (notification) => {
|
|||
sound.play("notification");
|
||||
};
|
||||
|
||||
if ($i) {
|
||||
if (isSignedIn) {
|
||||
const connection = stream.useChannel("main", null, "UI");
|
||||
connection.on("notification", onNotification);
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
</template>
|
||||
<div class="divider"></div>
|
||||
<MkA
|
||||
v-if="$i.isAdmin || $i.isModerator"
|
||||
v-if="isModerator"
|
||||
v-click-anime
|
||||
class="item"
|
||||
active-class="active"
|
||||
|
@ -130,6 +130,7 @@ import { computed, defineAsyncComponent, toRef } from "vue";
|
|||
import * as os from "@/os";
|
||||
import { navbarItemDef } from "@/navbar";
|
||||
import { openAccountMenu as openAccountMenu_ } from "@/account";
|
||||
import { $i, isModerator } from "@/reactiveAccount";
|
||||
import { openHelpMenu_ } from "@/scripts/helpMenu";
|
||||
import { defaultStore } from "@/store";
|
||||
import { i18n } from "@/i18n";
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
</template>
|
||||
<div class="divider"></div>
|
||||
<MkA
|
||||
v-if="$i.isAdmin || $i.isModerator"
|
||||
v-if="isModerator"
|
||||
v-click-anime
|
||||
v-tooltip.noDelay.right="i18n.ts.controlPanel"
|
||||
class="item _button"
|
||||
|
@ -150,7 +150,7 @@ import { computed, defineAsyncComponent, ref, watch } from "vue";
|
|||
import * as os from "@/os";
|
||||
import { navbarItemDef } from "@/navbar";
|
||||
import { openAccountMenu as openAccountMenu_ } from "@/account";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isAdmin, isModerator } from "@/reactiveAccount";
|
||||
import { openHelpMenu_ } from "@/scripts/helpMenu";
|
||||
import { defaultStore } from "@/store";
|
||||
import { i18n } from "@/i18n";
|
||||
|
@ -195,7 +195,7 @@ const noEmailServer = !instance.enableEmail;
|
|||
const thereIsUnresolvedAbuseReport = ref(false);
|
||||
const updateAvailable = ref(false);
|
||||
|
||||
if ($i?.isAdmin) {
|
||||
if (isAdmin) {
|
||||
os.api("admin/abuse-user-reports", {
|
||||
state: "unresolved",
|
||||
limit: 1,
|
||||
|
|
|
@ -241,7 +241,7 @@ watch(route, () => {
|
|||
const columns = deckStore.reactiveState.columns;
|
||||
const layout = deckStore.reactiveState.layout;
|
||||
const menuIndicated = computed(() => {
|
||||
if ($i == null) return false;
|
||||
if (!isSignedIn) return false;
|
||||
for (const def in navbarItemDef) {
|
||||
if (navbarItemDef[def].indicated) return true;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ import type { Column } from "./deck-store";
|
|||
import { removeColumn, updateColumn } from "./deck-store";
|
||||
import XTimeline from "@/components/MkTimeline.vue";
|
||||
import * as os from "@/os";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { isSignedIn, isModerator } from "@/reactiveAccount";
|
||||
import { instance } from "@/instance";
|
||||
import { i18n } from "@/i18n";
|
||||
import icon from "@/scripts/icon";
|
||||
|
@ -72,10 +72,9 @@ const columnActive = ref(true);
|
|||
onMounted(() => {
|
||||
if (props.column.tl == null) {
|
||||
setType();
|
||||
} else if ($i) {
|
||||
} else if (isSignedIn) {
|
||||
disabled.value =
|
||||
!$i.isModerator &&
|
||||
!$i.isAdmin &&
|
||||
!isModerator &&
|
||||
((instance.disableLocalTimeline &&
|
||||
["local", "social"].includes(props.column.tl)) ||
|
||||
(instance.disableRecommendedTimeline &&
|
||||
|
|
Loading…
Reference in a new issue