partialかどうかの判定に新規のプロパティを利用するように
This commit is contained in:
parent
ba685850df
commit
3ae17b7217
|
@ -325,6 +325,17 @@ export class NoteEntityService implements OnModuleInit {
|
|||
return true;
|
||||
}
|
||||
|
||||
/** CDNなどにキャッシュしても問題ないノートかどうか */
|
||||
@bindThis
|
||||
public canCache(note: MiNote | Packed<'Note'>): boolean {
|
||||
return (
|
||||
(note.visibility === 'public' || note.visibility === 'home') &&
|
||||
note.user?.makeNotesFollowersOnlyBefore == null &&
|
||||
note.user?.makeNotesHiddenBefore == null &&
|
||||
(note.user?.requireSigninToViewContents == false || note.user?.requireSigninToViewContents == null)
|
||||
);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async packAttachedFiles(fileIds: MiNote['fileIds'], packedFiles: Map<MiNote['fileIds'][number], Packed<'DriveFile'> | null>): Promise<Packed<'DriveFile'>[]> {
|
||||
const missingIds = [];
|
||||
|
|
|
@ -29,7 +29,7 @@ class AntennaChannel extends Channel {
|
|||
}
|
||||
|
||||
@bindThis
|
||||
public async init(params: any) {
|
||||
public async init(params: JsonObject) {
|
||||
if (typeof params.antennaId !== 'string') return;
|
||||
this.antennaId = params.antennaId as string;
|
||||
this.minimize = !!(params.minimize ?? false);
|
||||
|
@ -45,13 +45,21 @@ class AntennaChannel extends Channel {
|
|||
|
||||
if (this.isNoteMutedOrBlocked(note)) return;
|
||||
|
||||
if (this.minimize && ['public', 'home'].includes(note.visibility)) {
|
||||
this.send('note', {
|
||||
id: note.id, myReaction: note.myReaction,
|
||||
poll: note.poll?.choices ? { choices: note.poll.choices } : undefined,
|
||||
reply: note.reply?.myReaction ? { myReaction: note.reply.myReaction } : undefined,
|
||||
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
|
||||
});
|
||||
if (this.minimize) {
|
||||
if (this.noteEntityService.canCache(note)) {
|
||||
this.send('note', {
|
||||
id: note.id, myReaction: note.myReaction,
|
||||
poll: note.poll?.choices ? { choices: note.poll.choices } : undefined,
|
||||
reply: note.reply?.myReaction ? { myReaction: note.reply.myReaction } : undefined,
|
||||
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
|
||||
_allowCached_: true,
|
||||
});
|
||||
} else {
|
||||
this.send('note', {
|
||||
id: note.id,
|
||||
_allowCached_: false,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.connection.cacheNote(note);
|
||||
this.send('note', note);
|
||||
|
|
|
@ -29,7 +29,7 @@ class ChannelChannel extends Channel {
|
|||
}
|
||||
|
||||
@bindThis
|
||||
public async init(params: any) {
|
||||
public async init(params: JsonObject) {
|
||||
if (typeof params.channelId !== 'string') return;
|
||||
this.channelId = params.channelId as string;
|
||||
this.minimize = !!(params.minimize ?? false);
|
||||
|
@ -51,13 +51,21 @@ class ChannelChannel extends Channel {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.minimize && ['public', 'home'].includes(note.visibility)) {
|
||||
this.send('note', {
|
||||
id: note.id, myReaction: note.myReaction,
|
||||
poll: note.poll?.choices ? { choices: note.poll.choices } : undefined,
|
||||
reply: note.reply?.myReaction ? { myReaction: note.reply.myReaction } : undefined,
|
||||
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
|
||||
});
|
||||
if (this.minimize) {
|
||||
if (this.noteEntityService.canCache(note)) {
|
||||
this.send('note', {
|
||||
id: note.id, myReaction: note.myReaction,
|
||||
poll: note.poll?.choices ? { choices: note.poll.choices } : undefined,
|
||||
reply: note.reply?.myReaction ? { myReaction: note.reply.myReaction } : undefined,
|
||||
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
|
||||
_allowCached_: true,
|
||||
});
|
||||
} else {
|
||||
this.send('note', {
|
||||
id: note.id,
|
||||
_allowCached_: false,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.connection.cacheNote(note);
|
||||
this.send('note', note);
|
||||
|
|
|
@ -64,13 +64,21 @@ class GlobalTimelineChannel extends Channel {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.minimize && ['public', 'home'].includes(note.visibility)) {
|
||||
this.send('note', {
|
||||
id: note.id, myReaction: note.myReaction,
|
||||
poll: note.poll?.choices ? { choices: note.poll.choices } : undefined,
|
||||
reply: note.reply?.myReaction ? { myReaction: note.reply.myReaction } : undefined,
|
||||
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
|
||||
});
|
||||
if (this.minimize) {
|
||||
if (this.noteEntityService.canCache(note)) {
|
||||
this.send('note', {
|
||||
id: note.id, myReaction: note.myReaction,
|
||||
poll: note.poll?.choices ? { choices: note.poll.choices } : undefined,
|
||||
reply: note.reply?.myReaction ? { myReaction: note.reply.myReaction } : undefined,
|
||||
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
|
||||
_allowCached_: true,
|
||||
});
|
||||
} else {
|
||||
this.send('note', {
|
||||
id: note.id,
|
||||
_allowCached_: false,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.connection.cacheNote(note);
|
||||
this.send('note', note);
|
||||
|
|
|
@ -88,13 +88,21 @@ class HomeTimelineChannel extends Channel {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.minimize && ['public', 'home'].includes(note.visibility)) {
|
||||
this.send('note', {
|
||||
id: note.id, myReaction: note.myReaction,
|
||||
poll: note.poll?.choices ? { choices: note.poll.choices } : undefined,
|
||||
reply: note.reply?.myReaction ? { myReaction: note.reply.myReaction } : undefined,
|
||||
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
|
||||
});
|
||||
if (this.minimize) {
|
||||
if (this.noteEntityService.canCache(note)) {
|
||||
this.send('note', {
|
||||
id: note.id, myReaction: note.myReaction,
|
||||
poll: note.poll?.choices ? { choices: note.poll.choices } : undefined,
|
||||
reply: note.reply?.myReaction ? { myReaction: note.reply.myReaction } : undefined,
|
||||
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
|
||||
_allowCached_: true,
|
||||
});
|
||||
} else {
|
||||
this.send('note', {
|
||||
id: note.id,
|
||||
_allowCached_: false,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.connection.cacheNote(note);
|
||||
this.send('note', note);
|
||||
|
|
|
@ -103,13 +103,21 @@ class HybridTimelineChannel extends Channel {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.minimize && ['public', 'home'].includes(note.visibility)) {
|
||||
this.send('note', {
|
||||
id: note.id, myReaction: note.myReaction,
|
||||
poll: note.poll?.choices ? { choices: note.poll.choices } : undefined,
|
||||
reply: note.reply?.myReaction ? { myReaction: note.reply.myReaction } : undefined,
|
||||
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
|
||||
});
|
||||
if (this.minimize) {
|
||||
if (this.noteEntityService.canCache(note)) {
|
||||
this.send('note', {
|
||||
id: note.id, myReaction: note.myReaction,
|
||||
poll: note.poll?.choices ? { choices: note.poll.choices } : undefined,
|
||||
reply: note.reply?.myReaction ? { myReaction: note.reply.myReaction } : undefined,
|
||||
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
|
||||
_allowCached_: true,
|
||||
});
|
||||
} else {
|
||||
this.send('note', {
|
||||
id: note.id,
|
||||
_allowCached_: false,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.connection.cacheNote(note);
|
||||
this.send('note', note);
|
||||
|
|
|
@ -74,13 +74,21 @@ class LocalTimelineChannel extends Channel {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.minimize && ['public', 'home'].includes(note.visibility)) {
|
||||
this.send('note', {
|
||||
id: note.id, myReaction: note.myReaction,
|
||||
poll: note.poll?.choices ? { choices: note.poll.choices } : undefined,
|
||||
reply: note.reply?.myReaction ? { myReaction: note.reply.myReaction } : undefined,
|
||||
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
|
||||
});
|
||||
if (this.minimize) {
|
||||
if (this.noteEntityService.canCache(note)) {
|
||||
this.send('note', {
|
||||
id: note.id, myReaction: note.myReaction,
|
||||
poll: note.poll?.choices ? { choices: note.poll.choices } : undefined,
|
||||
reply: note.reply?.myReaction ? { myReaction: note.reply.myReaction } : undefined,
|
||||
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
|
||||
_allowCached_: true,
|
||||
});
|
||||
} else {
|
||||
this.send('note', {
|
||||
id: note.id,
|
||||
_allowCached_: false,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.connection.cacheNote(note);
|
||||
this.send('note', note);
|
||||
|
|
|
@ -50,14 +50,23 @@ class RoleTimelineChannel extends Channel {
|
|||
|
||||
if (this.isNoteMutedOrBlocked(note)) return;
|
||||
|
||||
if (this.minimize && ['public', 'home'].includes(note.visibility)) {
|
||||
this.send('note', {
|
||||
id: note.id, myReaction: note.myReaction,
|
||||
poll: note.poll?.choices ? { choices: note.poll.choices } : undefined,
|
||||
reply: note.reply?.myReaction ? { myReaction: note.reply.myReaction } : undefined,
|
||||
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
|
||||
});
|
||||
if (this.minimize) {
|
||||
if (this.noteEntityService.canCache(note)) {
|
||||
this.send('note', {
|
||||
id: note.id, myReaction: note.myReaction,
|
||||
poll: note.poll?.choices ? { choices: note.poll.choices } : undefined,
|
||||
reply: note.reply?.myReaction ? { myReaction: note.reply.myReaction } : undefined,
|
||||
renote: note.renote?.myReaction ? { myReaction: note.renote.myReaction } : undefined,
|
||||
_allowCached_: true,
|
||||
});
|
||||
} else {
|
||||
this.send('note', {
|
||||
id: note.id,
|
||||
_allowCached_: false,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.connection.cacheNote(note);
|
||||
this.send('note', note);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -29,6 +29,8 @@ import { $i, iAmModerator } from '@/account.js';
|
|||
import { instance } from '@/instance.js';
|
||||
import { defaultStore } from '@/store.js';
|
||||
import { Paging } from '@/components/MkPagination.vue';
|
||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||
import { MisskeyEntity } from '@/types/date-separated-list.js';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
src: BasicTimelineType | 'mentions' | 'directs' | 'list' | 'antenna' | 'channel' | 'role';
|
||||
|
@ -73,20 +75,33 @@ const tlComponent = shallowRef<InstanceType<typeof MkNotes>>();
|
|||
|
||||
let tlNotesCount = 0;
|
||||
|
||||
async function prepend(data) {
|
||||
async function prepend(data: Misskey.entities.Note | Misskey.entities.StreamNote) {
|
||||
if (tlComponent.value == null) return;
|
||||
|
||||
let note = data;
|
||||
let note: Misskey.entities.Note & MisskeyEntity;
|
||||
|
||||
// チェックするプロパティはなんでも良い
|
||||
// minimizeが有効でid以外が存在しない場合は取得する
|
||||
if (!data.visibility) {
|
||||
const res = await window.fetch(`/notes/${data.id}.json`, {
|
||||
method: 'GET',
|
||||
credentials: 'omit',
|
||||
});
|
||||
if (!res.ok) return;
|
||||
note = deepMerge(data, await res.json());
|
||||
if ('_allowCached_' in data) {
|
||||
let fullNote: Misskey.entities.Note | null = null;
|
||||
|
||||
const { _allowCached_, ..._data } = data;
|
||||
|
||||
if (_allowCached_) {
|
||||
const res = await window.fetch(`/notes/${data.id}.json`, {
|
||||
method: 'GET',
|
||||
credentials: 'omit',
|
||||
});
|
||||
if (!res.ok) return;
|
||||
fullNote = await res.json();
|
||||
} else {
|
||||
fullNote = await misskeyApi('notes/show', {
|
||||
noteId: data.id,
|
||||
});
|
||||
}
|
||||
if (fullNote == null) return;
|
||||
|
||||
note = deepMerge(_data, fullNote);
|
||||
} else {
|
||||
note = data;
|
||||
}
|
||||
|
||||
tlNotesCount++;
|
||||
|
|
|
@ -635,7 +635,7 @@ export type Channels = {
|
|||
minimize?: boolean;
|
||||
};
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
note: (payload: Note | StreamNote) => void;
|
||||
};
|
||||
receives: null;
|
||||
};
|
||||
|
@ -647,7 +647,7 @@ export type Channels = {
|
|||
minimize?: boolean;
|
||||
};
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
note: (payload: Note | StreamNote) => void;
|
||||
};
|
||||
receives: null;
|
||||
};
|
||||
|
@ -659,7 +659,7 @@ export type Channels = {
|
|||
minimize?: boolean;
|
||||
};
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
note: (payload: Note | StreamNote) => void;
|
||||
};
|
||||
receives: null;
|
||||
};
|
||||
|
@ -670,7 +670,7 @@ export type Channels = {
|
|||
minimize?: boolean;
|
||||
};
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
note: (payload: Note | StreamNote) => void;
|
||||
};
|
||||
receives: null;
|
||||
};
|
||||
|
@ -682,7 +682,7 @@ export type Channels = {
|
|||
minimize?: boolean;
|
||||
};
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
note: (payload: Note | StreamNote) => void;
|
||||
};
|
||||
receives: null;
|
||||
};
|
||||
|
@ -701,7 +701,7 @@ export type Channels = {
|
|||
minimize?: boolean;
|
||||
};
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
note: (payload: Note | StreamNote) => void;
|
||||
};
|
||||
receives: null;
|
||||
};
|
||||
|
@ -711,7 +711,7 @@ export type Channels = {
|
|||
minimize?: boolean;
|
||||
};
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
note: (payload: Note | StreamNote) => void;
|
||||
};
|
||||
receives: null;
|
||||
};
|
||||
|
@ -721,7 +721,7 @@ export type Channels = {
|
|||
minimize?: boolean;
|
||||
};
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
note: (payload: Note | StreamNote) => void;
|
||||
};
|
||||
receives: null;
|
||||
};
|
||||
|
@ -1222,6 +1222,7 @@ declare namespace entities {
|
|||
EmojiUpdated,
|
||||
EmojiDeleted,
|
||||
AnnouncementCreated,
|
||||
StreamNote,
|
||||
SignupRequest,
|
||||
SignupResponse,
|
||||
SignupPendingRequest,
|
||||
|
@ -3192,6 +3193,19 @@ export type StreamEvents = {
|
|||
_disconnected_: void;
|
||||
} & BroadcastEvents;
|
||||
|
||||
// @public (undocumented)
|
||||
type StreamNote = ({
|
||||
id: Note['id'];
|
||||
poll?: Pick<NonNullable<Note['poll']>, 'choices'>;
|
||||
reply?: Pick<NonNullable<Note['reply']>, 'myReaction'>;
|
||||
renote?: Pick<NonNullable<Note['renote']>, 'myReaction'>;
|
||||
} & {
|
||||
_allowCached_: true;
|
||||
}) | {
|
||||
id: Note['id'];
|
||||
_allowCached_: false;
|
||||
};
|
||||
|
||||
// Warning: (ae-forgotten-export) The symbol "SwitchCase" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-forgotten-export) The symbol "IsCaseMatched" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-forgotten-export) The symbol "GetCaseResult" needs to be exported by the entry point index.d.ts
|
||||
|
@ -3421,8 +3435,8 @@ type UsersUpdateMemoRequest = operations['users___update-memo']['requestBody']['
|
|||
// Warnings were encountered during analysis:
|
||||
//
|
||||
// src/entities.ts:50:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts
|
||||
// src/streaming.types.ts:228:4 - (ae-forgotten-export) The symbol "ReversiUpdateKey" needs to be exported by the entry point index.d.ts
|
||||
// src/streaming.types.ts:238:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts
|
||||
// src/streaming.types.ts:229:4 - (ae-forgotten-export) The symbol "ReversiUpdateKey" needs to be exported by the entry point index.d.ts
|
||||
// src/streaming.types.ts:239:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts
|
||||
|
||||
// (No @packageDocumentation comment for this package)
|
||||
|
||||
|
|
|
@ -248,6 +248,18 @@ export type AnnouncementCreated = {
|
|||
announcement: Announcement;
|
||||
};
|
||||
|
||||
export type StreamNote = ({
|
||||
id: Note['id'];
|
||||
poll?: Pick<NonNullable<Note['poll']>, 'choices'>;
|
||||
reply?: Pick<NonNullable<Note['reply']>, 'myReaction'>;
|
||||
renote?: Pick<NonNullable<Note['renote']>, 'myReaction'>;
|
||||
} & {
|
||||
_allowCached_: true;
|
||||
}) | {
|
||||
id: Note['id'];
|
||||
_allowCached_: false;
|
||||
};
|
||||
|
||||
export type SignupRequest = {
|
||||
username: string;
|
||||
password: string;
|
||||
|
|
|
@ -19,6 +19,7 @@ import {
|
|||
QueueStatsLog,
|
||||
ServerStats,
|
||||
ServerStatsLog,
|
||||
StreamNote,
|
||||
ReversiGameDetailed,
|
||||
} from './entities.js';
|
||||
import {
|
||||
|
@ -76,7 +77,7 @@ export type Channels = {
|
|||
minimize?: boolean;
|
||||
};
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
note: (payload: Note | StreamNote) => void;
|
||||
};
|
||||
receives: null;
|
||||
};
|
||||
|
@ -88,7 +89,7 @@ export type Channels = {
|
|||
minimize?: boolean;
|
||||
};
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
note: (payload: Note | StreamNote) => void;
|
||||
};
|
||||
receives: null;
|
||||
};
|
||||
|
@ -100,7 +101,7 @@ export type Channels = {
|
|||
minimize?: boolean;
|
||||
};
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
note: (payload: Note | StreamNote) => void;
|
||||
};
|
||||
receives: null;
|
||||
};
|
||||
|
@ -111,7 +112,7 @@ export type Channels = {
|
|||
minimize?: boolean;
|
||||
};
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
note: (payload: Note | StreamNote) => void;
|
||||
};
|
||||
receives: null;
|
||||
};
|
||||
|
@ -123,7 +124,7 @@ export type Channels = {
|
|||
minimize?: boolean;
|
||||
};
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
note: (payload: Note | StreamNote) => void;
|
||||
};
|
||||
receives: null;
|
||||
};
|
||||
|
@ -142,7 +143,7 @@ export type Channels = {
|
|||
minimize?: boolean;
|
||||
};
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
note: (payload: Note | StreamNote) => void;
|
||||
};
|
||||
receives: null;
|
||||
};
|
||||
|
@ -152,7 +153,7 @@ export type Channels = {
|
|||
minimize?: boolean;
|
||||
};
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
note: (payload: Note | StreamNote) => void;
|
||||
};
|
||||
receives: null;
|
||||
};
|
||||
|
@ -162,7 +163,7 @@ export type Channels = {
|
|||
minimize?: boolean;
|
||||
};
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
note: (payload: Note | StreamNote) => void;
|
||||
};
|
||||
receives: null;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue