wip
This commit is contained in:
parent
ec73511759
commit
b982ba56bc
|
@ -33,26 +33,28 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<script lang="ts" setup>
|
||||
import { computed, watch, provide, ref } from 'vue';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import { url } from '@@/js/config.js';
|
||||
import type { MenuItem } from '@/types/menu.js';
|
||||
import MkNotes from '@/components/MkNotes.vue';
|
||||
import { $i } from '@/account.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import * as os from '@/os.js';
|
||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
||||
import { url } from '@@/js/config.js';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import { clipsCache } from '@/cache.js';
|
||||
import { isSupportShare } from '@/scripts/navigator.js';
|
||||
import { copyToClipboard } from '@/scripts/copy-to-clipboard.js';
|
||||
import { genEmbedCode } from '@/scripts/get-embed-code.js';
|
||||
import type { MenuItem } from '@/types/menu.js';
|
||||
import { getServerContext } from '@/server-context.js';
|
||||
|
||||
const CTX_CLIP = getServerContext('clip');
|
||||
|
||||
const props = defineProps<{
|
||||
clipId: string,
|
||||
}>();
|
||||
|
||||
const clip = ref<Misskey.entities.Clip | null>(getServerContext('clip'));
|
||||
const clip = ref<Misskey.entities.Clip | null>(CTX_CLIP);
|
||||
const favorited = ref(false);
|
||||
const pagination = {
|
||||
endpoint: 'clips/notes' as const,
|
||||
|
@ -65,8 +67,8 @@ const pagination = {
|
|||
const isOwned = computed<boolean | null>(() => $i && clip.value && ($i.id === clip.value.userId));
|
||||
|
||||
watch(() => props.clipId, async () => {
|
||||
if (getServerContext('clip') && getServerContext('clip').id === props.clipId) {
|
||||
clip.value = getServerContext('clip');
|
||||
if (CTX_CLIP && CTX_CLIP.id === props.clipId) {
|
||||
clip.value = CTX_CLIP;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,12 +64,14 @@ import { defaultStore } from '@/store.js';
|
|||
import { pleaseLogin } from '@/scripts/please-login.js';
|
||||
import { getServerContext } from '@/server-context.js';
|
||||
|
||||
const CTX_NOTE = getServerContext('note');
|
||||
|
||||
const props = defineProps<{
|
||||
noteId: string;
|
||||
initialTab?: string;
|
||||
}>();
|
||||
|
||||
const note = ref<null | Misskey.entities.Note>(getServerContext('note'));
|
||||
const note = ref<null | Misskey.entities.Note>(CTX_NOTE);
|
||||
const clips = ref<Misskey.entities.Clip[]>();
|
||||
const showPrev = ref<'user' | 'channel' | false>(false);
|
||||
const showNext = ref<'user' | 'channel' | false>(false);
|
||||
|
@ -118,8 +120,8 @@ function fetchNote() {
|
|||
showNext.value = false;
|
||||
note.value = null;
|
||||
|
||||
if (getServerContext('note') && getServerContext('note').id === props.noteId) {
|
||||
note.value = getServerContext('note');
|
||||
if (CTX_NOTE && CTX_NOTE.id === props.noteId) {
|
||||
note.value = CTX_NOTE;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|||
import { i18n } from '@/i18n.js';
|
||||
import { $i } from '@/account.js';
|
||||
import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue';
|
||||
import { getServerContext } from '@/server-context.js';
|
||||
|
||||
const XHome = defineAsyncComponent(() => import('./home.vue'));
|
||||
const XTimeline = defineAsyncComponent(() => import('./index.timeline.vue'));
|
||||
|
@ -52,6 +53,8 @@ const XFlashs = defineAsyncComponent(() => import('./flashs.vue'));
|
|||
const XGallery = defineAsyncComponent(() => import('./gallery.vue'));
|
||||
const XRaw = defineAsyncComponent(() => import('./raw.vue'));
|
||||
|
||||
const CTX_USER = getServerContext('user');
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
acct: string;
|
||||
page?: string;
|
||||
|
@ -61,13 +64,24 @@ const props = withDefaults(defineProps<{
|
|||
|
||||
const tab = ref(props.page);
|
||||
|
||||
const user = ref<null | Misskey.entities.UserDetailed>(null);
|
||||
const user = ref<null | Misskey.entities.UserDetailed>(CTX_USER);
|
||||
const error = ref<any>(null);
|
||||
|
||||
function fetchUser(): void {
|
||||
if (props.acct == null) return;
|
||||
|
||||
const { username, host } = Misskey.acct.parse(props.acct);
|
||||
|
||||
if (CTX_USER && CTX_USER.username === username && CTX_USER.host === host) {
|
||||
user.value = CTX_USER;
|
||||
return;
|
||||
}
|
||||
|
||||
user.value = null;
|
||||
misskeyApi('users/show', Misskey.acct.parse(props.acct)).then(u => {
|
||||
misskeyApi('users/show', {
|
||||
username,
|
||||
host,
|
||||
}).then(u => {
|
||||
user.value = u;
|
||||
}).catch(err => {
|
||||
error.value = err;
|
||||
|
|
Loading…
Reference in New Issue