Merge branch 'misskey-dev:develop' into develop
This commit is contained in:
commit
e8e7ff0f41
@ -26,6 +26,10 @@
|
|||||||
- 見たことのあるRenoteを省略して表示をオンのときに自分のnoteのrenoteを省略するように
|
- 見たことのあるRenoteを省略して表示をオンのときに自分のnoteのrenoteを省略するように
|
||||||
- フォルダーやファイルに対しても開発者モード使用時、IDをコピーできるように
|
- フォルダーやファイルに対しても開発者モード使用時、IDをコピーできるように
|
||||||
- 引用対象を「もっと見る」で展開した場合、「閉じる」で畳めるように
|
- 引用対象を「もっと見る」で展開した場合、「閉じる」で畳めるように
|
||||||
|
- プロフィールURLをコピーできるボタンを追加 #11190
|
||||||
|
- ユーザーのContextMenuに「アンテナに追加」ボタンを追加
|
||||||
|
- フォローやお気に入り登録をしていないチャンネルを開く時は概要ページを開くように
|
||||||
|
- 画面ビューワをタップした場合、マウスクリックと同様に画像ビューワを閉じるように
|
||||||
- Fix: サーバーメトリクスが90度傾いている
|
- Fix: サーバーメトリクスが90度傾いている
|
||||||
- Fix: 非ログイン時にクレデンシャルが必要なページに行くとエラーが出る問題を修正
|
- Fix: 非ログイン時にクレデンシャルが必要なページに行くとエラーが出る問題を修正
|
||||||
- Fix: sparkle内にリンクを入れるとクリック不能になる問題の修正
|
- Fix: sparkle内にリンクを入れるとクリック不能になる問題の修正
|
||||||
@ -33,12 +37,14 @@
|
|||||||
- Fix: ページ遷移でスクロール位置が保持されない問題を修正
|
- Fix: ページ遷移でスクロール位置が保持されない問題を修正
|
||||||
- Fix: フォルダーのページネーションが機能しない #11180
|
- Fix: フォルダーのページネーションが機能しない #11180
|
||||||
- Fix: 長い文章を投稿する際、プレビューが画面からはみ出る問題を修正
|
- Fix: 長い文章を投稿する際、プレビューが画面からはみ出る問題を修正
|
||||||
|
- Fix: システムフォント設定が正しく反映されない問題を修正
|
||||||
|
|
||||||
### Server
|
### Server
|
||||||
- JSON.parse の回数を削減することで、ストリーミングのパフォーマンスを向上しました
|
- JSON.parse の回数を削減することで、ストリーミングのパフォーマンスを向上しました
|
||||||
- nsfwjs のモデルロードを排他することで、重複ロードによってメモリ使用量が増加しないように
|
- nsfwjs のモデルロードを排他することで、重複ロードによってメモリ使用量が増加しないように
|
||||||
- 連合の配送ジョブのパフォーマンスを向上(ロック機構の見直し、Redisキャッシュの活用)
|
- 連合の配送ジョブのパフォーマンスを向上(ロック機構の見直し、Redisキャッシュの活用)
|
||||||
- 全体的なDBクエリのパフォーマンスを向上
|
- 全体的なDBクエリのパフォーマンスを向上
|
||||||
|
- featuredノートのsignedGet回数を減らしました
|
||||||
|
|
||||||
## 13.13.2
|
## 13.13.2
|
||||||
|
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
* Gulp tasks
|
* Gulp tasks
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const fs = require('fs');
|
import * as fs from 'node:fs';
|
||||||
const gulp = require('gulp');
|
import gulp from 'gulp';
|
||||||
const replace = require('gulp-replace');
|
import replace from 'gulp-replace';
|
||||||
const terser = require('gulp-terser');
|
import terser from 'gulp-terser';
|
||||||
const cssnano = require('gulp-cssnano');
|
import cssnano from 'gulp-cssnano';
|
||||||
|
|
||||||
const locales = require('./locales');
|
import locales from './locales/index.js';
|
||||||
const meta = require('./package.json');
|
import meta from './package.json' assert { type: "json" };
|
||||||
|
|
||||||
gulp.task('copy:backend:views', () =>
|
gulp.task('copy:backend:views', () =>
|
||||||
gulp.src('./packages/backend/src/server/web/views/**/*').pipe(gulp.dest('./packages/backend/built/server/web/views'))
|
gulp.src('./packages/backend/src/server/web/views/**/*').pipe(gulp.dest('./packages/backend/built/server/web/views'))
|
@ -1,6 +1,6 @@
|
|||||||
const fs = require('fs');
|
import * as fs from 'node:fs';
|
||||||
const yaml = require('js-yaml');
|
import * as yaml from 'js-yaml';
|
||||||
const ts = require('typescript');
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
function createMembers(record) {
|
function createMembers(record) {
|
||||||
return Object.entries(record)
|
return Object.entries(record)
|
||||||
@ -14,7 +14,7 @@ function createMembers(record) {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function generateDTS() {
|
export default function generateDTS() {
|
||||||
const locale = yaml.load(fs.readFileSync(`${__dirname}/ja-JP.yml`, 'utf-8'));
|
const locale = yaml.load(fs.readFileSync(`${__dirname}/ja-JP.yml`, 'utf-8'));
|
||||||
const members = createMembers(locale);
|
const members = createMembers(locale);
|
||||||
const elements = [
|
const elements = [
|
||||||
|
2
locales/index.d.ts
vendored
2
locales/index.d.ts
vendored
@ -52,6 +52,7 @@ export interface Locale {
|
|||||||
"deleteAndEdit": string;
|
"deleteAndEdit": string;
|
||||||
"deleteAndEditConfirm": string;
|
"deleteAndEditConfirm": string;
|
||||||
"addToList": string;
|
"addToList": string;
|
||||||
|
"addToAntenna": string;
|
||||||
"sendMessage": string;
|
"sendMessage": string;
|
||||||
"copyRSS": string;
|
"copyRSS": string;
|
||||||
"copyUsername": string;
|
"copyUsername": string;
|
||||||
@ -59,6 +60,7 @@ export interface Locale {
|
|||||||
"copyNoteId": string;
|
"copyNoteId": string;
|
||||||
"copyFileId": string;
|
"copyFileId": string;
|
||||||
"copyFolderId": string;
|
"copyFolderId": string;
|
||||||
|
"copyProfileUrl": string;
|
||||||
"searchUser": string;
|
"searchUser": string;
|
||||||
"reply": string;
|
"reply": string;
|
||||||
"loadMore": string;
|
"loadMore": string;
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
* Languages Loader
|
* Languages Loader
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const fs = require('fs');
|
import * as fs from 'node:fs';
|
||||||
const yaml = require('js-yaml');
|
import * as yaml from 'js-yaml';
|
||||||
|
|
||||||
const merge = (...args) => args.reduce((a, c) => ({
|
const merge = (...args) => args.reduce((a, c) => ({
|
||||||
...a,
|
...a,
|
||||||
@ -51,9 +51,9 @@ const primaries = {
|
|||||||
// 何故か文字列にバックスペース文字が混入することがあり、YAMLが壊れるので取り除く
|
// 何故か文字列にバックスペース文字が混入することがあり、YAMLが壊れるので取り除く
|
||||||
const clean = (text) => text.replace(new RegExp(String.fromCodePoint(0x08), 'g'), '');
|
const clean = (text) => text.replace(new RegExp(String.fromCodePoint(0x08), 'g'), '');
|
||||||
|
|
||||||
const locales = languages.reduce((a, c) => (a[c] = yaml.load(clean(fs.readFileSync(`${__dirname}/${c}.yml`, 'utf-8'))) || {}, a), {});
|
const locales = languages.reduce((a, c) => (a[c] = yaml.load(clean(fs.readFileSync(new URL(`${c}.yml`, import.meta.url), 'utf-8'))) || {}, a), {});
|
||||||
|
|
||||||
module.exports = Object.entries(locales)
|
export default Object.entries(locales)
|
||||||
.reduce((a, [k ,v]) => (a[k] = (() => {
|
.reduce((a, [k ,v]) => (a[k] = (() => {
|
||||||
const [lang] = k.split('-');
|
const [lang] = k.split('-');
|
||||||
switch (k) {
|
switch (k) {
|
||||||
|
@ -49,6 +49,7 @@ delete: "削除"
|
|||||||
deleteAndEdit: "削除して編集"
|
deleteAndEdit: "削除して編集"
|
||||||
deleteAndEditConfirm: "このノートを削除してもう一度編集しますか?このノートへのリアクション、Renote、返信も全て削除されます。"
|
deleteAndEditConfirm: "このノートを削除してもう一度編集しますか?このノートへのリアクション、Renote、返信も全て削除されます。"
|
||||||
addToList: "リストに追加"
|
addToList: "リストに追加"
|
||||||
|
addToAntenna: "アンテナに追加"
|
||||||
sendMessage: "メッセージを送信"
|
sendMessage: "メッセージを送信"
|
||||||
copyRSS: "RSSをコピー"
|
copyRSS: "RSSをコピー"
|
||||||
copyUsername: "ユーザー名をコピー"
|
copyUsername: "ユーザー名をコピー"
|
||||||
@ -56,6 +57,7 @@ copyUserId: "ユーザーIDをコピー"
|
|||||||
copyNoteId: "ノートIDをコピー"
|
copyNoteId: "ノートIDをコピー"
|
||||||
copyFileId: "ファイルIDをコピー"
|
copyFileId: "ファイルIDをコピー"
|
||||||
copyFolderId: "フォルダーIDをコピー"
|
copyFolderId: "フォルダーIDをコピー"
|
||||||
|
copyProfileUrl: "プロフィールURLをコピー"
|
||||||
searchUser: "ユーザーを検索"
|
searchUser: "ユーザーを検索"
|
||||||
reply: "返信"
|
reply: "返信"
|
||||||
loadMore: "もっと見る"
|
loadMore: "もっと見る"
|
||||||
|
3
locales/package.json
Normal file
3
locales/package.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"type": "module"
|
||||||
|
}
|
@ -177,7 +177,7 @@ export class ApNoteService {
|
|||||||
|
|
||||||
// リプライ
|
// リプライ
|
||||||
const reply: Note | null = note.inReplyTo
|
const reply: Note | null = note.inReplyTo
|
||||||
? await this.resolveNote(note.inReplyTo, resolver)
|
? await this.resolveNote(note.inReplyTo, { resolver })
|
||||||
.then(x => {
|
.then(x => {
|
||||||
if (x == null) {
|
if (x == null) {
|
||||||
this.logger.warn('Specified inReplyTo, but not found');
|
this.logger.warn('Specified inReplyTo, but not found');
|
||||||
@ -293,9 +293,8 @@ export class ApNoteService {
|
|||||||
* リモートサーバーからフェッチしてMisskeyに登録しそれを返します。
|
* リモートサーバーからフェッチしてMisskeyに登録しそれを返します。
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
public async resolveNote(value: string | IObject, resolver?: Resolver): Promise<Note | null> {
|
public async resolveNote(value: string | IObject, options: { sentFrom?: URL, resolver?: Resolver } = {}): Promise<Note | null> {
|
||||||
const uri = typeof value === 'string' ? value : value.id;
|
const uri = getApId(value);
|
||||||
if (uri == null) throw new Error('missing uri');
|
|
||||||
|
|
||||||
// ブロックしていたら中断
|
// ブロックしていたら中断
|
||||||
const meta = await this.metaService.fetch();
|
const meta = await this.metaService.fetch();
|
||||||
@ -318,7 +317,8 @@ export class ApNoteService {
|
|||||||
// リモートサーバーからフェッチしてきて登録
|
// リモートサーバーからフェッチしてきて登録
|
||||||
// ここでuriの代わりに添付されてきたNote Objectが指定されていると、サーバーフェッチを経ずにノートが生成されるが
|
// ここでuriの代わりに添付されてきたNote Objectが指定されていると、サーバーフェッチを経ずにノートが生成されるが
|
||||||
// 添付されてきたNote Objectは偽装されている可能性があるため、常にuriを指定してサーバーフェッチを行う。
|
// 添付されてきたNote Objectは偽装されている可能性があるため、常にuriを指定してサーバーフェッチを行う。
|
||||||
return await this.createNote(uri, resolver, true);
|
const createFrom = options.sentFrom?.origin === new URL(uri).origin ? value : uri;
|
||||||
|
return await this.createNote(createFrom, options.resolver, true);
|
||||||
} finally {
|
} finally {
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
@ -604,7 +604,10 @@ export class ApPersonService implements OnModuleInit {
|
|||||||
const featuredNotes = await Promise.all(items
|
const featuredNotes = await Promise.all(items
|
||||||
.filter(item => getApType(item) === 'Note') // TODO: Noteでなくてもいいかも
|
.filter(item => getApType(item) === 'Note') // TODO: Noteでなくてもいいかも
|
||||||
.slice(0, 5)
|
.slice(0, 5)
|
||||||
.map(item => limit(() => this.apNoteService.resolveNote(item, _resolver))));
|
.map(item => limit(() => this.apNoteService.resolveNote(item, {
|
||||||
|
resolver: _resolver,
|
||||||
|
sentFrom: new URL(user.uri),
|
||||||
|
}))));
|
||||||
|
|
||||||
await this.db.transaction(async transactionalEntityManager => {
|
await this.db.transaction(async transactionalEntityManager => {
|
||||||
await transactionalEntityManager.delete(UserNotePining, { userId: user.id });
|
await transactionalEntityManager.delete(UserNotePining, { userId: user.id });
|
||||||
|
@ -18,7 +18,8 @@ type MockResponse = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export class MockResolver extends Resolver {
|
export class MockResolver extends Resolver {
|
||||||
private _rs = new Map<string, MockResponse>();
|
#responseMap = new Map<string, MockResponse>();
|
||||||
|
#remoteGetTrials: string[] = [];
|
||||||
|
|
||||||
constructor(loggerService: LoggerService) {
|
constructor(loggerService: LoggerService) {
|
||||||
super(
|
super(
|
||||||
@ -38,18 +39,28 @@ export class MockResolver extends Resolver {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async _register(uri: string, content: string | Record<string, any>, type = 'application/activity+json') {
|
public register(uri: string, content: string | Record<string, any>, type = 'application/activity+json'): void {
|
||||||
this._rs.set(uri, {
|
this.#responseMap.set(uri, {
|
||||||
type,
|
type,
|
||||||
content: typeof content === 'string' ? content : JSON.stringify(content),
|
content: typeof content === 'string' ? content : JSON.stringify(content),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public clear(): void {
|
||||||
|
this.#responseMap.clear();
|
||||||
|
this.#remoteGetTrials.length = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public remoteGetTrials(): string[] {
|
||||||
|
return this.#remoteGetTrials;
|
||||||
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async resolve(value: string | IObject): Promise<IObject> {
|
public async resolve(value: string | IObject): Promise<IObject> {
|
||||||
if (typeof value !== 'string') return value;
|
if (typeof value !== 'string') return value;
|
||||||
|
|
||||||
const r = this._rs.get(value);
|
this.#remoteGetTrials.push(value);
|
||||||
|
const r = this.#responseMap.get(value);
|
||||||
|
|
||||||
if (!r) {
|
if (!r) {
|
||||||
throw new Error('Not registed for mock');
|
throw new Error('Not registed for mock');
|
||||||
|
@ -11,16 +11,19 @@ import { GlobalModule } from '@/GlobalModule.js';
|
|||||||
import { CoreModule } from '@/core/CoreModule.js';
|
import { CoreModule } from '@/core/CoreModule.js';
|
||||||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||||
import { LoggerService } from '@/core/LoggerService.js';
|
import { LoggerService } from '@/core/LoggerService.js';
|
||||||
import type { IActor } from '@/core/activitypub/type.js';
|
import type { IActor, ICollection, IPost } from '@/core/activitypub/type.js';
|
||||||
import { Note } from '@/models/index.js';
|
import { Note } from '@/models/index.js';
|
||||||
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||||
import { MockResolver } from '../misc/mock-resolver.js';
|
import { MockResolver } from '../misc/mock-resolver.js';
|
||||||
|
|
||||||
const host = 'https://host1.test';
|
const host = 'https://host1.test';
|
||||||
|
|
||||||
function createRandomActor(): IActor & { id: string } {
|
type NonTransientIActor = IActor & { id: string };
|
||||||
|
type NonTransientIPost = IPost & { id: string };
|
||||||
|
|
||||||
|
function createRandomActor({ actorHost = host } = {}): NonTransientIActor {
|
||||||
const preferredUsername = secureRndstr(8);
|
const preferredUsername = secureRndstr(8);
|
||||||
const actorId = `${host}/users/${preferredUsername.toLowerCase()}`;
|
const actorId = `${actorHost}/users/${preferredUsername.toLowerCase()}`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
@ -32,13 +35,41 @@ function createRandomActor(): IActor & { id: string } {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createRandomNote(actor: NonTransientIActor): NonTransientIPost {
|
||||||
|
const id = secureRndstr(8);
|
||||||
|
const noteId = `${new URL(actor.id).origin}/notes/${id}`;
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: noteId,
|
||||||
|
type: 'Note',
|
||||||
|
attributedTo: actor.id,
|
||||||
|
content: 'test test foo',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function createRandomNotes(actor: NonTransientIActor, length: number): NonTransientIPost[] {
|
||||||
|
return new Array(length).fill(null).map(() => createRandomNote(actor));
|
||||||
|
}
|
||||||
|
|
||||||
|
function createRandomFeaturedCollection(actor: NonTransientIActor, length: number): ICollection {
|
||||||
|
const items = createRandomNotes(actor, length);
|
||||||
|
|
||||||
|
return {
|
||||||
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
|
type: 'Collection',
|
||||||
|
id: actor.outbox as string,
|
||||||
|
totalItems: items.length,
|
||||||
|
items,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
describe('ActivityPub', () => {
|
describe('ActivityPub', () => {
|
||||||
let noteService: ApNoteService;
|
let noteService: ApNoteService;
|
||||||
let personService: ApPersonService;
|
let personService: ApPersonService;
|
||||||
let rendererService: ApRendererService;
|
let rendererService: ApRendererService;
|
||||||
let resolver: MockResolver;
|
let resolver: MockResolver;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeAll(async () => {
|
||||||
const app = await Test.createTestingModule({
|
const app = await Test.createTestingModule({
|
||||||
imports: [GlobalModule, CoreModule],
|
imports: [GlobalModule, CoreModule],
|
||||||
}).compile();
|
}).compile();
|
||||||
@ -53,7 +84,11 @@ describe('ActivityPub', () => {
|
|||||||
|
|
||||||
// Prevent ApPersonService from fetching instance, as it causes Jest import-after-test error
|
// Prevent ApPersonService from fetching instance, as it causes Jest import-after-test error
|
||||||
const federatedInstanceService = app.get<FederatedInstanceService>(FederatedInstanceService);
|
const federatedInstanceService = app.get<FederatedInstanceService>(FederatedInstanceService);
|
||||||
jest.spyOn(federatedInstanceService, 'fetch').mockImplementation(() => new Promise(() => {}));
|
jest.spyOn(federatedInstanceService, 'fetch').mockImplementation(() => new Promise(() => { }));
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
resolver.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Parse minimum object', () => {
|
describe('Parse minimum object', () => {
|
||||||
@ -69,7 +104,7 @@ describe('ActivityPub', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
test('Minimum Actor', async () => {
|
test('Minimum Actor', async () => {
|
||||||
resolver._register(actor.id, actor);
|
resolver.register(actor.id, actor);
|
||||||
|
|
||||||
const user = await personService.createPerson(actor.id, resolver);
|
const user = await personService.createPerson(actor.id, resolver);
|
||||||
|
|
||||||
@ -79,8 +114,8 @@ describe('ActivityPub', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Minimum Note', async () => {
|
test('Minimum Note', async () => {
|
||||||
resolver._register(actor.id, actor);
|
resolver.register(actor.id, actor);
|
||||||
resolver._register(post.id, post);
|
resolver.register(post.id, post);
|
||||||
|
|
||||||
const note = await noteService.createNote(post.id, resolver, true);
|
const note = await noteService.createNote(post.id, resolver, true);
|
||||||
|
|
||||||
@ -97,7 +132,7 @@ describe('ActivityPub', () => {
|
|||||||
name: secureRndstr(129),
|
name: secureRndstr(129),
|
||||||
};
|
};
|
||||||
|
|
||||||
resolver._register(actor.id, actor);
|
resolver.register(actor.id, actor);
|
||||||
|
|
||||||
const user = await personService.createPerson(actor.id, resolver);
|
const user = await personService.createPerson(actor.id, resolver);
|
||||||
|
|
||||||
@ -110,7 +145,7 @@ describe('ActivityPub', () => {
|
|||||||
name: '',
|
name: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
resolver._register(actor.id, actor);
|
resolver.register(actor.id, actor);
|
||||||
|
|
||||||
const user = await personService.createPerson(actor.id, resolver);
|
const user = await personService.createPerson(actor.id, resolver);
|
||||||
|
|
||||||
@ -126,4 +161,62 @@ describe('ActivityPub', () => {
|
|||||||
} as Note);
|
} as Note);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Featured', () => {
|
||||||
|
test('Fetch featured notes from IActor', async () => {
|
||||||
|
const actor = createRandomActor();
|
||||||
|
actor.featured = `${actor.id}/collections/featured`;
|
||||||
|
|
||||||
|
const featured = createRandomFeaturedCollection(actor, 5);
|
||||||
|
|
||||||
|
resolver.register(actor.id, actor);
|
||||||
|
resolver.register(actor.featured, featured);
|
||||||
|
|
||||||
|
await personService.createPerson(actor.id, resolver);
|
||||||
|
|
||||||
|
// All notes in `featured` are same-origin, no need to fetch notes again
|
||||||
|
assert.deepStrictEqual(resolver.remoteGetTrials(), [actor.id, actor.featured]);
|
||||||
|
|
||||||
|
// Created notes without resolving anything
|
||||||
|
for (const item of featured.items as IPost[]) {
|
||||||
|
const note = await noteService.fetchNote(item);
|
||||||
|
assert.ok(note);
|
||||||
|
assert.strictEqual(note.text, 'test test foo');
|
||||||
|
assert.strictEqual(note.uri, item.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Fetch featured notes from IActor pointing to another remote server', async () => {
|
||||||
|
const actor1 = createRandomActor();
|
||||||
|
actor1.featured = `${actor1.id}/collections/featured`;
|
||||||
|
const actor2 = createRandomActor({ actorHost: 'https://host2.test' });
|
||||||
|
|
||||||
|
const actor2Note = createRandomNote(actor2);
|
||||||
|
const featured = createRandomFeaturedCollection(actor1, 0);
|
||||||
|
(featured.items as IPost[]).push({
|
||||||
|
...actor2Note,
|
||||||
|
content: 'test test bar', // fraud!
|
||||||
|
});
|
||||||
|
|
||||||
|
resolver.register(actor1.id, actor1);
|
||||||
|
resolver.register(actor1.featured, featured);
|
||||||
|
resolver.register(actor2.id, actor2);
|
||||||
|
resolver.register(actor2Note.id, actor2Note);
|
||||||
|
|
||||||
|
await personService.createPerson(actor1.id, resolver);
|
||||||
|
|
||||||
|
// actor2Note is from a different server and needs to be fetched again
|
||||||
|
assert.deepStrictEqual(
|
||||||
|
resolver.remoteGetTrials(),
|
||||||
|
[actor1.id, actor1.featured, actor2Note.id, actor2.id],
|
||||||
|
);
|
||||||
|
|
||||||
|
const note = await noteService.fetchNote(actor2Note.id);
|
||||||
|
assert.ok(note);
|
||||||
|
|
||||||
|
// Reflects the original content instead of the fraud
|
||||||
|
assert.strictEqual(note.text, 'test test foo');
|
||||||
|
assert.strictEqual(note.uri, actor2Note.id);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
import fs from 'node:fs/promises';
|
import fs from 'node:fs/promises';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import micromatch from 'micromatch';
|
import micromatch from 'micromatch';
|
||||||
import main from './main';
|
import main from './main.js';
|
||||||
|
|
||||||
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||||
|
|
||||||
interface Stats {
|
interface Stats {
|
||||||
readonly modules: readonly {
|
readonly modules: readonly {
|
||||||
@ -13,8 +16,8 @@ interface Stats {
|
|||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.readFile(
|
await fs.readFile(
|
||||||
path.resolve(__dirname, '../storybook-static/preview-stats.json')
|
new URL('../storybook-static/preview-stats.json', import.meta.url)
|
||||||
).then((buffer) => {
|
).then((buffer) => {
|
||||||
const stats: Stats = JSON.parse(buffer.toString());
|
const stats: Stats = JSON.parse(buffer.toString());
|
||||||
const keys = new Set(stats.modules.map((stat) => stat.id));
|
const keys = new Set(stats.modules.map((stat) => stat.id));
|
||||||
|
@ -96,7 +96,7 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toStories(component: string): string {
|
function toStories(component: string): Promise<string> {
|
||||||
const msw = `${component.slice(0, -'.vue'.length)}.msw`;
|
const msw = `${component.slice(0, -'.vue'.length)}.msw`;
|
||||||
const implStories = `${component.slice(0, -'.vue'.length)}.stories.impl`;
|
const implStories = `${component.slice(0, -'.vue'.length)}.stories.impl`;
|
||||||
const metaStories = `${component.slice(0, -'.vue'.length)}.stories.meta`;
|
const metaStories = `${component.slice(0, -'.vue'.length)}.stories.meta`;
|
||||||
@ -394,7 +394,8 @@ function toStories(component: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// glob('src/{components,pages,ui,widgets}/**/*.vue')
|
// glob('src/{components,pages,ui,widgets}/**/*.vue')
|
||||||
Promise.all([
|
(async () => {
|
||||||
|
const globs = await Promise.all([
|
||||||
glob('src/components/global/*.vue'),
|
glob('src/components/global/*.vue'),
|
||||||
glob('src/components/Mk{A,B}*.vue'),
|
glob('src/components/Mk{A,B}*.vue'),
|
||||||
glob('src/components/MkDigitalClock.vue'),
|
glob('src/components/MkDigitalClock.vue'),
|
||||||
@ -403,9 +404,10 @@ Promise.all([
|
|||||||
glob('src/components/MkUserSetupDialog.vue'),
|
glob('src/components/MkUserSetupDialog.vue'),
|
||||||
glob('src/components/MkUserSetupDialog.*.vue'),
|
glob('src/components/MkUserSetupDialog.*.vue'),
|
||||||
glob('src/pages/user/home.vue'),
|
glob('src/pages/user/home.vue'),
|
||||||
])
|
]);
|
||||||
.then((globs) => globs.flat())
|
const components = globs.flat();
|
||||||
.then((components) => Promise.all(components.map((component) => {
|
await Promise.all(components.map(async (component) => {
|
||||||
const stories = component.replace(/\.vue$/, '.stories.ts');
|
const stories = component.replace(/\.vue$/, '.stories.ts');
|
||||||
return writeFile(stories, toStories(component));
|
await writeFile(stories, await toStories(component));
|
||||||
})));
|
}))
|
||||||
|
})();
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
import { resolve } from 'node:path';
|
import { resolve } from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
import type { StorybookConfig } from '@storybook/vue3-vite';
|
import type { StorybookConfig } from '@storybook/vue3-vite';
|
||||||
import { type Plugin, mergeConfig } from 'vite';
|
import { type Plugin, mergeConfig } from 'vite';
|
||||||
import turbosnap from 'vite-plugin-turbosnap';
|
import turbosnap from 'vite-plugin-turbosnap';
|
||||||
|
|
||||||
|
const dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
|
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
|
||||||
addons: [
|
addons: [
|
||||||
@ -9,7 +13,7 @@ const config = {
|
|||||||
'@storybook/addon-interactions',
|
'@storybook/addon-interactions',
|
||||||
'@storybook/addon-links',
|
'@storybook/addon-links',
|
||||||
'@storybook/addon-storysource',
|
'@storybook/addon-storysource',
|
||||||
resolve(__dirname, '../node_modules/storybook-addon-misskey-theme'),
|
resolve(dirname, '../node_modules/storybook-addon-misskey-theme'),
|
||||||
],
|
],
|
||||||
framework: {
|
framework: {
|
||||||
name: '@storybook/vue3-vite',
|
name: '@storybook/vue3-vite',
|
||||||
@ -28,7 +32,8 @@ const config = {
|
|||||||
}
|
}
|
||||||
return mergeConfig(config, {
|
return mergeConfig(config, {
|
||||||
plugins: [
|
plugins: [
|
||||||
turbosnap({
|
// XXX: https://github.com/IanVS/vite-plugin-turbosnap/issues/8
|
||||||
|
(turbosnap as any as typeof turbosnap['default'])({
|
||||||
rootDir: config.root ?? process.cwd(),
|
rootDir: config.root ?? process.cwd(),
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
3
packages/frontend/.storybook/package.json
Normal file
3
packages/frontend/.storybook/package.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"type": "module"
|
||||||
|
}
|
@ -1,9 +1,8 @@
|
|||||||
import { writeFile } from 'node:fs/promises';
|
import { writeFile } from 'node:fs/promises';
|
||||||
import { resolve } from 'node:path';
|
import * as locales from '../../../locales/index.js';
|
||||||
import * as locales from '../../../locales';
|
|
||||||
|
|
||||||
writeFile(
|
await writeFile(
|
||||||
resolve(__dirname, 'locale.ts'),
|
new URL('locale.ts', import.meta.url),
|
||||||
`export default ${JSON.stringify(locales['ja-JP'], undefined, 2)} as const;`,
|
`export default ${JSON.stringify(locales['ja-JP'], undefined, 2)} as const;`,
|
||||||
'utf8',
|
'utf8',
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { readFile, writeFile } from 'node:fs/promises';
|
import { readFile, writeFile } from 'node:fs/promises';
|
||||||
import { resolve } from 'node:path';
|
import JSON5 from 'json5';
|
||||||
import * as JSON5 from 'json5';
|
|
||||||
|
|
||||||
const keys = [
|
const keys = [
|
||||||
'_dark',
|
'_dark',
|
||||||
@ -26,9 +25,9 @@ const keys = [
|
|||||||
'd-u0',
|
'd-u0',
|
||||||
]
|
]
|
||||||
|
|
||||||
Promise.all(keys.map((key) => readFile(resolve(__dirname, `../src/themes/${key}.json5`), 'utf8'))).then((sources) => {
|
await Promise.all(keys.map((key) => readFile(new URL(`../src/themes/${key}.json5`, import.meta.url), 'utf8'))).then((sources) => {
|
||||||
writeFile(
|
writeFile(
|
||||||
resolve(__dirname, './themes.ts'),
|
new URL('./themes.ts', import.meta.url),
|
||||||
`export default ${JSON.stringify(
|
`export default ${JSON.stringify(
|
||||||
Object.fromEntries(sources.map((source, i) => [keys[i], JSON5.parse(source)])),
|
Object.fromEntries(sources.map((source, i) => [keys[i], JSON5.parse(source)])),
|
||||||
undefined,
|
undefined,
|
||||||
|
@ -3,10 +3,10 @@ import { FORCE_REMOUNT } from '@storybook/core-events';
|
|||||||
import { type Preview, setup } from '@storybook/vue3';
|
import { type Preview, setup } from '@storybook/vue3';
|
||||||
import isChromatic from 'chromatic/isChromatic';
|
import isChromatic from 'chromatic/isChromatic';
|
||||||
import { initialize, mswDecorator } from 'msw-storybook-addon';
|
import { initialize, mswDecorator } from 'msw-storybook-addon';
|
||||||
import { userDetailed } from './fakes';
|
import { userDetailed } from './fakes.js';
|
||||||
import locale from './locale';
|
import locale from './locale.js';
|
||||||
import { commonHandlers, onUnhandledRequest } from './mocks';
|
import { commonHandlers, onUnhandledRequest } from './mocks.js';
|
||||||
import themes from './themes';
|
import themes from './themes.js';
|
||||||
import '../src/style.scss';
|
import '../src/style.scss';
|
||||||
|
|
||||||
const appInitialized = Symbol();
|
const appInitialized = Symbol();
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"target": "es2022",
|
||||||
|
"module": "Node16",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"allowUnusedLabels": false,
|
"allowUnusedLabels": false,
|
||||||
"allowUnreachableCode": false,
|
"allowUnreachableCode": false,
|
||||||
|
@ -4,3 +4,4 @@ import { Cache } from '@/scripts/cache';
|
|||||||
export const clipsCache = new Cache<misskey.entities.Clip[]>(Infinity);
|
export const clipsCache = new Cache<misskey.entities.Clip[]>(Infinity);
|
||||||
export const rolesCache = new Cache(Infinity);
|
export const rolesCache = new Cache(Infinity);
|
||||||
export const userListsCache = new Cache<misskey.entities.UserList[]>(Infinity);
|
export const userListsCache = new Cache<misskey.entities.UserList[]>(Infinity);
|
||||||
|
export const antennasCache = new Cache<misskey.entities.Antenna[]>(Infinity);
|
||||||
|
@ -1,24 +1,29 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div v-for="user in users" :key="user.id" style="display:inline-block;width:32px;height:32px;margin-right:8px;">
|
<div v-for="user in users.slice(0, limit)" :key="user.id" style="display:inline-block;width:32px;height:32px;margin-right:8px;">
|
||||||
<MkAvatar :user="user" style="width:32px; height:32px;" indicator link preview/>
|
<MkAvatar :user="user" style="width:32px; height:32px;" indicator link preview/>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="users.length > limit" style="display: inline-block;">...</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
|
import { UserLite } from 'misskey-js/built/entities';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
userIds: string[];
|
userIds: string[];
|
||||||
}>();
|
limit?: number;
|
||||||
|
}>(), {
|
||||||
|
limit: Infinity,
|
||||||
|
});
|
||||||
|
|
||||||
const users = ref([]);
|
const users = ref<UserLite[]>([]);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
users.value = await os.api('users/show', {
|
users.value = await os.api('users/show', {
|
||||||
userIds: props.userIds,
|
userIds: props.userIds,
|
||||||
});
|
}) as unknown as UserLite[];
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -113,7 +113,7 @@ onMounted(() => {
|
|||||||
right: 0,
|
right: 0,
|
||||||
},
|
},
|
||||||
imageClickAction: 'close',
|
imageClickAction: 'close',
|
||||||
tapAction: 'toggle-controls',
|
tapAction: 'close',
|
||||||
bgOpacity: 1,
|
bgOpacity: 1,
|
||||||
showAnimationDuration: 100,
|
showAnimationDuration: 100,
|
||||||
hideAnimationDuration: 100,
|
hideAnimationDuration: 100,
|
||||||
|
@ -87,7 +87,7 @@ const props = defineProps<{
|
|||||||
channelId: string;
|
channelId: string;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
let tab = $ref('timeline');
|
let tab = $ref('overview');
|
||||||
let channel = $ref(null);
|
let channel = $ref(null);
|
||||||
let favorited = $ref(false);
|
let favorited = $ref(false);
|
||||||
let searchQuery = $ref('');
|
let searchQuery = $ref('');
|
||||||
@ -107,6 +107,9 @@ watch(() => props.channelId, async () => {
|
|||||||
channelId: props.channelId,
|
channelId: props.channelId,
|
||||||
});
|
});
|
||||||
favorited = channel.isFavorited;
|
favorited = channel.isFavorited;
|
||||||
|
if (favorited || channel.isFollowing) {
|
||||||
|
tab = 'timeline';
|
||||||
|
}
|
||||||
}, { immediate: true });
|
}, { immediate: true });
|
||||||
|
|
||||||
function edit() {
|
function edit() {
|
||||||
|
@ -9,6 +9,7 @@ import XAntenna from './editor.vue';
|
|||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||||
import { useRouter } from '@/router';
|
import { useRouter } from '@/router';
|
||||||
|
import { antennasCache } from '@/cache';
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
@ -26,13 +27,10 @@ let draft = $ref({
|
|||||||
});
|
});
|
||||||
|
|
||||||
function onAntennaCreated() {
|
function onAntennaCreated() {
|
||||||
|
antennasCache.delete();
|
||||||
router.push('/my/antennas');
|
router.push('/my/antennas');
|
||||||
}
|
}
|
||||||
|
|
||||||
const headerActions = $computed(() => []);
|
|
||||||
|
|
||||||
const headerTabs = $computed(() => []);
|
|
||||||
|
|
||||||
definePageMetadata({
|
definePageMetadata({
|
||||||
title: i18n.ts.manageAntennas,
|
title: i18n.ts.manageAntennas,
|
||||||
icon: 'ti ti-antenna',
|
icon: 'ti ti-antenna',
|
||||||
|
@ -10,6 +10,7 @@ import * as os from '@/os';
|
|||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import { useRouter } from '@/router';
|
import { useRouter } from '@/router';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||||
|
import { antennasCache } from '@/cache';
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ const props = defineProps<{
|
|||||||
}>();
|
}>();
|
||||||
|
|
||||||
function onAntennaUpdated() {
|
function onAntennaUpdated() {
|
||||||
|
antennasCache.delete();
|
||||||
router.push('/my/antennas');
|
router.push('/my/antennas');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,10 +29,6 @@ os.api('antennas/show', { antennaId: props.antennaId }).then((antennaResponse) =
|
|||||||
antenna = antennaResponse;
|
antenna = antennaResponse;
|
||||||
});
|
});
|
||||||
|
|
||||||
const headerActions = $computed(() => []);
|
|
||||||
|
|
||||||
const headerTabs = $computed(() => []);
|
|
||||||
|
|
||||||
definePageMetadata({
|
definePageMetadata({
|
||||||
title: i18n.ts.manageAntennas,
|
title: i18n.ts.manageAntennas,
|
||||||
icon: 'ti ti-antenna',
|
icon: 'ti ti-antenna',
|
||||||
|
@ -2,15 +2,20 @@
|
|||||||
<MkStickyContainer>
|
<MkStickyContainer>
|
||||||
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
||||||
<MkSpacer :contentMax="700">
|
<MkSpacer :contentMax="700">
|
||||||
<div class="ieepwinx">
|
<div>
|
||||||
<MkButton :link="true" to="/my/antennas/create" primary class="add"><i class="ti ti-plus"></i> {{ i18n.ts.add }}</MkButton>
|
<div v-if="antennas.length === 0" class="empty">
|
||||||
|
<div class="_fullinfo">
|
||||||
|
<img :src="infoImageUrl" class="_ghost"/>
|
||||||
|
<div>{{ i18n.ts.nothing }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="">
|
<MkButton :link="true" to="/my/antennas/create" primary :class="$style.add"><i class="ti ti-plus"></i> {{ i18n.ts.add }}</MkButton>
|
||||||
<MkPagination v-slot="{items}" ref="list" :pagination="pagination">
|
|
||||||
<MkA v-for="antenna in items" :key="antenna.id" class="ljoevbzj" :to="`/my/antennas/${antenna.id}`">
|
<div v-if="antennas.length > 0" class="_gaps">
|
||||||
|
<MkA v-for="antenna in antennas" :key="antenna.id" :class="$style.antenna" :to="`/my/antennas/${antenna.id}`">
|
||||||
<div class="name">{{ antenna.name }}</div>
|
<div class="name">{{ antenna.name }}</div>
|
||||||
</MkA>
|
</MkA>
|
||||||
</MkPagination>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
@ -18,19 +23,31 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { } from 'vue';
|
|
||||||
import MkPagination from '@/components/MkPagination.vue';
|
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||||
|
import { antennasCache } from '@/cache';
|
||||||
|
import { api } from '@/os';
|
||||||
|
import { onActivated } from 'vue';
|
||||||
|
import { infoImageUrl } from '@/instance';
|
||||||
|
|
||||||
const pagination = {
|
const antennas = $computed(() => antennasCache.value.value ?? []);
|
||||||
endpoint: 'antennas/list' as const,
|
|
||||||
noPaging: true,
|
|
||||||
limit: 10,
|
|
||||||
};
|
|
||||||
|
|
||||||
const headerActions = $computed(() => []);
|
function fetch() {
|
||||||
|
antennasCache.fetch(() => api('antennas/list'));
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch();
|
||||||
|
|
||||||
|
const headerActions = $computed(() => [{
|
||||||
|
asFullButton: true,
|
||||||
|
icon: 'ti ti-refresh',
|
||||||
|
text: i18n.ts.reload,
|
||||||
|
handler: () => {
|
||||||
|
antennasCache.delete();
|
||||||
|
fetch();
|
||||||
|
},
|
||||||
|
}]);
|
||||||
|
|
||||||
const headerTabs = $computed(() => []);
|
const headerTabs = $computed(() => []);
|
||||||
|
|
||||||
@ -38,19 +55,20 @@ definePageMetadata({
|
|||||||
title: i18n.ts.manageAntennas,
|
title: i18n.ts.manageAntennas,
|
||||||
icon: 'ti ti-antenna',
|
icon: 'ti ti-antenna',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onActivated(() => {
|
||||||
|
antennasCache.fetch(() => api('antennas/list'));
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" module>
|
||||||
.ieepwinx {
|
.add {
|
||||||
|
|
||||||
> .add {
|
|
||||||
margin: 0 auto 16px auto;
|
margin: 0 auto 16px auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ljoevbzj {
|
.antenna {
|
||||||
display: block;
|
display: block;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
margin-bottom: 8px;
|
|
||||||
border: solid 1px var(--divider);
|
border: solid 1px var(--divider);
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
|
||||||
@ -58,10 +76,9 @@ definePageMetadata({
|
|||||||
border: solid 1px var(--accent);
|
border: solid 1px var(--accent);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
> .name {
|
.name {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -3,38 +3,43 @@
|
|||||||
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
||||||
<MkSpacer :contentMax="700">
|
<MkSpacer :contentMax="700">
|
||||||
<div class="_gaps">
|
<div class="_gaps">
|
||||||
|
<div v-if="items.length === 0" class="empty">
|
||||||
|
<div class="_fullinfo">
|
||||||
|
<img :src="infoImageUrl" class="_ghost"/>
|
||||||
|
<div>{{ i18n.ts.nothing }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<MkButton primary rounded style="margin: 0 auto;" @click="create"><i class="ti ti-plus"></i> {{ i18n.ts.createList }}</MkButton>
|
<MkButton primary rounded style="margin: 0 auto;" @click="create"><i class="ti ti-plus"></i> {{ i18n.ts.createList }}</MkButton>
|
||||||
|
|
||||||
<MkPagination v-slot="{items}" ref="pagingComponent" :pagination="pagination">
|
<div v-if="items.length > 0" class="_gaps">
|
||||||
<div class="_gaps">
|
|
||||||
<MkA v-for="list in items" :key="list.id" class="_panel" :class="$style.list" :to="`/my/lists/${ list.id }`">
|
<MkA v-for="list in items" :key="list.id" class="_panel" :class="$style.list" :to="`/my/lists/${ list.id }`">
|
||||||
<div style="margin-bottom: 4px;">{{ list.name }}</div>
|
<div style="margin-bottom: 4px;">{{ list.name }}</div>
|
||||||
<MkAvatars :userIds="list.userIds"/>
|
<MkAvatars :userIds="list.userIds" :limit="10"/>
|
||||||
</MkA>
|
</MkA>
|
||||||
</div>
|
</div>
|
||||||
</MkPagination>
|
|
||||||
</div>
|
</div>
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
</MkStickyContainer>
|
</MkStickyContainer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { } from 'vue';
|
import { onActivated } from 'vue';
|
||||||
import MkPagination from '@/components/MkPagination.vue';
|
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
import MkAvatars from '@/components/MkAvatars.vue';
|
import MkAvatars from '@/components/MkAvatars.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||||
import { userListsCache } from '@/cache';
|
import { userListsCache } from '@/cache';
|
||||||
|
import { infoImageUrl } from '@/instance';
|
||||||
|
|
||||||
const pagingComponent = $shallowRef<InstanceType<typeof MkPagination>>();
|
const items = $computed(() => userListsCache.value.value ?? []);
|
||||||
|
|
||||||
const pagination = {
|
function fetch() {
|
||||||
endpoint: 'users/lists/list' as const,
|
userListsCache.fetch(() => os.api('users/lists/list'));
|
||||||
noPaging: true,
|
}
|
||||||
limit: 10,
|
|
||||||
};
|
fetch();
|
||||||
|
|
||||||
async function create() {
|
async function create() {
|
||||||
const { canceled, result: name } = await os.inputText({
|
const { canceled, result: name } = await os.inputText({
|
||||||
@ -43,10 +48,18 @@ async function create() {
|
|||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
await os.apiWithDialog('users/lists/create', { name: name });
|
await os.apiWithDialog('users/lists/create', { name: name });
|
||||||
userListsCache.delete();
|
userListsCache.delete();
|
||||||
pagingComponent.reload();
|
fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
const headerActions = $computed(() => []);
|
const headerActions = $computed(() => [{
|
||||||
|
asFullButton: true,
|
||||||
|
icon: 'ti ti-refresh',
|
||||||
|
text: i18n.ts.reload,
|
||||||
|
handler: () => {
|
||||||
|
userListsCache.delete();
|
||||||
|
fetch();
|
||||||
|
},
|
||||||
|
}]);
|
||||||
|
|
||||||
const headerTabs = $computed(() => []);
|
const headerTabs = $computed(() => []);
|
||||||
|
|
||||||
@ -58,6 +71,10 @@ definePageMetadata({
|
|||||||
handler: create,
|
handler: create,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onActivated(() => {
|
||||||
|
fetch();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" module>
|
<style lang="scss" module>
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
import { ref } from "vue";
|
||||||
|
|
||||||
export class Cache<T> {
|
export class Cache<T> {
|
||||||
private cachedAt: number | null = null;
|
private cachedAt: number | null = null;
|
||||||
private value: T | undefined;
|
public value = ref<T | undefined>();
|
||||||
private lifetime: number;
|
private lifetime: number;
|
||||||
|
|
||||||
constructor(lifetime: Cache<never>['lifetime']) {
|
constructor(lifetime: Cache<never>['lifetime']) {
|
||||||
@ -10,21 +11,20 @@ export class Cache<T> {
|
|||||||
|
|
||||||
public set(value: T): void {
|
public set(value: T): void {
|
||||||
this.cachedAt = Date.now();
|
this.cachedAt = Date.now();
|
||||||
this.value = value;
|
this.value.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get(): T | undefined {
|
private get(): T | undefined {
|
||||||
if (this.cachedAt == null) return undefined;
|
if (this.cachedAt == null) return undefined;
|
||||||
if ((Date.now() - this.cachedAt) > this.lifetime) {
|
if ((Date.now() - this.cachedAt) > this.lifetime) {
|
||||||
this.value = undefined;
|
this.value.value = undefined;
|
||||||
this.cachedAt = null;
|
this.cachedAt = null;
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return this.value;
|
return this.value.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public delete() {
|
public delete() {
|
||||||
this.value = undefined;
|
|
||||||
this.cachedAt = null;
|
this.cachedAt = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
|
import { toUnicode } from 'punycode';
|
||||||
import { defineAsyncComponent } from 'vue';
|
import { defineAsyncComponent } from 'vue';
|
||||||
import * as misskey from 'misskey-js';
|
import * as misskey from 'misskey-js';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import copyToClipboard from '@/scripts/copy-to-clipboard';
|
import copyToClipboard from '@/scripts/copy-to-clipboard';
|
||||||
import { host } from '@/config';
|
import { host, url } from '@/config';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { defaultStore, userActions } from '@/store';
|
import { defaultStore, userActions } from '@/store';
|
||||||
import { $i, iAmModerator } from '@/account';
|
import { $i, iAmModerator } from '@/account';
|
||||||
import { mainRouter } from '@/router';
|
import { mainRouter } from '@/router';
|
||||||
import { Router } from '@/nirax';
|
import { Router } from '@/nirax';
|
||||||
import { rolesCache, userListsCache } from '@/cache';
|
import { antennasCache, rolesCache, userListsCache } from '@/cache';
|
||||||
|
|
||||||
export function getUserMenu(user: misskey.entities.UserDetailed, router: Router = mainRouter) {
|
export function getUserMenu(user: misskey.entities.UserDetailed, router: Router = mainRouter) {
|
||||||
const meId = $i ? $i.id : null;
|
const meId = $i ? $i.id : null;
|
||||||
@ -137,6 +138,13 @@ export function getUserMenu(user: misskey.entities.UserDetailed, router: Router
|
|||||||
action: () => {
|
action: () => {
|
||||||
copyToClipboard(`${user.host ?? host}/@${user.username}.atom`);
|
copyToClipboard(`${user.host ?? host}/@${user.username}.atom`);
|
||||||
},
|
},
|
||||||
|
}, {
|
||||||
|
icon: 'ti ti-share',
|
||||||
|
text: i18n.ts.copyProfileUrl,
|
||||||
|
action: () => {
|
||||||
|
const canonical = user.host === null ? `@${user.username}` : `@${user.username}@${toUnicode(user.host)}`;
|
||||||
|
copyToClipboard(`${url}/${canonical}`);
|
||||||
|
},
|
||||||
}, {
|
}, {
|
||||||
icon: 'ti ti-mail',
|
icon: 'ti ti-mail',
|
||||||
text: i18n.ts.sendMessage,
|
text: i18n.ts.sendMessage,
|
||||||
@ -158,11 +166,39 @@ export function getUserMenu(user: misskey.entities.UserDetailed, router: Router
|
|||||||
|
|
||||||
return lists.map(list => ({
|
return lists.map(list => ({
|
||||||
text: list.name,
|
text: list.name,
|
||||||
action: () => {
|
action: async () => {
|
||||||
os.apiWithDialog('users/lists/push', {
|
await os.apiWithDialog('users/lists/push', {
|
||||||
listId: list.id,
|
listId: list.id,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
});
|
});
|
||||||
|
userListsCache.delete();
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
type: 'parent',
|
||||||
|
icon: 'ti ti-antenna',
|
||||||
|
text: i18n.ts.addToAntenna,
|
||||||
|
children: async () => {
|
||||||
|
const antennas = await antennasCache.fetch(() => os.api('antennas/list'));
|
||||||
|
const canonical = user.host === null ? `@${user.username}` : `@${user.username}@${toUnicode(user.host)}`;
|
||||||
|
return antennas.filter((a) => a.src === 'users').map(antenna => ({
|
||||||
|
text: antenna.name,
|
||||||
|
action: async () => {
|
||||||
|
await os.apiWithDialog('antennas/update', {
|
||||||
|
antennaId: antenna.id,
|
||||||
|
name: antenna.name,
|
||||||
|
keywords: antenna.keywords,
|
||||||
|
excludeKeywords: antenna.excludeKeywords,
|
||||||
|
src: antenna.src,
|
||||||
|
userListId: antenna.userListId,
|
||||||
|
users: [...antenna.users, canonical],
|
||||||
|
caseSensitive: antenna.caseSensitive,
|
||||||
|
withReplies: antenna.withReplies,
|
||||||
|
withFile: antenna.withFile,
|
||||||
|
notify: antenna.notify,
|
||||||
|
});
|
||||||
|
antennasCache.delete();
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
@ -72,7 +72,7 @@ html {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.useSystemFont {
|
&.useSystemFont {
|
||||||
font-family: 'Hiragino Maru Gothic Pro', sans-serif;
|
font-family: system-ui;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
const esbuild = require('esbuild');
|
import { fileURLToPath } from 'node:url';
|
||||||
const locales = require('../../locales');
|
import * as esbuild from 'esbuild';
|
||||||
const meta = require('../../package.json');
|
import locales from '../../locales/index.js';
|
||||||
|
import meta from '../../package.json' assert { type: "json" };
|
||||||
const watch = process.argv[2]?.includes('watch');
|
const watch = process.argv[2]?.includes('watch');
|
||||||
|
|
||||||
|
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
||||||
|
|
||||||
console.log('Starting SW building...');
|
console.log('Starting SW building...');
|
||||||
|
|
||||||
/** @type {esbuild.BuildOptions} */
|
/** @type {esbuild.BuildOptions} */
|
||||||
|
@ -19,5 +19,6 @@
|
|||||||
"eslint": "8.44.0",
|
"eslint": "8.44.0",
|
||||||
"eslint-plugin-import": "2.27.5",
|
"eslint-plugin-import": "2.27.5",
|
||||||
"typescript": "5.1.6"
|
"typescript": "5.1.6"
|
||||||
}
|
},
|
||||||
|
"type": "module"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user