refactor (client): $i -> me

This commit is contained in:
naskya 2024-03-07 11:06:45 +09:00
parent ce406f9861
commit 5fb3253069
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
92 changed files with 314 additions and 320 deletions

View file

@ -3,8 +3,7 @@ import { defineAsyncComponent } from "vue";
import { i18n } from "./i18n";
import { apiUrl } from "@/config";
import { alert, api, popup, popupMenu, waiting } from "@/os";
import { $i } from "@/reactiveAccount";
import icon from "@/scripts/icon";
import { me } from "@/me";
import { del, get, set } from "@/scripts/idb-proxy";
import { reloadChannel, unisonReload } from "@/scripts/unison-reload";
@ -16,7 +15,7 @@ export async function signout() {
waiting();
localStorage.removeItem("account");
await removeAccount($i.id);
await removeAccount(me.id);
const accounts = await getAccounts();
@ -29,7 +28,7 @@ export async function signout() {
await fetch(`${apiUrl}/sw/unregister`, {
method: "POST",
body: JSON.stringify({
i: $i.token,
i: me.token,
endpoint: push.endpoint,
}),
});
@ -117,22 +116,23 @@ function showSuspendedDialog() {
export function updateAccount(accountData) {
for (const [key, value] of Object.entries(accountData)) {
$i[key] = value;
me[key] = value;
}
localStorage.setItem("account", JSON.stringify($i));
localStorage.setItem("account", JSON.stringify(me));
}
export function refreshAccount() {
return fetchAccount($i.token).then(updateAccount);
export async function refreshAccount() {
const accountData = await fetchAccount(me.token);
return updateAccount(accountData);
}
export async function login(token: Account["token"], redirect?: string) {
waiting();
if (_DEV_) console.log("logging as token ", token);
const me = await fetchAccount(token);
localStorage.setItem("account", JSON.stringify(me));
const newAccount = await fetchAccount(token);
localStorage.setItem("account", JSON.stringify(newAccount));
document.cookie = `token=${token}; path=/; max-age=31536000`; // bull dashboardの認証とかで使う
await addAccount(me.id, token);
await addAccount(newAccount.id, token);
if (redirect) {
// 他のタブは再読み込みするだけ
@ -194,7 +194,7 @@ export async function openAccountMenu(
}
const storedAccounts = await getAccounts().then((accounts) =>
accounts.filter((x) => x.id !== $i.id),
accounts.filter((x) => x.id !== me.id),
);
const accountsPromise = api("users/show", {
userIds: storedAccounts.map((x) => x.id),
@ -256,12 +256,12 @@ export async function openAccountMenu(
{
type: "link",
text: i18n.ts.profile,
to: `/@${$i.username}`,
avatar: $i,
to: `/@${me.username}`,
avatar: me,
},
null,
]),
...(opts.includeCurrentAccount ? [createItem($i)] : []),
...(opts.includeCurrentAccount ? [createItem(me)] : []),
...accountItemPromises,
...(isMobile ?? false
? [
@ -269,8 +269,8 @@ export async function openAccountMenu(
{
type: "link",
text: i18n.ts.profile,
to: `/@${$i.username}`,
avatar: $i,
to: `/@${me.username}`,
avatar: me,
},
]
: [
@ -304,7 +304,7 @@ export async function openAccountMenu(
} else {
popupMenu(
[
...(opts.includeCurrentAccount ? [createItem($i)] : []),
...(opts.includeCurrentAccount ? [createItem(me)] : []),
...accountItemPromises,
],
ev.currentTarget ?? ev.target,

View file

@ -4,7 +4,7 @@
:class="{
isMe: isMe(message),
isRead: message.groupId
? message.reads.includes($i?.id)
? message.reads.includes(me?.id)
: message.isRead,
}"
:to="
@ -67,14 +67,14 @@
<script lang="ts" setup>
import { acct } from "firefish-js";
import { i18n } from "@/i18n";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
defineProps<{
message: Record<string, any>;
}>();
function isMe(message): boolean {
return message.userId === $i?.id;
return message.userId === me?.id;
}
</script>

View file

@ -42,7 +42,7 @@ import Cropper from "cropperjs";
import tinycolor from "tinycolor2";
import XModalWindow from "@/components/MkModalWindow.vue";
import * as os from "@/os";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { defaultStore } from "@/store";
import { apiUrl, url } from "@/config";
import { query } from "@/scripts/url";
@ -81,7 +81,7 @@ const ok = async () => {
method: "POST",
body: formData,
headers: {
authorization: `Bearer ${$i.token}`,
authorization: `Bearer ${me.token}`,
},
})
.then((response) => response.json())

View file

@ -9,11 +9,11 @@
@dragstart="onDragstart"
@dragend="onDragend"
>
<div v-if="$i?.avatarId == file.id" class="label">
<div v-if="me?.avatarId == file.id" class="label">
<img src="/client-assets/label.svg" />
<p>{{ i18n.ts.avatar }}</p>
</div>
<div v-if="$i?.bannerId == file.id" class="label">
<div v-if="me?.bannerId == file.id" class="label">
<img src="/client-assets/label.svg" />
<p>{{ i18n.ts.banner }}</p>
</div>
@ -45,7 +45,7 @@ import MkDriveFileThumbnail from "@/components/MkDriveFileThumbnail.vue";
import bytes from "@/filters/bytes";
import * as os from "@/os";
import { i18n } from "@/i18n";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import icon from "@/scripts/icon";
const props = withDefaults(

View file

@ -8,7 +8,7 @@
<i :class="icon('ph-dots-three-outline')"></i>
</button>
<button
v-if="!hideFollowButton && isSignedIn && $i.id != user.id"
v-if="!hideFollowButton && isSignedIn && me.id != user.id"
v-tooltip="full ? null : `${state} ${user.name || user.username}`"
class="kpoogebi _button follow-button"
:class="{
@ -66,7 +66,7 @@ import type { entities } from "firefish-js";
import * as os from "@/os";
import { useStream } from "@/stream";
import { i18n } from "@/i18n";
import { $i, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
import { getUserMenu } from "@/scripts/get-user-menu";
import { useRouter } from "@/router";
import { vibrate } from "@/scripts/vibrate";

View file

@ -36,7 +36,7 @@
<script lang="ts" setup>
import { toUnicode } from "punycode";
import { host as localHost } from "@/config";
import { $i, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
import { defaultStore } from "@/store";
const props = defineProps<{
@ -53,8 +53,8 @@ const url = `/${canonical}`;
const isMe =
isSignedIn &&
`@${props.username}@${toUnicode(props.host)}` ===
`@${$i.username}@${toUnicode(localHost)}`.toLowerCase();
`@${props.username}@${toUnicode(props.host)}`.toLowerCase() ===
`@${me.username}@${toUnicode(localHost)}`.toLowerCase();
</script>
<style lang="scss" scoped>

View file

@ -127,7 +127,7 @@
<Mfm
:text="translation.text"
:author="appearNote.user"
:i="$i"
:i="me"
:lang="targetLang"
:custom-emojis="appearNote.emojis"
/>
@ -296,7 +296,7 @@ import { userPage } from "@/filters/user";
import * as os from "@/os";
import { defaultStore, noteViewInterruptors } from "@/store";
import { reactionPicker } from "@/scripts/reaction-picker";
import { $i, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
import { i18n } from "@/i18n";
import { getNoteMenu } from "@/scripts/get-note-menu";
import { useNoteCapture } from "@/scripts/use-note-capture";
@ -355,13 +355,13 @@ const reactButton = ref<HTMLElement>();
const appearNote = computed(() =>
isRenote ? (note.value.renote as entities.Note) : note.value,
);
const isMyRenote = isSignedIn && $i.id === note.value.userId;
const isMyRenote = isSignedIn && me.id === note.value.userId;
const showContent = ref(false);
const isDeleted = ref(false);
const muted = ref(
getWordSoftMute(
note.value,
$i?.id,
me?.id,
defaultStore.state.mutedWords,
defaultStore.state.mutedLangs,
),

View file

@ -180,7 +180,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 { me } from "@/me";
import { i18n } from "@/i18n";
import { getNoteMenu } from "@/scripts/get-note-menu";
import { useNoteCapture } from "@/scripts/use-note-capture";
@ -235,7 +235,7 @@ const isDeleted = ref(false);
const muted = ref(
getWordSoftMute(
note.value,
$i?.id,
me?.id,
defaultStore.state.mutedWords,
defaultStore.state.mutedLangs,
),

View file

@ -1,17 +1,17 @@
<template>
<div v-size="{ min: [350, 500] }" class="fefdfafb">
<MkAvatar class="avatar" :user="$i" disable-link />
<MkAvatar class="avatar" :user="me" disable-link />
<div class="main">
<div class="header">
<MkUserName :user="$i" />
<MkUserName :user="me" />
</div>
<div class="body">
<div class="content">
<Mfm
:text="preprocess(text).trim()"
:lang="lang"
:author="$i"
:i="$i"
:author="me"
:i="me"
advanced-mfm
/>
</div>

View file

@ -50,7 +50,7 @@
<Mfm
:text="translation.text"
:author="appearNote.user"
:i="$i"
:i="me"
:lang="targetLang"
:custom-emojis="appearNote.emojis"
/>
@ -211,7 +211,7 @@ import { useRouter } from "@/router";
import { userPage } from "@/filters/user";
import * as os from "@/os";
import { reactionPicker } from "@/scripts/reaction-picker";
import { $i, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
import { i18n } from "@/i18n";
import { useNoteCapture } from "@/scripts/use-note-capture";
import { defaultStore } from "@/store";
@ -269,7 +269,7 @@ const isDeleted = ref(false);
const muted = ref(
getWordSoftMute(
note.value,
$i?.id,
me?.id,
defaultStore.state.mutedWords,
defaultStore.state.mutedLangs,
),

View file

@ -54,7 +54,7 @@ import XNotification from "@/components/MkNotification.vue";
import XList from "@/components/MkDateSeparatedList.vue";
import XNote from "@/components/MkNote.vue";
import { useStream } from "@/stream";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { i18n } from "@/i18n";
const props = defineProps<{
@ -73,7 +73,7 @@ const pagination: Paging = {
includeTypes: props.includeTypes ?? undefined,
excludeTypes: props.includeTypes
? undefined
: $i.mutingNotificationTypes,
: me.mutingNotificationTypes,
unreadOnly: props.unreadOnly,
})),
};
@ -81,7 +81,7 @@ const pagination: Paging = {
const onNotification = (notification) => {
const isMuted = props.includeTypes
? !props.includeTypes.includes(notification.type)
: $i.mutingNotificationTypes.includes(notification.type);
: me.mutingNotificationTypes.includes(notification.type);
if (isMuted || document.visibilityState === "visible") {
stream.send("readNotification", {
id: notification.id,

View file

@ -20,7 +20,7 @@
class="account _button"
@click="openAccountMenu"
>
<MkAvatar :user="postAccount ?? $i" class="avatar" />
<MkAvatar :user="postAccount ?? me" class="avatar" />
</button>
<div class="right">
<span
@ -322,7 +322,7 @@ import MkInfo from "@/components/MkInfo.vue";
import { i18n } from "@/i18n";
import { instance } from "@/instance";
import { getAccounts, openAccountMenu as openAccountMenu_ } from "@/account";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { uploadFile } from "@/scripts/upload";
import { deepClone } from "@/scripts/clone";
import XCheatSheet from "@/components/MkCheatSheetDialog.vue";
@ -517,7 +517,7 @@ if (props.mention) {
if (
props.reply &&
(props.reply.user.username !== $i.username ||
(props.reply.user.username !== me.username ||
(props.reply.user.host != null && props.reply.user.host !== host))
) {
text.value = `@${props.reply.user.username}${
@ -539,7 +539,7 @@ if (props.reply && props.reply.text != null) {
: `@${x.username}@${toASCII(otherHost)}`;
// exclude me
if ($i.username === x.username && (x.host == null || x.host === host))
if (me.username === x.username && (x.host == null || x.host === host))
continue;
// remove duplicates
@ -573,7 +573,7 @@ if (
if (props.reply.visibleUserIds) {
os.api("users/show", {
userIds: props.reply.visibleUserIds.filter(
(uid) => uid !== $i.id && uid !== props.reply.userId,
(uid) => uid !== me.id && uid !== props.reply.userId,
),
}).then((users) => {
users.forEach(pushVisibleUser);
@ -582,7 +582,7 @@ if (
visibility.value = "private";
}
if (props.reply.userId !== $i.id) {
if (props.reply.userId !== me.id) {
os.api("users/show", { userId: props.reply.userId }).then(
(user) => {
pushVisibleUser(user);
@ -611,7 +611,7 @@ const addRe = (s: string) => {
if (defaultStore.state.keepCw && props.reply && props.reply.cw) {
useCw.value = true;
cw.value =
props.reply.user.username === $i.username
props.reply.user.username === me.username
? props.reply.cw
: addRe(props.reply.cw);
}
@ -1194,9 +1194,9 @@ function openAccountMenu(ev: MouseEvent) {
{
withExtraOperation: false,
includeCurrentAccount: true,
active: postAccount.value != null ? postAccount.value.id : $i.id,
active: postAccount.value != null ? postAccount.value.id : me.id,
onChoose: (account) => {
if (account.id === $i.id) {
if (account.id === me.id) {
postAccount.value = null;
} else {
postAccount.value = account;

View file

@ -56,7 +56,7 @@
import { ref } from "vue";
import { getAccounts } from "@/account";
import { $i, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
import MkButton from "@/components/MkButton.vue";
import { instance } from "@/instance";
import { api, apiWithDialog, promiseDialog } from "@/os";
@ -149,7 +149,7 @@ async function unsubscribe() {
if (isSignedIn && accounts.length >= 2) {
apiWithDialog("sw/unregister", {
i: $i.token,
i: me.token,
endpoint,
});
} else {
@ -197,7 +197,7 @@ if (navigator.serviceWorker == null) {
instance.swPublickey &&
"PushManager" in window &&
isSignedIn &&
$i.token
me.token
) {
supported.value = true;

View file

@ -14,7 +14,7 @@ import { computed } from "vue";
import type { entities } from "firefish-js";
import { pleaseLogin } from "@/scripts/please-login";
import * as os from "@/os";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { i18n } from "@/i18n";
import { defaultStore } from "@/store";
import icon from "@/scripts/icon";
@ -26,7 +26,7 @@ const props = defineProps<{
const canRenote = computed(
() =>
["public", "home"].includes(props.note.visibility) ||
props.note.userId === $i?.id,
props.note.userId === me?.id,
);
function quote(): void {

View file

@ -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 { isSignedIn } from "@/reactiveAccount";
import { isSignedIn } from "@/me";
const props = defineProps<{
reaction: string;

View file

@ -19,7 +19,7 @@
<script lang="ts" setup>
import { computed, ref } from "vue";
import type { entities } from "firefish-js";
import { $i, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
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(() => isSignedIn && $i.id === props.note.userId);
const isMe = computed(() => isSignedIn && me.id === props.note.userId);
</script>
<style lang="scss" scoped>

View file

@ -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, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
import { useTooltip } from "@/scripts/use-tooltip";
import { i18n } from "@/i18n";
import { defaultStore } from "@/store";
@ -46,7 +46,7 @@ const buttonRef = ref<HTMLElement>();
const canRenote = computed(
() =>
["public", "home"].includes(props.note.visibility) ||
props.note.userId === $i.id,
props.note.userId === me.id,
);
useTooltip(buttonRef, async (showing) => {
@ -77,7 +77,7 @@ const hasRenotedBefore = ref(false);
if (isSignedIn) {
os.api("notes/renotes", {
noteId: props.note.id,
userId: $i.id,
userId: me.id,
limit: 1,
}).then((res) => {
hasRenotedBefore.value = res.length > 0;

View file

@ -52,7 +52,7 @@ export default defineComponent({
flag: true,
radio: "firefish",
mfm: `Hello world! This is an @example mention. BTW, you are @${
this.$i ? this.$i.username : "guest"
this.me ? this.me.username : "guest"
}.\nAlso, here is ${config.url} and [example link](${
config.url
}). for more details, see <https://firefish.dev/firefish/firefish>.\nAs you know #Firefish is open-source software.`,

View file

@ -31,7 +31,7 @@
:text="note.cw"
:author="note.user"
:lang="note.lang"
:i="$i"
:i="me"
:custom-emojis="note.emojis"
/>
</p>
@ -103,7 +103,7 @@
v-if="note.text"
:text="note.text"
:author="note.user"
:i="$i"
:i="me"
:lang="note.lang"
:custom-emojis="note.emojis"
/>

View file

@ -50,7 +50,7 @@ import XNotes from "@/components/MkNotes.vue";
import MkInfo from "@/components/MkInfo.vue";
import { useStream } from "@/stream";
import * as sound from "@/scripts/sound";
import { $i, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
import { i18n } from "@/i18n";
import { defaultStore } from "@/store";
import icon from "@/scripts/icon";
@ -103,7 +103,7 @@ const prepend = (note) => {
emit("note");
if (props.sound) {
sound.play(isSignedIn && note.userId === $i.id ? "noteMy" : "note");
sound.play(isSignedIn && note.userId === me.id ? "noteMy" : "note");
}
};

View file

@ -211,7 +211,7 @@ import MkPushNotificationAllowButton from "@/components/MkPushNotificationAllowB
import FormSwitch from "@/components/form/switch.vue";
import { defaultStore } from "@/store";
import { i18n } from "@/i18n";
import { isModerator } from "@/reactiveAccount";
import { isModerator } from "@/me";
import { instance } from "@/instance";
import icon from "@/scripts/icon";

View file

@ -8,7 +8,7 @@
:class="{ detailed }"
>
<span
v-if="isSignedIn && $i.id !== user.id && user.isFollowed"
v-if="isSignedIn && me.id !== user.id && user.isFollowed"
class="followed"
>{{ i18n.ts.followsYou }}</span
>
@ -34,7 +34,7 @@
class="mfm"
:text="user.description"
:author="user"
:i="$i"
:i="me"
:custom-emojis="user.emojis"
/>
<span v-else style="opacity: 0.7">{{
@ -56,7 +56,7 @@
<Mfm
:text="field.value"
:author="user"
:i="$i"
:i="me"
:custom-emojis="user.emojis"
:colored="false"
/>
@ -80,7 +80,7 @@
<div class="buttons">
<slot>
<MkFollowButton
v-if="isSignedIn && user.id !== $i.id"
v-if="isSignedIn && user.id !== me.id"
:user="user"
/>
</slot>
@ -97,7 +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";
import { me, isSignedIn } from "@/me";
const props = defineProps<{
user: entities.UserDetailed;

View file

@ -20,10 +20,10 @@
<i :class="icon('ph-caret-left')"></i>
</button>
<MkAvatar
v-if="narrow && props.displayMyAvatar && $i"
v-if="narrow && props.displayMyAvatar && me"
v-vibrate="5"
class="avatar button"
:user="$i"
:user="me"
:disable-preview="true"
disable-link
@click.stop="openAccountMenu"
@ -139,7 +139,7 @@ import { popupMenu } from "@/os";
import { scrollToTop } from "@/scripts/scroll";
import { injectPageMetadata } from "@/scripts/page-metadata";
import { openAccountMenu as openAccountMenu_ } from "@/account";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { i18n } from "@/i18n";
import icon from "@/scripts/icon";

View file

@ -73,7 +73,7 @@ export default defineComponent({
method: "POST",
body: formData,
headers: {
authorization: `Bearer ${this.$i.token}`,
authorization: `Bearer ${this.me.token}`,
},
})
.then((response) => response.json())

View file

@ -1,6 +1,6 @@
<template>
<div class="mrdgzndn">
<Mfm :key="text" :text="text" :is-note="false" :i="$i" />
<Mfm :key="text" :text="text" :is-note="false" :i="me" />
<MkUrlPreview v-for="url in urls" :key="url" :url="url" class="url" />
</div>
</template>

View file

@ -21,7 +21,7 @@ import { Parser } from "@syuilo/aiscript";
import XBlock from "./page.block.vue";
import { Hpml } from "@/scripts/hpml/evaluator";
import { url } from "@/config";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { defaultStore } from "@/store";
export default defineComponent({
@ -37,7 +37,7 @@ export default defineComponent({
setup(props, ctx) {
const hpml = new Hpml(props.page, {
randomSeed: Math.random(),
visitor: $i,
visitor: me,
url,
enableAiScript: !defaultStore.state.disablePagesScript,
});

View file

@ -39,7 +39,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, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
import { compareFirefishVersions } from "@/scripts/compare-versions";
import { deviceKind } from "@/scripts/device-kind";
import { getAccountFromId } from "@/scripts/get-account-from-id";
@ -76,8 +76,6 @@ function checkForSplash() {
console.info(`vue ${vueVersion}`);
(window as any).$i = $i;
window.addEventListener("error", (event) => {
console.error(event);
/*
@ -132,7 +130,7 @@ function checkForSplash() {
if (loginId) {
const target = getUrlWithoutLoginId(location.href);
if (!$i || $i.id !== loginId) {
if (!me || me.id !== loginId) {
const account = await getAccountFromId(loginId);
if (account) {
await login(account.token, target);
@ -145,7 +143,7 @@ function checkForSplash() {
// #endregion
// #region Fetch user
if ($i?.token) {
if (me?.token) {
if (_DEV_) {
console.log("account cache found. refreshing...");
}
@ -192,7 +190,7 @@ function checkForSplash() {
const app = createApp(
window.location.search === "?zen"
? defineAsyncComponent(() => import("@/ui/zen.vue"))
: !$i
: !me
? defineAsyncComponent(() => import("@/ui/visitor.vue"))
: ui === "deck"
? defineAsyncComponent(() => import("@/ui/deck.vue"))
@ -203,10 +201,6 @@ function checkForSplash() {
app.config.performance = true;
}
app.config.globalProperties = {
$i,
};
widgets(app);
directives(app);
components(app);
@ -258,7 +252,7 @@ function checkForSplash() {
defaultStore.state.showUpdates
) {
// ログインしてる場合だけ
if ($i) {
if (me) {
popup(
defineAsyncComponent(() => import("@/components/MkUpdated.vue")),
{},
@ -432,7 +426,7 @@ function checkForSplash() {
// only add post shortcuts if logged in
hotkeys["p|n"] = post;
if ($i.isDeleted) {
if (me.isDeleted) {
alert({
type: "warning",
text: i18n.ts.accountDeletionInProgress,
@ -446,7 +440,7 @@ function checkForSplash() {
if (Date.now() - lastUsedDate > 1000 * 60 * 60 * 2) {
toast(
i18n.t("welcomeBackWithName", {
name: $i.name || $i.username,
name: me.name || me.username,
}),
);
}
@ -459,7 +453,7 @@ function checkForSplash() {
const neverShowDonationInfo = localStorage.getItem("neverShowDonationInfo");
if (
neverShowDonationInfo !== "true" &&
new Date($i.createdAt).getTime() < Date.now() - 1000 * 60 * 60 * 24 * 3 &&
new Date(me.createdAt).getTime() < Date.now() - 1000 * 60 * 60 * 24 * 3 &&
!location.pathname.startsWith("/miauth")
) {
if (

View file

@ -4,11 +4,11 @@ import type { Account } from "@/account";
const accountData = localStorage.getItem("account");
// TODO: 外部からはreadonlyに
export const $i = accountData
export const me = accountData
? reactive(JSON.parse(accountData) as Account)
: null;
export const isSignedIn = $i != null;
export const isModerator = $i != null && ($i.isModerator || $i.isAdmin);
export const isEmojiMod = isModerator || $i?.emojiModPerm !== "unauthorized";
export const isAdmin = $i?.isAdmin;
export const isSignedIn = me != null;
export const isModerator = me != null && (me.isModerator || me.isAdmin);
export const isEmojiMod = isModerator || me?.emojiModPerm !== "unauthorized";
export const isAdmin = me?.isAdmin;

View file

@ -2,7 +2,7 @@ import { computed, reactive } from "vue";
import { ui } from "@/config";
import { i18n } from "@/i18n";
import * as os from "@/os";
import { $i, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
import icon from "@/scripts/icon";
import { search } from "@/scripts/search";
import { unisonReload } from "@/scripts/unison-reload";
@ -12,14 +12,14 @@ export const navbarItemDef = reactive({
title: "notifications",
icon: `${icon("ph-bell")}`,
show: computed(() => isSignedIn),
indicated: computed(() => $i?.hasUnreadNotification),
indicated: computed(() => me?.hasUnreadNotification),
to: "/my/notifications",
},
messaging: {
title: "messaging",
icon: `${icon("ph-chats-teardrop")}`,
show: computed(() => isSignedIn),
indicated: computed(() => $i?.hasUnreadMessagingMessage),
indicated: computed(() => me?.hasUnreadMessagingMessage),
to: "/my/messaging",
},
drive: {
@ -31,8 +31,8 @@ export const navbarItemDef = reactive({
followRequests: {
title: "followRequests",
icon: `${icon("ph-hand-waving")}`,
show: computed(() => $i?.isLocked || $i?.hasPendingReceivedFollowRequest),
indicated: computed(() => $i?.hasPendingReceivedFollowRequest),
show: computed(() => me?.isLocked || me?.hasPendingReceivedFollowRequest),
indicated: computed(() => me?.hasPendingReceivedFollowRequest),
to: "/my/follow-requests",
},
explore: {
@ -43,7 +43,7 @@ export const navbarItemDef = reactive({
announcements: {
title: "announcements",
icon: `${icon("ph-megaphone-simple")}`,
indicated: computed(() => $i?.hasUnreadAnnouncement),
indicated: computed(() => me?.hasUnreadAnnouncement),
to: "/announcements",
},
search: {

View file

@ -11,7 +11,7 @@ import MkPostFormDialog from "@/components/MkPostFormDialog.vue";
import MkToast from "@/components/MkToast.vue";
import MkWaitingDialog from "@/components/MkWaitingDialog.vue";
import { apiUrl, url } from "@/config";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import type { MenuItem } from "@/types/menu";
export const pendingApiRequestsCount = ref(0);
@ -32,7 +32,7 @@ export const api = ((
pendingApiRequestsCount.value--;
};
const authorizationToken = token ?? $i?.token ?? undefined;
const authorizationToken = token ?? me?.token ?? undefined;
const authorization = authorizationToken
? `Bearer ${authorizationToken}`
: undefined;
@ -77,7 +77,7 @@ export const apiGet = ((
const query = new URLSearchParams(data);
const authorizationToken = token ?? $i?.token ?? undefined;
const authorizationToken = token ?? me?.token ?? undefined;
const authorization = authorizationToken
? `Bearer ${authorizationToken}`
: undefined;

View file

@ -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 { isModerator } from "@/reactiveAccount";
import { isModerator } from "@/me";
import { instance } from "@/instance";
import { defaultStore } from "@/store";
import icon from "@/scripts/icon";

View file

@ -172,7 +172,7 @@ import * as os from "@/os";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
import { deviceKind } from "@/scripts/device-kind";
import { isAdmin, isModerator } from "@/reactiveAccount";
import { isAdmin, isModerator } from "@/me";
import { defaultStore } from "@/store";
import icon from "@/scripts/icon";
import "swiper/scss";

View file

@ -73,7 +73,7 @@ import MkSuperMenu from "@/components/MkSuperMenu.vue";
import MkInfo from "@/components/MkInfo.vue";
import { instance } from "@/instance";
import { version } from "@/config";
import { $i, isAdmin } from "@/reactiveAccount";
import { me, isAdmin } from "@/me";
import * as os from "@/os";
import { lookupUser } from "@/scripts/lookup-user";
import { lookupFile } from "@/scripts/lookup-file";

View file

@ -59,7 +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";
import { isSignedIn } from "@/me";
const pagination = {
endpoint: "announcements" as const,

View file

@ -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 { isSignedIn } from "@/reactiveAccount";
import { isSignedIn } from "@/me";
import { i18n } from "@/i18n";
const props = defineProps<{

View file

@ -71,13 +71,13 @@
<Mfm
:text="channel.description"
:is-note="false"
:i="$i"
:i="me"
/>
</div>
</div>
<XPostForm
v-if="$i"
v-if="me"
:channel="channel"
class="post-form _panel _gap"
fixed
@ -103,7 +103,7 @@ import XTimeline from "@/components/MkTimeline.vue";
import XChannelFollowButton from "@/components/MkChannelFollowButton.vue";
import * as os from "@/os";
import { useRouter } from "@/router";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
import icon from "@/scripts/icon";
@ -132,7 +132,7 @@ function edit() {
}
const headerActions = computed(() => [
...(channel.value && channel.value?.userId === $i?.id
...(channel.value && channel.value?.userId === me?.id
? [
{
icon: `${icon("ph-gear-six")}`,

View file

@ -8,7 +8,7 @@
<Mfm
:text="clip.description"
:is-note="false"
:i="$i"
:i="me"
/>
</div>
<div class="user">
@ -31,7 +31,7 @@
import { computed, provide, ref, watch } from "vue";
import type { entities } from "firefish-js";
import XNotes from "@/components/MkNotes.vue";
import { $i, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
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>(
() => isSignedIn && clip.value && $i.id === clip.value.userId,
() => isSignedIn && clip.value && me.id === clip.value.userId,
);
watch(

View file

@ -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 { isSignedIn } from "@/reactiveAccount";
import { isSignedIn } from "@/me";
import icon from "@/scripts/icon";
const props = defineProps<{

View file

@ -47,7 +47,7 @@
:text="req.followee.description"
:is-note="false"
:author="req.followee"
:i="$i"
:i="me"
:custom-emojis="req.followee.emojis"
:plain="true"
:nowrap="true"
@ -70,7 +70,7 @@ import { userPage } from "@/filters/user";
import * as os from "@/os";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import icon from "@/scripts/icon";
const paginationComponent = ref<InstanceType<typeof MkPagination>>();

View file

@ -14,7 +14,7 @@
</div>
</template>
<template #default="{ items }">
<MkInfo v-if="$i?.isLocked === false" warn class="info"
<MkInfo v-if="me?.isLocked === false" warn class="info"
>{{ i18n.ts.silencedWarning }}
</MkInfo>
<div class="mk-follow-requests">
@ -50,7 +50,7 @@
:text="req.follower.description"
:is-note="false"
:author="req.follower"
:i="$i"
:i="me"
:custom-emojis="req.follower.emojis"
:plain="true"
:nowrap="true"
@ -89,7 +89,7 @@ import { userPage } from "@/filters/user";
import * as os from "@/os";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import icon from "@/scripts/icon";
const paginationComponent = ref<InstanceType<typeof MkPagination>>();

View file

@ -59,7 +59,7 @@
<div class="other">
<button
v-if="
isSignedIn && $i.id === post.user.id
isSignedIn && me.id === post.user.id
"
v-tooltip="i18n.ts.toEdit"
v-click-anime
@ -105,7 +105,7 @@
<MkAcct :user="post.user" />
</div>
<MkFollowButton
v-if="!$i || $i.id != post.user.id"
v-if="!me || me.id != post.user.id"
:user="post.user"
:inline="true"
:transparent="false"
@ -163,7 +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";
import { isSignedIn } from "@/me";
const router = useRouter();

View file

@ -275,7 +275,7 @@ import MkKeyValue from "@/components/MkKeyValue.vue";
import FormSwitch from "@/components/form/switch.vue";
import * as os from "@/os";
import number from "@/filters/number";
import { isAdmin } from "@/reactiveAccount";
import { isAdmin } from "@/me";
import { definePageMetadata } from "@/scripts/page-metadata";
import { deviceKind } from "@/scripts/device-kind";
import { defaultStore } from "@/store";

View file

@ -104,7 +104,7 @@ import { useStream } from "@/stream";
import { useRouter } from "@/router";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { deviceKind } from "@/scripts/device-kind";
import { defaultStore } from "@/store";
import icon from "@/scripts/icon";
@ -203,7 +203,7 @@ function onRead(ids): void {
if (found.recipientId) {
found.isRead = true;
} else if (found.groupId) {
found.reads.push($i.id);
found.reads.push(me.id);
}
}
}

View file

@ -25,7 +25,7 @@
ref="text"
class="text"
:text="message.text"
:i="$i"
:i="me"
/>
</div>
<div v-else class="content">
@ -90,7 +90,7 @@ import XMediaList from "@/components/MkMediaList.vue";
import { extractUrlFromMfm } from "@/scripts/extract-url-from-mfm";
import MkUrlPreview from "@/components/MkUrlPreview.vue";
import * as os from "@/os";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { i18n } from "@/i18n";
import icon from "@/scripts/icon";
@ -99,7 +99,7 @@ const props = defineProps<{
isGroup?: boolean;
}>();
const isMe = computed(() => props.message.userId === $i?.id);
const isMe = computed(() => props.message.userId === me?.id);
const urls = computed(() =>
props.message.text ? extractUrlFromMfm(mfm.parse(props.message.text)) : [],
);

View file

@ -122,7 +122,7 @@ import { useStream } from "@/stream";
import * as sound from "@/scripts/sound";
import { vibrate } from "@/scripts/vibrate";
import { i18n } from "@/i18n";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { defaultStore } from "@/store";
import { definePageMetadata } from "@/scripts/page-metadata";
import icon from "@/scripts/icon";
@ -200,7 +200,7 @@ async function fetch() {
connection.value.on("read", onRead);
connection.value.on("deleted", onDeleted);
connection.value.on("typers", (_typers) => {
typers.value = _typers.filter((u) => u.id !== $i?.id);
typers.value = _typers.filter((u) => u.id !== me?.id);
});
document.addEventListener("visibilitychange", onVisibilitychange);
@ -258,7 +258,7 @@ function onMessage(message) {
const _isBottom = isBottomVisible(rootEl.value, 64);
pagingComponent.value.prepend(message);
if (message.userId !== $i?.id && !document.hidden) {
if (message.userId !== me?.id && !document.hidden) {
connection.value?.send("read", {
id: message.id,
});
@ -269,7 +269,7 @@ function onMessage(message) {
nextTick(() => {
thisScrollToBottom();
});
} else if (message.userId !== $i?.id) {
} else if (message.userId !== me?.id) {
// Notify
notifyNewMessage();
}
@ -341,7 +341,7 @@ function notifyNewMessage() {
function onVisibilitychange() {
if (document.hidden) return;
for (const message of pagingComponent.value.items) {
if (message.userId !== $i?.id && !message.isRead) {
if (message.userId !== me?.id && !message.isRead) {
connection.value?.send("read", {
id: message.id,
});

View file

@ -1,6 +1,6 @@
<template>
<MkSpacer :content-max="800">
<div v-if="$i">
<div v-if="me">
<div v-if="state == 'waiting'" class="waiting _section">
<div class="_content">
<MkLoading />
@ -83,7 +83,7 @@ import MkSignin from "@/components/MkSignin.vue";
import MkButton from "@/components/MkButton.vue";
import * as os from "@/os";
import { login } from "@/account";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { appendQuery, query } from "@/scripts/url";
import { i18n } from "@/i18n";
import icon from "@/scripts/icon";

View file

@ -179,7 +179,7 @@ import { selectFile } from "@/scripts/select-file";
import { mainRouter } from "@/router";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import icon from "@/scripts/icon";
const props = defineProps<{
@ -189,7 +189,7 @@ const props = defineProps<{
}>();
const tab = ref("settings");
const author = ref($i);
const author = ref(me);
const readonly = ref(false);
const page = ref(null);
const pageId = ref(null);

View file

@ -52,7 +52,7 @@
/></MkA>
<template
v-if="
isSignedIn && $i.id === page.userId
isSignedIn && me.id === page.userId
"
>
<MkA
@ -63,7 +63,7 @@
><i :class="icon('ph-pencil')"
/></MkA>
<button
v-if="$i.pinnedPageId === page.id"
v-if="me.pinnedPageId === page.id"
v-tooltip="i18n.ts.unpin"
class="menu _button"
@click="pin(false)"
@ -150,7 +150,7 @@
<MkAcct :user="page.user" />
</div>
<MkFollowButton
v-if="!$i || $i.id != page.user.id"
v-if="!me || me.id != page.user.id"
:user="page.user"
:inline="true"
:transparent="false"
@ -161,9 +161,9 @@
</div>
<!-- <div class="links">
<MkA :to="`/@${username}/pages/${pageName}/view-source`" class="link">{{ i18n.ts._pages.viewSource }}</MkA>
<template v-if="isSignedIn && $i.id === page.userId">
<template v-if="isSignedIn && me.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-if="me.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>
</template>
</div> -->
@ -215,7 +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";
import { isSignedIn } from "@/me";
const props = defineProps<{
pageName: string;

View file

@ -50,7 +50,7 @@ import MkContainer from "@/components/MkContainer.vue";
import MkButton from "@/components/MkButton.vue";
import { createAiScriptEnv } from "@/scripts/aiscript/api";
import * as os from "@/os";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
import icon from "@/scripts/icon";
@ -74,7 +74,7 @@ async function run() {
const aiscript = new Interpreter(
createAiScriptEnv({
storageKey: "scratchpad",
token: $i?.token,
token: me?.token,
}),
{
in: (q) => {

View file

@ -51,7 +51,7 @@ import { definePageMetadata } from "@/scripts/page-metadata";
import { defaultStore } from "@/store";
import { deviceKind } from "@/scripts/device-kind";
import icon from "@/scripts/icon";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import "swiper/scss";
import "swiper/scss/virtual";
import { api } from "@/os";
@ -96,7 +96,7 @@ const usersPagination = {
};
async function getUserId(user: string): Promise<string> {
if (user === "me") return $i!.id;
if (user === "me") return me!.id;
const split = (user.startsWith("@") ? user.slice(1) : user).split("@");
const username = split[0];

View file

@ -2,7 +2,7 @@
<FormSection :first="first">
<template #label>{{ i18n.ts["2fa"] }}</template>
<div v-if="$i" class="_gaps_s">
<div v-if="me" class="_gaps_s">
<MkFolder>
<template #icon
><i
@ -12,7 +12,7 @@
></template>
<template #label>{{ i18n.ts.totp }}</template>
<template #caption>{{ i18n.ts.totpDescription }}</template>
<div v-if="$i.twoFactorEnabled" class="_gaps_s">
<div v-if="me.twoFactorEnabled" class="_gaps_s">
<div v-text="i18n.ts._2fa.alreadyRegistered" />
<MkButton @click="unregisterTOTP"
><i
@ -24,7 +24,7 @@
</div>
<MkButton
v-else-if="!twoFactorData && !$i.twoFactorEnabled"
v-else-if="!twoFactorData && !me.twoFactorEnabled"
@click="registerTOTP"
>{{ i18n.ts._2fa.registerTOTP }}</MkButton
>
@ -55,7 +55,7 @@
>{{ i18n.ts._2fa.registerSecurityKey }}</MkButton
>
<MkFolder
v-for="key in $i.securityKeysList"
v-for="key in me.securityKeysList"
:key="key.id"
>
<h3>{{ key.name }}</h3>
@ -79,7 +79,7 @@
<MkSwitch
:disabled="
!$i.twoFactorEnabled || $i.securityKeysList.length === 0
!me.twoFactorEnabled || me.securityKeysList.length === 0
"
:model-value="usePasswordLessLogin"
@update:modelValue="(v) => updatePasswordLessLogin(v)"
@ -103,7 +103,7 @@ import MkSwitch from "@/components/form/switch.vue";
import FormSection from "@/components/form/section.vue";
import MkFolder from "@/components/MkFolder.vue";
import * as os from "@/os";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { i18n } from "@/i18n";
import icon from "@/scripts/icon";
@ -120,7 +120,7 @@ withDefaults(
const twoFactorData = ref<any>(null);
const supportsCredentials = ref(!!navigator.credentials);
const usePasswordLessLogin = computed(() => $i!.usePasswordLessLogin);
const usePasswordLessLogin = computed(() => me!.usePasswordLessLogin);
async function registerTOTP() {
const password = await os.inputText({
@ -252,9 +252,9 @@ async function addSecurityKey() {
name: "Firefish",
},
user: {
id: byteify($i!.id, "ascii"),
name: $i!.username,
displayName: $i!.name,
id: byteify(me!.id, "ascii"),
name: me!.username,
displayName: me!.name,
},
pubKeyCredParams: [{ alg: -7, type: "public-key" }],
timeout: 60000,

View file

@ -3,7 +3,7 @@
<MkKeyValue>
<template #key>ID</template>
<template #value
><span class="_monospace">{{ $i.id }}</span></template
><span class="_monospace">{{ me.id }}</span></template
>
</MkKeyValue>
@ -11,7 +11,7 @@
<MkKeyValue>
<template #key>{{ i18n.ts.registeredDate }}</template>
<template #value
><MkTime :time="$i.createdAt" mode="detail"
><MkTime :time="me.createdAt" mode="detail"
/></template>
</MkKeyValue>
</FormSection>
@ -135,25 +135,25 @@
<MkKeyValue oneline style="margin: 1em 0">
<template #key>emailVerified</template>
<template #value>{{
$i.emailVerified ? i18n.ts.yes : i18n.ts.no
me.emailVerified ? i18n.ts.yes : i18n.ts.no
}}</template>
</MkKeyValue>
<MkKeyValue oneline style="margin: 1em 0">
<template #key>twoFactorEnabled</template>
<template #value>{{
$i.twoFactorEnabled ? i18n.ts.yes : i18n.ts.no
me.twoFactorEnabled ? i18n.ts.yes : i18n.ts.no
}}</template>
</MkKeyValue>
<MkKeyValue oneline style="margin: 1em 0">
<template #key>securityKeys</template>
<template #value>{{
$i.securityKeys ? i18n.ts.yes : i18n.ts.no
me.securityKeys ? i18n.ts.yes : i18n.ts.no
}}</template>
</MkKeyValue>
<MkKeyValue oneline style="margin: 1em 0">
<template #key>usePasswordLessLogin</template>
<template #value>{{
$i.usePasswordLessLogin ? i18n.ts.yes : i18n.ts.no
me.usePasswordLessLogin ? i18n.ts.yes : i18n.ts.no
}}</template>
</MkKeyValue>
<MkKeyValue oneline style="margin: 1em 0">
@ -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, isAdmin, isModerator } from "@/reactiveAccount";
import { me, isAdmin, isModerator } from "@/me";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
import icon from "@/scripts/icon";
@ -188,7 +188,7 @@ const stats = ref<any>({});
onMounted(() => {
os.api("users/stats", {
userId: $i!.id,
userId: me!.id,
}).then((response) => {
stats.value = response;
});

View file

@ -39,7 +39,7 @@ import {
getAccounts,
login,
} from "@/account";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
import icon from "@/scripts/icon";
@ -50,7 +50,7 @@ const accounts = ref<any>(null);
const init = async () => {
getAccounts()
.then((accounts) => {
storedAccounts.value = accounts.filter((x) => x.id !== $i!.id);
storedAccounts.value = accounts.filter((x) => x.id !== me!.id);
console.log(storedAccounts.value);

View file

@ -7,7 +7,7 @@
i18n.ts._accountDelete.sendEmail
}}</FormInfo>
<FormButton
v-if="!$i.isDeleted"
v-if="!me.isDeleted"
danger
class="_formBlock"
@click="deleteAccount"

View file

@ -57,14 +57,14 @@ import bytes from "@/filters/bytes";
import { defaultStore } from "@/store";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
import { $i, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
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>(isSignedIn && $i.alwaysMarkNsfw);
const alwaysMarkNsfw = ref<boolean>(isSignedIn && me.alwaysMarkNsfw);
const meterStyle = computed(() => {
return {

View file

@ -6,11 +6,11 @@
<template #prefix
><i :class="icon('ph-envelope-simple-open')"></i
></template>
<template v-if="$i.email && !$i.emailVerified" #caption>{{
<template v-if="me.email && !me.emailVerified" #caption>{{
i18n.ts.verificationEmailSent
}}</template>
<template
v-else-if="emailAddress === $i.email && $i.emailVerified"
v-else-if="emailAddress === me.email && me.emailVerified"
#caption
><i
:class="icon('ph-check')"
@ -23,7 +23,7 @@
<FormSection>
<FormSwitch
:model-value="$i.receiveAnnouncementEmail"
:model-value="me.receiveAnnouncementEmail"
@update:modelValue="onChangeReceiveAnnouncementEmail"
>
{{ i18n.ts.receiveAnnouncementFromInstance }}
@ -66,12 +66,12 @@ import FormSection from "@/components/form/section.vue";
import FormInput from "@/components/form/input.vue";
import FormSwitch from "@/components/form/switch.vue";
import * as os from "@/os";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
import icon from "@/scripts/icon";
const emailAddress = ref($i!.email);
const emailAddress = ref(me!.email);
const onChangeReceiveAnnouncementEmail = (v) => {
os.api("i/update", {
@ -93,22 +93,22 @@ const saveEmailAddress = () => {
};
const emailNotification_mention = ref(
$i!.emailNotificationTypes.includes("mention"),
me!.emailNotificationTypes.includes("mention"),
);
const emailNotification_reply = ref(
$i!.emailNotificationTypes.includes("reply"),
me!.emailNotificationTypes.includes("reply"),
);
const emailNotification_quote = ref(
$i!.emailNotificationTypes.includes("quote"),
me!.emailNotificationTypes.includes("quote"),
);
const emailNotification_follow = ref(
$i!.emailNotificationTypes.includes("follow"),
me!.emailNotificationTypes.includes("follow"),
);
const emailNotification_receiveFollowRequest = ref(
$i!.emailNotificationTypes.includes("receiveFollowRequest"),
me!.emailNotificationTypes.includes("receiveFollowRequest"),
);
const emailNotification_groupInvited = ref(
$i!.emailNotificationTypes.includes("groupInvited"),
me!.emailNotificationTypes.includes("groupInvited"),
);
const saveNotificationSettings = () => {

View file

@ -103,7 +103,7 @@
i18n.ts.enableTimelineStreaming
}}</FormSwitch>
<!-- <FormSwitch
v-model="$i.injectFeaturedNote"
v-model="me.injectFeaturedNote"
class="_formBlock"
@update:modelValue="onChangeInjectFeaturedNote"
>
@ -297,7 +297,7 @@
}}</template></FormSwitch
>
<FormSwitch
v-if="$i?.isAdmin"
v-if="me?.isAdmin"
v-model="showAdminUpdates"
class="_formBlock"
>{{ i18n.ts.showAdminUpdates }}</FormSwitch
@ -376,7 +376,7 @@
<script lang="ts" setup>
import { computed, ref, watch } from "vue";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import FormSwitch from "@/components/form/switch.vue";
import FormSelect from "@/components/form/select.vue";
import FormRadios from "@/components/form/radios.vue";
@ -536,7 +536,7 @@ const showNoAltTextWarning = computed(
// os.api("i/update", {
// injectFeaturedNote: v,
// }).then((i) => {
// $i!.injectFeaturedNote = i.injectFeaturedNote;
// me!.injectFeaturedNote = i.injectFeaturedNote;
// });
// }

View file

@ -46,7 +46,7 @@ import { i18n } from "@/i18n";
import MkInfo from "@/components/MkInfo.vue";
import MkSuperMenu from "@/components/MkSuperMenu.vue";
import { signout } from "@/account";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { unisonReload } from "@/scripts/unison-reload";
import { instance } from "@/instance";
import { useRouter } from "@/router";
@ -291,7 +291,7 @@ watch(router.currentRef, (to) => {
});
const emailNotConfigured = computed(
() => instance.enableEmail && ($i.email == null || !$i.emailVerified),
() => instance.enableEmail && (me.email == null || !me.emailVerified),
);
provideMetadataReceiver((info) => {

View file

@ -26,12 +26,12 @@ import FormTextarea from "@/components/form/textarea.vue";
import MkInfo from "@/components/MkInfo.vue";
import MkButton from "@/components/MkButton.vue";
import * as os from "@/os";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
import icon from "@/scripts/icon";
const instanceMutes = ref($i!.mutedInstances.join("\n"));
const instanceMutes = ref(me!.mutedInstances.join("\n"));
const changed = ref(false);
async function save() {

View file

@ -60,7 +60,7 @@ import FormInfo from "@/components/MkInfo.vue";
import * as os from "@/os";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import icon from "@/scripts/icon";
const moveToAccount = ref("");
@ -69,8 +69,8 @@ const accountAlias = ref([""]);
await init();
async function init() {
if ($i?.alsoKnownAs && $i.alsoKnownAs.length > 0) {
const aka = await os.api("users/show", { userIds: $i.alsoKnownAs });
if (me?.alsoKnownAs && me.alsoKnownAs.length > 0) {
const aka = await os.api("users/show", { userIds: me.alsoKnownAs });
accountAlias.value =
aka && aka.length > 0
? aka.map((user) => `@${acct.toString(user)}`)
@ -86,7 +86,7 @@ async function save(): Promise<void> {
.map((e) => e.trim())
.filter((e) => e !== ""),
});
$i.alsoKnownAs = i.alsoKnownAs;
me.alsoKnownAs = i.alsoKnownAs;
await init();
}

View file

@ -54,7 +54,7 @@ import { notificationTypes } from "firefish-js";
import FormButton from "@/components/MkButton.vue";
import FormSection from "@/components/form/section.vue";
import * as os from "@/os";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
import MkPushNotificationAllowButton from "@/components/MkPushNotificationAllowButton.vue";
@ -83,7 +83,7 @@ async function readAllNotifications() {
function configure() {
const includingTypes = notificationTypes.filter(
(x) => !$i!.mutingNotificationTypes.includes(x),
(x) => !me!.mutingNotificationTypes.includes(x),
);
os.popup(
defineAsyncComponent(
@ -103,7 +103,7 @@ function configure() {
),
})
.then((i) => {
$i!.mutingNotificationTypes = i.mutingNotificationTypes;
me!.mutingNotificationTypes = i.mutingNotificationTypes;
});
},
},

View file

@ -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 { isSignedIn } from "@/reactiveAccount";
import { isSignedIn } from "@/me";
import { i18n } from "@/i18n";
import { host, version } from "@/config";
import { definePageMetadata } from "@/scripts/page-metadata";

View file

@ -165,19 +165,19 @@ import FormFolder from "@/components/form/folder.vue";
import * as os from "@/os";
import { defaultStore } from "@/store";
import { i18n } from "@/i18n";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { definePageMetadata } from "@/scripts/page-metadata";
import icon from "@/scripts/icon";
const isLocked = ref($i.isLocked);
const autoAcceptFollowed = ref($i.autoAcceptFollowed);
const noCrawle = ref($i.noCrawle);
const isIndexable = ref($i.isIndexable);
const isExplorable = ref($i.isExplorable);
const hideOnlineStatus = ref($i.hideOnlineStatus);
const publicReactions = ref($i.publicReactions);
const ffVisibility = ref($i.ffVisibility);
const preventAiLearning = ref($i.preventAiLearning);
const isLocked = ref(me.isLocked);
const autoAcceptFollowed = ref(me.autoAcceptFollowed);
const noCrawle = ref(me.noCrawle);
const isIndexable = ref(me.isIndexable);
const isExplorable = ref(me.isExplorable);
const hideOnlineStatus = ref(me.hideOnlineStatus);
const publicReactions = ref(me.publicReactions);
const ffVisibility = ref(me.ffVisibility);
const preventAiLearning = ref(me.preventAiLearning);
const defaultNoteVisibility = computed(
defaultStore.makeGetterSetter("defaultNoteVisibility"),

View file

@ -7,13 +7,13 @@
<div
class="llvierxe"
:style="{
backgroundImage: $i.bannerUrl ? `url(${$i.bannerUrl})` : null,
backgroundImage: me.bannerUrl ? `url(${me.bannerUrl})` : null,
}"
>
<div class="avatar">
<MkAvatar
class="avatar"
:user="$i"
:user="me"
:disable-link="true"
@click="changeAvatar"
/>
@ -118,7 +118,7 @@
i18n.t("_profile.metadataDescription", {
a: "\<a\>",
l: "\<a\>",
rel: `rel="me" href="https://${host}/@${$i.username}"`,
rel: `rel="me" href="https://${host}/@${me.username}"`,
})
}}</template>
</FormSlot>
@ -162,19 +162,19 @@ import FormSlot from "@/components/form/slot.vue";
import { selectFile } from "@/scripts/select-file";
import * as os from "@/os";
import { i18n } from "@/i18n";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { definePageMetadata } from "@/scripts/page-metadata";
import { host } from "@/config";
import icon from "@/scripts/icon";
const profile = reactive({
name: $i?.name,
description: $i?.description,
location: $i?.location,
birthday: $i?.birthday,
isBot: $i?.isBot,
isCat: $i?.isCat,
speakAsCat: $i?.speakAsCat,
name: me?.name,
description: me?.description,
location: me?.location,
birthday: me?.birthday,
isBot: me?.isBot,
isCat: me?.isCat,
speakAsCat: me?.speakAsCat,
});
const props = withDefaults(
@ -197,7 +197,7 @@ watch(
);
const fields = reactive(
$i.fields.map((field) => ({ name: field.name, value: field.value })),
me.fields.map((field) => ({ name: field.name, value: field.value })),
);
function addField() {
@ -253,8 +253,8 @@ function changeAvatar(ev) {
const i = await os.apiWithDialog("i/update", {
avatarId: originalOrCropped.id,
});
$i.avatarId = i.avatarId;
$i.avatarUrl = i.avatarUrl;
me.avatarId = i.avatarId;
me.avatarUrl = i.avatarUrl;
},
);
}
@ -278,8 +278,8 @@ function changeBanner(ev) {
const i = await os.apiWithDialog("i/update", {
bannerId: originalOrCropped.id,
});
$i.bannerId = i.bannerId;
$i.bannerUrl = i.bannerUrl;
me.bannerId = i.bannerId;
me.bannerUrl = i.bannerUrl;
},
);
}

View file

@ -74,7 +74,7 @@ import MkTab from "@/components/MkTab.vue";
import * as os from "@/os";
import number from "@/filters/number";
import { defaultStore } from "@/store";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";
import icon from "@/scripts/icon";
@ -93,8 +93,8 @@ const render = (mutedWords) =>
const tab = ref("soft");
const softMutedWords = ref(render(defaultStore.state.mutedWords));
const softMutedLangs = ref(render(defaultStore.state.mutedLangs));
const hardMutedWords = ref(render($i!.mutedWords));
const hardMutedPatterns = ref($i!.mutedPatterns.join("\n"));
const hardMutedWords = ref(render(me!.mutedWords));
const hardMutedPatterns = ref(me!.mutedPatterns.join("\n"));
const hardWordMutedNotesCount = ref(null);
const changed = ref(false);

View file

@ -151,7 +151,7 @@ import FormButton from "@/components/MkButton.vue";
import FormTextarea from "@/components/form/textarea.vue";
import FormFolder from "@/components/form/folder.vue";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import type { Theme } from "@/scripts/theme";
import { applyTheme } from "@/scripts/theme";
import lightTheme from "@/themes/_light.json5";
@ -315,7 +315,7 @@ async function saveAs() {
theme.value.id = uuid();
theme.value.name = name;
theme.value.author = `@${$i.username}@${toUnicode(host)}`;
theme.value.author = `@${me.username}@${toUnicode(host)}`;
if (description.value) theme.value.desc = description.value;
await addTheme(theme.value);
applyTheme(theme.value);

View file

@ -75,7 +75,7 @@ import * as os from "@/os";
import { defaultStore } from "@/store";
import { i18n } from "@/i18n";
import { instance } from "@/instance";
import { isModerator, isSignedIn } from "@/reactiveAccount";
import { isModerator, isSignedIn } from "@/me";
import { definePageMetadata } from "@/scripts/page-metadata";
import { deviceKind } from "@/scripts/device-kind";
import icon from "@/scripts/icon";

View file

@ -362,7 +362,7 @@ import { url } from "@/config";
import { userPage } from "@/filters/user";
import { definePageMetadata } from "@/scripts/page-metadata";
import { i18n } from "@/i18n";
import { isAdmin, isModerator } from "@/reactiveAccount";
import { isAdmin, isModerator } from "@/me";
import { instance } from "@/instance";
import icon from "@/scripts/icon";

View file

@ -68,7 +68,7 @@
<span
v-if="
isSignedIn &&
$i.id !== user.id &&
me.id !== user.id &&
user.isFollowed
"
class="followed"
@ -133,7 +133,7 @@
<span
v-if="
isSignedIn &&
$i.id !== user.id &&
me.id !== user.id &&
user.isFollowed
"
class="followed"
@ -221,7 +221,7 @@
:text="user.description"
:is-note="false"
:author="user"
:i="$i"
:i="me"
:custom-emojis="user.emojis"
/>
<p v-else class="empty">
@ -294,7 +294,7 @@
<Mfm
:text="field.value"
:author="user"
:i="$i"
:i="me"
:custom-emojis="user.emojis"
:colored="false"
/>
@ -341,7 +341,7 @@
/>
</div>
<MkInfo
v-else-if="isSignedIn && $i.id === user.id"
v-else-if="isSignedIn && me.id === user.id"
style="margin: 12px 0"
>{{ i18n.ts.userPagePinTip }}</MkInfo
>
@ -384,7 +384,7 @@ import { userPage } from "@/filters/user";
import { defaultStore } from "@/store";
import * as os from "@/os";
import { i18n } from "@/i18n";
import { $i, isModerator, isSignedIn } from "@/reactiveAccount";
import { me, isModerator, isSignedIn } from "@/me";
import { host } from "@/config";
import icon from "@/scripts/icon";

View file

@ -35,7 +35,7 @@ import * as os from "@/os";
import { useRouter } from "@/router";
import { definePageMetadata } from "@/scripts/page-metadata";
import { i18n } from "@/i18n";
import { $i, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
import icon from "@/scripts/icon";
const XHome = defineAsyncComponent(() => import("./home.vue"));
@ -86,7 +86,7 @@ const headerTabs = computed(() =>
title: i18n.ts.overview,
icon: `${icon("ph-user")}`,
},
...((isSignedIn && $i.id === user.value.id) ||
...((isSignedIn && me.id === user.value.id) ||
user.value.publicReactions
? [
{

View file

@ -14,7 +14,7 @@
v-if="note.text"
:text="note.text"
:author="note.user"
:i="$i"
:i="me"
:custom-emojis="note.emojis"
/>
<!-- <MkA v-if="note.renoteId" class="rp" :to="`/notes/${note.renoteId}`">RN: ...</MkA> -->

View file

@ -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, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
type StateDef = Record<
string,
@ -45,12 +45,12 @@ export class Storage<T extends StateDef> {
);
const deviceAccountState = isSignedIn
? JSON.parse(
localStorage.getItem(`${this.keyForLocalStorage}::${$i.id}`) || "{}",
localStorage.getItem(`${this.keyForLocalStorage}::${me.id}`) || "{}",
)
: {};
const registryCache = isSignedIn
? JSON.parse(
localStorage.getItem(`${this.keyForLocalStorage}::cache::${$i.id}`) ||
localStorage.getItem(`${this.keyForLocalStorage}::cache::${me.id}`) ||
"{}",
)
: {};
@ -104,7 +104,7 @@ export class Storage<T extends StateDef> {
}
}
localStorage.setItem(
`${this.keyForLocalStorage}::cache::${$i.id}`,
`${this.keyForLocalStorage}::cache::${me.id}`,
JSON.stringify(cache),
);
},
@ -135,13 +135,13 @@ export class Storage<T extends StateDef> {
const cache = JSON.parse(
localStorage.getItem(
`${this.keyForLocalStorage}::cache::${$i.id}`,
`${this.keyForLocalStorage}::cache::${me.id}`,
) || "{}",
);
if (cache[key] !== value) {
cache[key] = value;
localStorage.setItem(
`${this.keyForLocalStorage}::cache::${$i.id}`,
`${this.keyForLocalStorage}::cache::${me.id}`,
JSON.stringify(cache),
);
}
@ -171,11 +171,11 @@ export class Storage<T extends StateDef> {
case "deviceAccount": {
if (!isSignedIn) break;
const deviceAccountState = JSON.parse(
localStorage.getItem(`${this.keyForLocalStorage}::${$i.id}`) || "{}",
localStorage.getItem(`${this.keyForLocalStorage}::${me.id}`) || "{}",
);
deviceAccountState[key] = value;
localStorage.setItem(
`${this.keyForLocalStorage}::${$i.id}`,
`${this.keyForLocalStorage}::${me.id}`,
JSON.stringify(deviceAccountState),
);
break;
@ -183,12 +183,12 @@ export class Storage<T extends StateDef> {
case "account": {
if (!isSignedIn) break;
const cache = JSON.parse(
localStorage.getItem(`${this.keyForLocalStorage}::cache::${$i.id}`) ||
localStorage.getItem(`${this.keyForLocalStorage}::cache::${me.id}`) ||
"{}",
);
cache[key] = value;
localStorage.setItem(
`${this.keyForLocalStorage}::cache::${$i.id}`,
`${this.keyForLocalStorage}::cache::${me.id}`,
JSON.stringify(cache),
);
api("i/registry/set", {

View file

@ -3,7 +3,7 @@ import { defineAsyncComponent, inject } from "vue";
import { Router } from "@/nirax";
import MkError from "@/pages/_error_.vue";
import MkLoading from "@/pages/_loading_.vue";
import { $i, isEmojiMod, isModerator } from "@/reactiveAccount";
import { me, isEmojiMod, isModerator } from "@/me";
const page = (loader: AsyncComponentLoader<any>) =>
defineAsyncComponent({
@ -657,7 +657,7 @@ export const routes = [
{
name: "index",
path: "/",
component: $i
component: me
? page(() => import("./pages/timeline.vue"))
: page(() => import("./pages/welcome.vue")),
globalCacheKey: "index",

View file

@ -1,13 +1,13 @@
import { utils, values } from "@syuilo/aiscript";
import * as os from "@/os";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
export function createAiScriptEnv(opts) {
let apiRequests = 0;
return {
USER_ID: $i ? values.STR($i.id) : values.NULL,
USER_NAME: $i ? values.STR($i.name) : values.NULL,
USER_USERNAME: $i ? values.STR($i.username) : values.NULL,
USER_ID: me ? values.STR(me.id) : values.NULL,
USER_NAME: me ? values.STR(me.name) : values.NULL,
USER_USERNAME: me ? values.STR(me.username) : values.NULL,
"Mk:dialog": values.FN_NATIVE(async ([title, text, type]) => {
await os.alert({
type: type ? type.value : "info",

View file

@ -1,7 +1,7 @@
import type { Ref } from "vue";
import { defineAsyncComponent } from "vue";
import type { entities } from "firefish-js";
import { $i, isModerator, isSignedIn } from "@/reactiveAccount";
import { me, isModerator, isSignedIn } from "@/me";
import { i18n } from "@/i18n";
import { instance } from "@/instance";
import * as os from "@/os";
@ -288,10 +288,10 @@ export function getNoteMenu(props: {
noteId: appearNote.id,
});
const isAppearAuthor = appearNote.userId === $i.id;
const isAppearAuthor = appearNote.userId === me.id;
menu = [
...(props.currentClipPage?.value.userId === $i.id
...(props.currentClipPage?.value.userId === me.id
? [
{
icon: `${icon("ph-minus-circle")}`,
@ -349,7 +349,7 @@ export function getNoteMenu(props: {
},
),
isAppearAuthor
? ($i.pinnedNoteIds || []).includes(appearNote.id)
? (me.pinnedNoteIds || []).includes(appearNote.id)
? {
icon: `${icon("ph-push-pin")}`,
text: i18n.ts.unpin,

View file

@ -5,7 +5,7 @@ import copyToClipboard from "@/scripts/copy-to-clipboard";
import { host } from "@/config";
import * as os from "@/os";
import { userActions } from "@/store";
import { $i, isModerator, isSignedIn } from "@/reactiveAccount";
import { me, isModerator, isSignedIn } from "@/me";
import { mainRouter } from "@/router";
import type { Router } from "@/nirax";
import icon from "@/scripts/icon";
@ -290,7 +290,7 @@ export function getUserMenu(user, router: Router = mainRouter) {
os.post({ specified: user });
},
},
$i.id !== user.id
me.id !== user.id
? {
type: "link",
icon: `${icon("ph-chats-teardrop")}`,
@ -313,7 +313,7 @@ export function getUserMenu(user, router: Router = mainRouter) {
text: i18n.ts.addToList,
action: pushList,
},
$i.id !== user.id
me.id !== user.id
? {
icon: `${icon("ph-users-three")}`,
text: i18n.ts.inviteToGroup,
@ -335,7 +335,7 @@ export function getUserMenu(user, router: Router = mainRouter) {
},
] as any;
if (isSignedIn && $i.id !== user.id) {
if (isSignedIn && me.id !== user.id) {
menu = menu.concat([
{
icon: user.isMuted ? "ph-eye ph-lg" : "ph-eye-slash ph-lg",
@ -386,7 +386,7 @@ export function getUserMenu(user, router: Router = mainRouter) {
}
}
if (isSignedIn && $i.id === user.id) {
if (isSignedIn && me.id === user.id) {
menu = menu.concat([
null,
{

View file

@ -1,5 +1,5 @@
import { defineAsyncComponent } from "vue";
import { isSignedIn } from "@/reactiveAccount";
import { isSignedIn } from "@/me";
import { i18n } from "@/i18n";
import { popup } from "@/os";
import { vibrate } from "@/scripts/vibrate";

View file

@ -3,7 +3,7 @@ import type { entities } from "firefish-js";
import { readAndCompressImage } from "browser-image-resizer";
import { defaultStore } from "@/store";
import { apiUrl } from "@/config";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { alert } from "@/os";
import { i18n } from "@/i18n";
@ -84,7 +84,7 @@ export function uploadFile(
const xhr = new XMLHttpRequest();
xhr.open("POST", `${apiUrl}/drive/files/create`, true);
xhr.setRequestHeader("Authorization", `Bearer ${$i.token}`);
xhr.setRequestHeader("Authorization", `Bearer ${me.token}`);
xhr.onload = (ev) => {
if (
xhr.status !== 200 ||

View file

@ -2,7 +2,7 @@ import type { Ref } from "vue";
import { onUnmounted } from "vue";
import type { entities } from "firefish-js";
import { useStream } from "@/stream";
import { $i, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
import * as os from "@/os";
export function useNoteCapture(props: {
@ -34,7 +34,7 @@ export function useNoteCapture(props: {
note.value.reactions[reaction] = currentCount + 1;
if (isSignedIn && body.userId === $i.id) {
if (isSignedIn && body.userId === me.id) {
note.value.myReaction = reaction;
}
break;
@ -48,7 +48,7 @@ export function useNoteCapture(props: {
note.value.reactions[reaction] = Math.max(0, currentCount - 1);
if (isSignedIn && body.userId === $i.id) {
if (isSignedIn && body.userId === me.id) {
note.value.myReaction = undefined;
}
break;
@ -62,7 +62,7 @@ export function useNoteCapture(props: {
choices[choice] = {
...choices[choice],
votes: choices[choice].votes + 1,
...(isSignedIn && body.userId === $i.id
...(isSignedIn && body.userId === me.id
? {
isVoted: true,
}

View file

@ -1,6 +1,6 @@
import { markRaw, ref } from "vue";
import { Storage } from "./pizzax";
import { isSignedIn } from "./reactiveAccount";
import { isSignedIn } from "./me";
export const postFormActions = [];
export const userActions = [];

View file

@ -1,7 +1,7 @@
import { Stream } from "firefish-js";
import { markRaw } from "vue";
import { url } from "@/config";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
let stream: Stream | null = null;
let timeoutHeartBeat: number | null = null;
@ -13,9 +13,9 @@ export function useStream() {
stream = markRaw(
new Stream(
url,
$i
me
? {
token: $i.token,
token: me.token,
}
: null,
),

View file

@ -1,8 +1,8 @@
import type { Theme } from "./scripts/theme";
import { api } from "@/os";
import { $i, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
const lsCacheKey = isSignedIn ? `themes:${$i.id}` : "";
const lsCacheKey = isSignedIn ? `themes:${me.id}` : "";
export function getThemes(): Theme[] {
return JSON.parse(localStorage.getItem(lsCacheKey) || "[]");

View file

@ -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, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
import { useStream } from "@/stream";
const stream = useStream();
@ -35,7 +35,7 @@ const XUpload = defineAsyncComponent(() => import("./upload.vue"));
const dev = _DEV_;
const onNotification = (notification) => {
if ($i.mutingNotificationTypes.includes(notification.type)) return;
if (me.mutingNotificationTypes.includes(notification.type)) return;
if (document.visibilityState === "visible") {
stream.send("readNotification", {

View file

@ -4,22 +4,22 @@
<div class="top">
<div
class="banner"
:user="$i"
:style="{ backgroundImage: `url(${$i.bannerUrl})` }"
:user="me"
:style="{ backgroundImage: `url(${me.bannerUrl})` }"
></div>
<button
v-click-anime
v-tooltip.noDelay.right="
`${i18n.ts.account}: @${$i.username}`
`${i18n.ts.account}: @${me.username}`
"
class="item _button account"
@click="openAccountMenu"
>
<MkAvatar
:user="$i"
:user="me"
class="icon"
disable-link
/><!-- <MkAcct class="text" :user="$i"/> -->
/><!-- <MkAcct class="text" :user="me"/> -->
</button>
</div>
<div class="middle">
@ -81,7 +81,7 @@
><span class="text">{{ i18n.ts.controlPanel }}</span>
</MkA>
<MkA
v-else-if="$i.emojiModPerm !== 'unauthorized'"
v-else-if="me.emojiModPerm !== 'unauthorized'"
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, isModerator } from "@/reactiveAccount";
import { me, isModerator } from "@/me";
import { openHelpMenu_ } from "@/scripts/helpMenu";
import { defaultStore } from "@/store";
import { i18n } from "@/i18n";

View file

@ -4,22 +4,22 @@
<div class="top">
<div
class="banner"
:user="$i"
:style="{ backgroundImage: `url(${$i.bannerUrl})` }"
:user="me"
:style="{ backgroundImage: `url(${me.bannerUrl})` }"
></div>
<button
v-click-anime
v-tooltip.noDelay.right="
`${i18n.ts.account}: @${$i.username}`
`${i18n.ts.account}: @${me.username}`
"
class="item _button account"
@click="openAccountMenu"
>
<MkAvatar
:user="$i"
:user="me"
class="icon"
disable-link
/><!-- <MkAcct class="text" :user="$i"/> -->
/><!-- <MkAcct class="text" :user="me"/> -->
</button>
</div>
<nav class="middle">
@ -93,7 +93,7 @@
><span class="text">{{ i18n.ts.controlPanel }}</span>
</MkA>
<MkA
v-else-if="$i.emojiModPerm !== 'unauthorized'"
v-else-if="me.emojiModPerm !== 'unauthorized'"
v-click-anime
v-tooltip.noDelay.right="i18n.ts.customEmojis"
class="item _button"
@ -155,7 +155,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, isAdmin, isModerator } from "@/reactiveAccount";
import { me, isAdmin, isModerator } from "@/me";
import { openHelpMenu_ } from "@/scripts/helpMenu";
import { defaultStore } from "@/store";
import { i18n } from "@/i18n";

View file

@ -1,6 +1,6 @@
import { post } from "@/os";
import { login } from "@/account";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { getAccountFromId } from "@/scripts/get-account-from-id";
import { mainRouter } from "@/router";
@ -12,7 +12,7 @@ export function swInject() {
if (ev.data.type !== "order") return;
if (ev.data.loginId !== $i?.id) {
if (ev.data.loginId !== me?.id) {
return getAccountFromId(ev.data.loginId).then((account) => {
if (!account) return;
return login(account.token, ev.data.url);

View file

@ -151,7 +151,7 @@
>
<i :class="icon('ph-bell')"></i
><span
v-if="$i?.hasUnreadNotification"
v-if="me?.hasUnreadNotification"
class="indicator"
:class="{
animateIndicator: defaultStore.state.animation,
@ -203,7 +203,7 @@ import XDrawerMenu from "@/ui/_common_/navbar-for-mobile.vue";
import MkButton from "@/components/MkButton.vue";
import * as os from "@/os";
import { navbarItemDef } from "@/navbar";
import { $i, isSignedIn } from "@/reactiveAccount";
import { me, isSignedIn } from "@/me";
import { i18n } from "@/i18n";
import { mainRouter } from "@/router";
import { unisonReload } from "@/scripts/unison-reload";

View file

@ -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 { isModerator, isSignedIn } from "@/reactiveAccount";
import { isModerator, isSignedIn } from "@/me";
import { instance } from "@/instance";
import { i18n } from "@/i18n";
import icon from "@/scripts/icon";

View file

@ -85,7 +85,7 @@
>
<i :class="icon('ph-bell')"></i
><span
v-if="$i?.hasUnreadNotification"
v-if="me?.hasUnreadNotification"
class="indicator"
:class="{
animateIndicator: defaultStore.state.animation,
@ -120,7 +120,7 @@
>
<i :class="icon('ph-chats-teardrop')"></i
><span
v-if="$i?.hasUnreadMessagingMessage"
v-if="me?.hasUnreadMessagingMessage"
class="indicator"
:class="{
animateIndicator: defaultStore.state.animation,
@ -222,7 +222,7 @@ import { defaultStore } from "@/store";
import { navbarItemDef } from "@/navbar";
import { i18n } from "@/i18n";
import { openAccountMenu as openAccountMenuImpl } from "@/account";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { mainRouter } from "@/router";
import { provideMetadataReceiver } from "@/scripts/page-metadata";
import { deviceKind } from "@/scripts/device-kind";

View file

@ -38,7 +38,7 @@ import type { GetFormResultType } from "@/scripts/form";
import * as os from "@/os";
import MkContainer from "@/components/MkContainer.vue";
import { createAiScriptEnv } from "@/scripts/aiscript/api";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import { i18n } from "@/i18n";
import icon from "@/scripts/icon";
@ -84,7 +84,7 @@ const run = async () => {
const aiscript = new Interpreter(
createAiScriptEnv({
storageKey: "widget",
token: $i?.token,
token: me?.token,
}),
{
in: (q) => {

View file

@ -18,7 +18,7 @@ import type {
import { createAiScriptEnv } from "@/scripts/aiscript/api";
import type { GetFormResultType } from "@/scripts/form";
import * as os from "@/os";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
import MkButton from "@/components/MkButton.vue";
const name = "button";
@ -57,7 +57,7 @@ const run = async () => {
const aiscript = new Interpreter(
createAiScriptEnv({
storageKey: "widget",
token: $i?.token,
token: me?.token,
}),
{
in: (q) => {

View file

@ -50,7 +50,7 @@ import { useWidgetPropsManager } from "./widget";
import type { GetFormResultType } from "@/scripts/form";
import { i18n } from "@/i18n";
import { useInterval } from "@/scripts/use-interval";
import { $i } from "@/reactiveAccount";
import { me } from "@/me";
const name = "calendar";
@ -76,7 +76,7 @@ const { widgetProps, configure } = useWidgetPropsManager(
emit,
);
const hasBirthday = Boolean($i?.birthday);
const hasBirthday = Boolean(me?.birthday);
const year = ref(0);
const month = ref(0);
@ -123,7 +123,7 @@ const tick = () => {
isHoliday.value = now.getDay() === 0 || now.getDay() === 6;
if (hasBirthday) {
const [bdayYear, bdayMonth, bdayDay] = $i.birthday.split("-");
const [bdayYear, bdayMonth, bdayDay] = me.birthday.split("-");
if (month.value === +bdayMonth && day.value == +bdayDay) {
isBirthday.value = true;
}