forked from naskya/firefish
refactor: replace confusing expressions relevant to accounts
$i != null -> isSignedIn $i.isModerator || $i.isAdmin -> isModerator $i.isAdmin -> isAdmin $i.emojiModPerm !== "unauthorized" -> isEmojiMod iAmModerator, iAmAdmin, iAmEmojiMod -> isModerator, isAdmin, isEmojiMod
This commit is contained in:
parent
5ce9d75661
commit
8a46b92948
44 changed files with 186 additions and 197 deletions
|
@ -12,10 +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 const iAmEmojiMod = iAmModerator || $i?.emojiModPerm !== "unauthorized";
|
||||
|
||||
export async function signout() {
|
||||
waiting();
|
||||
localStorage.removeItem("account");
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<i :class="icon('ph-dots-three-outline')"></i>
|
||||
</button>
|
||||
<button
|
||||
v-if="!hideFollowButton && $i != null && $i.id != user.id"
|
||||
v-if="!hideFollowButton && 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 { useStream } 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,
|
||||
|
|
|
@ -49,7 +49,7 @@ import MkPullToRefresh from "@/components/MkPullToRefresh.vue";
|
|||
import MkInfo from "@/components/MkInfo.vue";
|
||||
import { useStream } 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";
|
||||
|
@ -77,14 +77,12 @@ let tlHintClosed: boolean;
|
|||
let tlNotesCount = 0;
|
||||
const queue = ref(0);
|
||||
|
||||
const isSignedIn = $i != null;
|
||||
|
||||
const prepend = (note) => {
|
||||
tlNotesCount++;
|
||||
tlComponent.value?.pagingComponent?.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");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -208,19 +208,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"
|
||||
:class="{ 'followed-emph': emphasizeFollowed }"
|
||||
>{{ i18n.ts.followsYou }}</span
|
||||
|
@ -80,7 +80,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>
|
||||
|
@ -96,6 +99,7 @@ import MkNumber from "@/components/MkNumber.vue";
|
|||
import { userPage } from "@/filters/user";
|
||||
import { i18n } from "@/i18n";
|
||||
import { defaultStore } from "@/store";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
|
||||
const props = defineProps<{
|
||||
user: firefish.entities.UserDetailed;
|
||||
|
|
|
@ -41,7 +41,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";
|
||||
|
@ -253,7 +253,7 @@ function checkForSplash() {
|
|||
// テーマリビルドするため
|
||||
localStorage.removeItem("theme");
|
||||
|
||||
if ($i && defaultStore.state.showUpdates) {
|
||||
if (isSignedIn && defaultStore.state.showUpdates) {
|
||||
popup(
|
||||
defineAsyncComponent(() => import("@/components/MkUpdated.vue")),
|
||||
{},
|
||||
|
@ -264,7 +264,7 @@ function checkForSplash() {
|
|||
}
|
||||
|
||||
if (
|
||||
$i &&
|
||||
isSignedIn &&
|
||||
defaultStore.state.tutorial === -1 &&
|
||||
!["/announcements", "/announcements/"].includes(window.location.pathname)
|
||||
) {
|
||||
|
@ -418,7 +418,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
|
||||
|
@ -272,11 +272,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";
|
||||
|
@ -302,7 +301,7 @@ const props = defineProps<{
|
|||
}>();
|
||||
|
||||
const tabs = ["overview"];
|
||||
if (iAmAdmin) tabs.push("users", "raw");
|
||||
if (isAdmin) tabs.push("users", "raw");
|
||||
const tab = ref(tabs[0]);
|
||||
watch(tab, () => syncSlide(tabs.indexOf(tab.value)));
|
||||
|
||||
|
@ -314,7 +313,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",
|
||||
|
@ -325,7 +324,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,
|
||||
|
@ -410,7 +409,7 @@ const theTabs = [
|
|||
},
|
||||
];
|
||||
|
||||
if (iAmAdmin) {
|
||||
if (isAdmin) {
|
||||
theTabs.push(
|
||||
{
|
||||
key: "users",
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -70,15 +70,15 @@ import bytes from "@/filters/bytes";
|
|||
import { defaultStore } from "@/store";
|
||||
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 { useStream } 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";
|
||||
|
@ -164,7 +164,7 @@ interface Profile {
|
|||
};
|
||||
}
|
||||
|
||||
const connection = $i && stream.useChannel("main");
|
||||
const connection = isSignedIn && stream.useChannel("main");
|
||||
|
||||
const profiles = ref<Record<string, Profile> | null>(null);
|
||||
|
||||
|
|
|
@ -75,15 +75,13 @@ 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";
|
||||
|
||||
const isSignedIn = $i != null;
|
||||
|
||||
if (isSignedIn && defaultStore.reactiveState.tutorial.value !== -1) {
|
||||
os.popup(XTutorial, {}, {}, "closed");
|
||||
}
|
||||
|
@ -92,14 +90,14 @@ const isHomeTimelineAvailable = isSignedIn;
|
|||
const isLocalTimelineAvailable =
|
||||
(!instance.disableLocalTimeline &&
|
||||
(isSignedIn || instance.enableGuestTimeline)) ||
|
||||
($i != null && ($i.isModerator || $i.isAdmin));
|
||||
isModerator;
|
||||
const isSocialTimelineAvailable = isLocalTimelineAvailable && isSignedIn;
|
||||
const isRecommendedTimelineAvailable =
|
||||
!instance.disableRecommendedTimeline && isSignedIn;
|
||||
const isGlobalTimelineAvailable =
|
||||
(!instance.disableGlobalTimeline &&
|
||||
(isSignedIn || instance.enableGuestTimeline)) ||
|
||||
($i != null && ($i.isModerator || $i.isAdmin));
|
||||
isModerator;
|
||||
const keymap = {
|
||||
t: focus,
|
||||
};
|
||||
|
|
|
@ -209,7 +209,7 @@
|
|||
<FormSwitch
|
||||
v-if="
|
||||
user.host == null &&
|
||||
$i.isAdmin &&
|
||||
isAdmin &&
|
||||
(moderator || !user.isAdmin)
|
||||
"
|
||||
v-model="moderator"
|
||||
|
@ -232,7 +232,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"
|
||||
|
@ -240,14 +240,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"
|
||||
|
@ -255,7 +255,7 @@
|
|||
{{ i18n.ts.delete2fa }}</FormButton
|
||||
>
|
||||
<FormButton
|
||||
v-if="user.host == null && $i.isAdmin"
|
||||
v-if="user.host == null && isAdmin"
|
||||
inline
|
||||
danger
|
||||
@click="deletePasskeys"
|
||||
|
@ -263,7 +263,7 @@
|
|||
{{ i18n.ts.deletePasskeys }}</FormButton
|
||||
>
|
||||
<FormButton
|
||||
v-if="$i.isAdmin"
|
||||
v-if="isAdmin"
|
||||
inline
|
||||
primary
|
||||
danger
|
||||
|
@ -281,14 +281,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"
|
||||
|
@ -336,7 +336,7 @@
|
|||
</FormSection>
|
||||
</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>
|
||||
|
@ -359,7 +359,6 @@ import FormInput from "@/components/form/input.vue";
|
|||
import FormFolder from "@/components/form/folder.vue";
|
||||
import FormSelect from "@/components/form/select.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";
|
||||
|
@ -368,7 +367,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";
|
||||
|
||||
|
@ -397,7 +396,7 @@ const filesPagination = {
|
|||
};
|
||||
|
||||
function createFetcher() {
|
||||
if (iAmModerator) {
|
||||
if (isModerator) {
|
||||
return () =>
|
||||
Promise.all([
|
||||
os.api("users/show", {
|
||||
|
@ -406,7 +405,7 @@ function createFetcher() {
|
|||
os.api("admin/show-user", {
|
||||
userId: props.userId,
|
||||
}),
|
||||
iAmAdmin
|
||||
isAdmin
|
||||
? os.api("admin/get-user-ips", {
|
||||
userId: props.userId,
|
||||
})
|
||||
|
@ -639,7 +638,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"
|
||||
|
@ -134,8 +134,8 @@
|
|||
/>
|
||||
<span
|
||||
v-if="
|
||||
$i &&
|
||||
$i.id != user.id &&
|
||||
isSignedIn &&
|
||||
$i.id !== user.id &&
|
||||
user.isFollowed
|
||||
"
|
||||
class="followed"
|
||||
|
@ -144,7 +144,7 @@
|
|||
}"
|
||||
>{{ 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"
|
||||
|
@ -346,7 +346,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
|
||||
>
|
||||
|
@ -389,7 +389,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 { useStream } from "./stream";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
|
||||
type StateDef = Record<
|
||||
string,
|
||||
|
@ -17,7 +17,7 @@ type StateDef = Record<
|
|||
type ArrayElement<A> = A extends readonly (infer T)[] ? T : never;
|
||||
|
||||
const stream = useStream();
|
||||
const connection = $i && stream.useChannel("main");
|
||||
const connection = isSignedIn && stream.useChannel("main");
|
||||
|
||||
export class Storage<T extends StateDef> {
|
||||
public readonly key: string;
|
||||
|
@ -43,12 +43,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}`) ||
|
||||
"{}",
|
||||
|
@ -65,7 +65,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];
|
||||
|
@ -85,7 +85,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(
|
||||
|
@ -169,7 +169,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}`) || "{}",
|
||||
);
|
||||
|
@ -181,7 +181,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,8 @@ const accountData = localStorage.getItem("account");
|
|||
export const $i = accountData
|
||||
? reactive(JSON.parse(accountData) as Account)
|
||||
: null;
|
||||
|
||||
export const isSignedIn = $i != null;
|
||||
export const isModerator = isSignedIn && ($i.isModerator || $i.isAdmin);
|
||||
export const isAdmin = isSignedIn && $i.isAdmin;
|
||||
export const isEmojiMod = isSignedIn && $i.emojiModPerm !== "unauthorized";
|
||||
|
|
|
@ -1,21 +1,10 @@
|
|||
import type { AsyncComponentLoader } from "vue";
|
||||
import { defineAsyncComponent, inject } from "vue";
|
||||
import { iAmEmojiMod, iAmModerator } from "@/account";
|
||||
import { isModerator, isEmojiMod } 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();
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
|
||||
const page = (loader: AsyncComponentLoader<any>) =>
|
||||
defineAsyncComponent({
|
||||
|
@ -311,10 +300,9 @@ export const routes = [
|
|||
},
|
||||
{
|
||||
path: "/search",
|
||||
component:
|
||||
$i != null
|
||||
? page(() => import("./pages/search.vue"))
|
||||
: page(() => import("./pages/not-found.vue")),
|
||||
component: isSignedIn
|
||||
? page(() => import("./pages/search.vue"))
|
||||
: page(() => import("./pages/not-found.vue")),
|
||||
query: {
|
||||
q: "query",
|
||||
channel: "channel",
|
||||
|
@ -429,20 +417,20 @@ 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/emojis",
|
||||
name: "emojis",
|
||||
component: iAmEmojiMod
|
||||
component: isEmojiMod
|
||||
? page(() => import("./pages/admin/emojis.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: [
|
||||
|
|
|
@ -2,7 +2,7 @@ import { url } from "@/config";
|
|||
import { i18n } from "@/i18n";
|
||||
import { instance } from "@/instance";
|
||||
import * as os from "@/os";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn, isModerator } from "@/reactiveAccount";
|
||||
import copyToClipboard from "@/scripts/copy-to-clipboard";
|
||||
import { getUserMenu } from "@/scripts/get-user-menu";
|
||||
import icon from "@/scripts/icon";
|
||||
|
@ -230,18 +230,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({
|
||||
|
@ -283,13 +283,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
|
||||
|
@ -410,7 +409,7 @@ export function getNoteMenu(props: {
|
|||
],
|
||||
},
|
||||
/*
|
||||
...($i.isModerator || $i.isAdmin ? [
|
||||
...(isModerator ? [
|
||||
null,
|
||||
{
|
||||
icon: `${icon('ph-megaphone-simple')}`,
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { iAmModerator } from "@/account";
|
||||
import { $i, isModerator, isSignedIn } from "@/reactiveAccount";
|
||||
import { host } from "@/config";
|
||||
import { i18n } from "@/i18n";
|
||||
import type { Router } from "@/nirax";
|
||||
import * as os from "@/os";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { mainRouter } from "@/router";
|
||||
import copyToClipboard from "@/scripts/copy-to-clipboard";
|
||||
import icon from "@/scripts/icon";
|
||||
|
@ -12,8 +11,6 @@ import * as Acct from "firefish-js/built/acct";
|
|||
import { defineAsyncComponent } from "vue";
|
||||
|
||||
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 { i18n } from "@/i18n";
|
||||
import { popup } from "@/os";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { isSignedIn } from "@/reactiveAccount";
|
||||
import { vibrate } from "@/scripts/vibrate";
|
||||
import { defineAsyncComponent } from "vue";
|
||||
|
||||
export function pleaseLogin(path?: string) {
|
||||
if ($i) return;
|
||||
if (isSignedIn) return;
|
||||
vibrate(100);
|
||||
|
||||
popup(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as os from "@/os";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isSignedIn } from "@/reactiveAccount";
|
||||
import { useStream } from "@/stream";
|
||||
import type * as firefish from "firefish-js";
|
||||
import type { Ref } from "vue";
|
||||
|
@ -35,7 +35,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;
|
||||
|
@ -49,7 +49,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;
|
||||
|
@ -63,7 +63,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,6 +1,6 @@
|
|||
import { markRaw, ref } from "vue";
|
||||
import { Storage } from "./pizzax";
|
||||
import { $i } from "./reactiveAccount";
|
||||
import { isSignedIn } from "./reactiveAccount";
|
||||
|
||||
export const postFormActions = [];
|
||||
export const userActions = [];
|
||||
|
@ -157,7 +157,7 @@ export const defaultStore = markRaw(
|
|||
tl: {
|
||||
where: "deviceAccount",
|
||||
default: {
|
||||
src: ($i != null ? "home" : "local") as
|
||||
src: (isSignedIn ? "home" : "local") as
|
||||
| "home"
|
||||
| "local"
|
||||
| "social"
|
||||
|
|
|
@ -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 { useStream } from "@/stream";
|
||||
|
||||
const stream = useStream();
|
||||
|
@ -57,7 +57,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"
|
||||
|
@ -81,7 +81,7 @@
|
|||
><span class="text">{{ i18n.ts.controlPanel }}</span>
|
||||
</MkA>
|
||||
<MkA
|
||||
v-else-if="$i.emojiModPerm !== 'unauthorized'"
|
||||
v-else-if="isEmojiMod"
|
||||
v-click-anime
|
||||
v-tooltip.noDelay.right="i18n.ts.customEmojis"
|
||||
class="item _button"
|
||||
|
@ -141,7 +141,7 @@ import { computed, defineAsyncComponent, toRef } from "vue";
|
|||
import * as os from "@/os";
|
||||
import { navbarItemDef } from "@/navbar";
|
||||
import { openAccountMenu as openAccountMenu_ } from "@/account";
|
||||
import { $i } from "@/reactiveAccount";
|
||||
import { $i, isEmojiMod, 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"
|
||||
|
@ -93,7 +93,7 @@
|
|||
><span class="text">{{ i18n.ts.controlPanel }}</span>
|
||||
</MkA>
|
||||
<MkA
|
||||
v-else-if="$i.emojiModPerm !== 'unauthorized'"
|
||||
v-else-if="isEmojiMod"
|
||||
v-click-anime
|
||||
v-tooltip.noDelay.right="i18n.ts.customEmojis"
|
||||
class="item _button"
|
||||
|
@ -161,7 +161,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, isEmojiMod, isModerator } from "@/reactiveAccount";
|
||||
import { openHelpMenu_ } from "@/scripts/helpMenu";
|
||||
import { defaultStore } from "@/store";
|
||||
import { i18n } from "@/i18n";
|
||||
|
@ -206,7 +206,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