Compare commits

...

3 Commits

Author SHA1 Message Date
syuilo 69f64c79ca
Merge ec73511759 into 763c708253 2024-11-19 21:12:42 +09:00
syuilo ec73511759 Update CHANGELOG.md 2024-11-19 20:10:14 +09:00
syuilo 9d36ad9052 wip 2024-11-19 17:53:28 +09:00
6 changed files with 55 additions and 3 deletions

View File

@ -30,6 +30,7 @@
(Based on https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/663) (Based on https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/663)
- Enhance: サイドバーを簡単に展開・折りたたみできるように ( #14981 ) - Enhance: サイドバーを簡単に展開・折りたたみできるように ( #14981 )
- Enhance: リノートメニューに「リノートの詳細」を追加 - Enhance: リノートメニューに「リノートの詳細」を追加
- Enhance: 非ログイン状態でMisskeyを開いた際のパフォーマンスを向上
- Fix: 通知の範囲指定の設定項目が必要ない通知設定でも範囲指定の設定がでている問題を修正 - Fix: 通知の範囲指定の設定項目が必要ない通知設定でも範囲指定の設定がでている問題を修正
- Fix: Turnstileが失敗・期限切れした際にも成功扱いとなってしまう問題を修正 - Fix: Turnstileが失敗・期限切れした際にも成功扱いとなってしまう問題を修正
(Cherry-picked from https://github.com/MisskeyIO/misskey/pull/768) (Cherry-picked from https://github.com/MisskeyIO/misskey/pull/768)

View File

@ -559,7 +559,7 @@ export class ClientServerService {
} }
}); });
//#region SSR (for crawlers) //#region SSR
// User // User
fastify.get<{ Params: { user: string; sub?: string; } }>('/@:user/:sub?', async (request, reply) => { fastify.get<{ Params: { user: string; sub?: string; } }>('/@:user/:sub?', async (request, reply) => {
const { username, host } = Acct.parse(request.params.user); const { username, host } = Acct.parse(request.params.user);
@ -584,11 +584,17 @@ export class ClientServerService {
reply.header('X-Robots-Tag', 'noimageai'); reply.header('X-Robots-Tag', 'noimageai');
reply.header('X-Robots-Tag', 'noai'); reply.header('X-Robots-Tag', 'noai');
} }
const _user = await this.userEntityService.pack(user);
return await reply.view('user', { return await reply.view('user', {
user, profile, me, user, profile, me,
avatarUrl: user.avatarUrl ?? this.userEntityService.getIdenticonUrl(user), avatarUrl: user.avatarUrl ?? this.userEntityService.getIdenticonUrl(user),
sub: request.params.sub, sub: request.params.sub,
...await this.generateCommonPugData(this.meta), ...await this.generateCommonPugData(this.meta),
clientCtx: htmlSafeJsonStringify({
user: _user,
}),
}); });
} else { } else {
// リモートユーザーなので // リモートユーザーなので
@ -641,6 +647,9 @@ export class ClientServerService {
// TODO: Let locale changeable by instance setting // TODO: Let locale changeable by instance setting
summary: getNoteSummary(_note), summary: getNoteSummary(_note),
...await this.generateCommonPugData(this.meta), ...await this.generateCommonPugData(this.meta),
clientCtx: htmlSafeJsonStringify({
note: _note,
}),
}); });
} else { } else {
return await renderBase(reply); return await renderBase(reply);
@ -729,6 +738,9 @@ export class ClientServerService {
profile, profile,
avatarUrl: _clip.user.avatarUrl, avatarUrl: _clip.user.avatarUrl,
...await this.generateCommonPugData(this.meta), ...await this.generateCommonPugData(this.meta),
clientCtx: htmlSafeJsonStringify({
clip: _clip,
}),
}); });
} else { } else {
return await renderBase(reply); return await renderBase(reply);

View File

@ -74,6 +74,9 @@ html
script(type='application/json' id='misskey_meta' data-generated-at=now) script(type='application/json' id='misskey_meta' data-generated-at=now)
!= metaJson != metaJson
script(type='application/json' id='misskey_clientCtx' data-generated-at=now)
!= clientCtx
script script
include ../boot.js include ../boot.js

View File

@ -46,12 +46,13 @@ import { isSupportShare } from '@/scripts/navigator.js';
import { copyToClipboard } from '@/scripts/copy-to-clipboard.js'; import { copyToClipboard } from '@/scripts/copy-to-clipboard.js';
import { genEmbedCode } from '@/scripts/get-embed-code.js'; import { genEmbedCode } from '@/scripts/get-embed-code.js';
import type { MenuItem } from '@/types/menu.js'; import type { MenuItem } from '@/types/menu.js';
import { getServerContext } from '@/server-context.js';
const props = defineProps<{ const props = defineProps<{
clipId: string, clipId: string,
}>(); }>();
const clip = ref<Misskey.entities.Clip | null>(null); const clip = ref<Misskey.entities.Clip | null>(getServerContext('clip'));
const favorited = ref(false); const favorited = ref(false);
const pagination = { const pagination = {
endpoint: 'clips/notes' as const, endpoint: 'clips/notes' as const,
@ -64,6 +65,11 @@ const pagination = {
const isOwned = computed<boolean | null>(() => $i && clip.value && ($i.id === clip.value.userId)); const isOwned = computed<boolean | null>(() => $i && clip.value && ($i.id === clip.value.userId));
watch(() => props.clipId, async () => { watch(() => props.clipId, async () => {
if (getServerContext('clip') && getServerContext('clip').id === props.clipId) {
clip.value = getServerContext('clip');
return;
}
clip.value = await misskeyApi('clips/show', { clip.value = await misskeyApi('clips/show', {
clipId: props.clipId, clipId: props.clipId,
}); });

View File

@ -62,13 +62,14 @@ import { dateString } from '@/filters/date.js';
import MkClipPreview from '@/components/MkClipPreview.vue'; import MkClipPreview from '@/components/MkClipPreview.vue';
import { defaultStore } from '@/store.js'; import { defaultStore } from '@/store.js';
import { pleaseLogin } from '@/scripts/please-login.js'; import { pleaseLogin } from '@/scripts/please-login.js';
import { getServerContext } from '@/server-context.js';
const props = defineProps<{ const props = defineProps<{
noteId: string; noteId: string;
initialTab?: string; initialTab?: string;
}>(); }>();
const note = ref<null | Misskey.entities.Note>(); const note = ref<null | Misskey.entities.Note>(getServerContext('note'));
const clips = ref<Misskey.entities.Clip[]>(); const clips = ref<Misskey.entities.Clip[]>();
const showPrev = ref<'user' | 'channel' | false>(false); const showPrev = ref<'user' | 'channel' | false>(false);
const showNext = ref<'user' | 'channel' | false>(false); const showNext = ref<'user' | 'channel' | false>(false);
@ -116,6 +117,12 @@ function fetchNote() {
showPrev.value = false; showPrev.value = false;
showNext.value = false; showNext.value = false;
note.value = null; note.value = null;
if (getServerContext('note') && getServerContext('note').id === props.noteId) {
note.value = getServerContext('note');
return;
}
misskeyApi('notes/show', { misskeyApi('notes/show', {
noteId: props.noteId, noteId: props.noteId,
}).then(res => { }).then(res => {

View File

@ -0,0 +1,23 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import * as Misskey from 'misskey-js';
import { $i } from '@/account.js';
const providedContextEl = document.getElementById('misskey_clientCtx');
export type ServerContext = {
clip?: Misskey.entities.Clip;
note?: Misskey.entities.Note;
user?: Misskey.entities.UserLite;
} | null;
export const serverContext: ServerContext = (providedContextEl && providedContextEl.textContent) ? JSON.parse(providedContextEl.textContent) : null;
export function getServerContext<K extends keyof NonNullable<ServerContext>>(entity: K): Required<Pick<NonNullable<ServerContext>, K>> | null {
// contextは非ログイン状態の情報しかないためログイン時は利用できない
if ($i) return null;
return serverContext ? (serverContext[entity] ?? null) : null;
}