Merge branch 'develop' into acid-chicken-patch-1

This commit is contained in:
Acid Chicken (硫酸鶏) 2023-03-31 16:41:55 +09:00 committed by GitHub
commit 13a406b6cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 4491 additions and 4444 deletions

View file

@ -18,6 +18,19 @@
--> -->
## 13.x.x (unreleased)
### General
- チャンネルをお気に入りに登録できるように
- チャンネルにノートをピン留めできるように
### Client
- 検索ページでURLを入力した際に照会したときと同等の挙動をするように
- ノートのリアクションを大きく表示するオプションを追加
### Server
-
## 13.10.3 ## 13.10.3
### Changes ### Changes

View file

@ -983,6 +983,8 @@ retryAllQueuesConfirmText: "一時的にサーバーの負荷が増大するこ
enableChartsForRemoteUser: "リモートユーザーのチャートを生成" enableChartsForRemoteUser: "リモートユーザーのチャートを生成"
enableChartsForFederatedInstances: "リモートサーバーのチャートを生成" enableChartsForFederatedInstances: "リモートサーバーのチャートを生成"
showClipButtonInNoteFooter: "ノートのアクションにクリップを追加" showClipButtonInNoteFooter: "ノートのアクションにクリップを追加"
largeNoteReactions: "ノートのリアクションを大きく表示"
noteIdOrUrl: "ートIDまたはURL"
_achievements: _achievements:
earnedAt: "獲得日時" earnedAt: "獲得日時"

View file

@ -6,7 +6,7 @@
"type": "git", "type": "git",
"url": "https://github.com/misskey-dev/misskey.git" "url": "https://github.com/misskey-dev/misskey.git"
}, },
"packageManager": "pnpm@7.29.3", "packageManager": "pnpm@8.1.0",
"workspaces": [ "workspaces": [
"packages/frontend", "packages/frontend",
"packages/backend", "packages/backend",
@ -50,16 +50,16 @@
"gulp-replace": "1.1.4", "gulp-replace": "1.1.4",
"gulp-terser": "2.1.0", "gulp-terser": "2.1.0",
"js-yaml": "4.1.0", "js-yaml": "4.1.0",
"typescript": "4.9.5" "typescript": "5.0.2"
}, },
"devDependencies": { "devDependencies": {
"@types/gulp": "4.0.10", "@types/gulp": "4.0.10",
"@types/gulp-rename": "2.0.1", "@types/gulp-rename": "2.0.1",
"@typescript-eslint/eslint-plugin": "5.54.1", "@typescript-eslint/eslint-plugin": "5.57.0",
"@typescript-eslint/parser": "5.54.1", "@typescript-eslint/parser": "5.57.0",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"cypress": "12.7.0", "cypress": "12.9.0",
"eslint": "8.35.0", "eslint": "8.37.0",
"start-server-and-test": "2.0.0" "start-server-and-test": "2.0.0"
}, },
"optionalDependencies": { "optionalDependencies": {

View file

@ -0,0 +1,21 @@
export class channelFavorite1680228513388 {
name = 'channelFavorite1680228513388'
async up(queryRunner) {
await queryRunner.query(`CREATE TABLE "channel_favorite" ("id" character varying(32) NOT NULL, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "channelId" character varying(32) NOT NULL, "userId" character varying(32) NOT NULL, CONSTRAINT "PK_59bddfd54d48689a298d41af00c" PRIMARY KEY ("id")); COMMENT ON COLUMN "channel_favorite"."createdAt" IS 'The created date of the ChannelFavorite.'`);
await queryRunner.query(`CREATE INDEX "IDX_735a5544f9249d412255f47f95" ON "channel_favorite" ("createdAt") `);
await queryRunner.query(`CREATE INDEX "IDX_d3ca0db011b75ac2a940a2337d" ON "channel_favorite" ("channelId") `);
await queryRunner.query(`CREATE INDEX "IDX_8302bd27226605ece14842fb25" ON "channel_favorite" ("userId") `);
await queryRunner.query(`ALTER TABLE "channel_favorite" ADD CONSTRAINT "FK_d3ca0db011b75ac2a940a2337d2" FOREIGN KEY ("channelId") REFERENCES "channel"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "channel_favorite" ADD CONSTRAINT "FK_8302bd27226605ece14842fb25a" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "channel_favorite" DROP CONSTRAINT "FK_8302bd27226605ece14842fb25a"`);
await queryRunner.query(`ALTER TABLE "channel_favorite" DROP CONSTRAINT "FK_d3ca0db011b75ac2a940a2337d2"`);
await queryRunner.query(`DROP INDEX "public"."IDX_8302bd27226605ece14842fb25"`);
await queryRunner.query(`DROP INDEX "public"."IDX_d3ca0db011b75ac2a940a2337d"`);
await queryRunner.query(`DROP INDEX "public"."IDX_735a5544f9249d412255f47f95"`);
await queryRunner.query(`DROP TABLE "channel_favorite"`);
}
}

View file

@ -0,0 +1,11 @@
export class channelNotePining1680238118084 {
name = 'channelNotePining1680238118084'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "channel" ADD "pinnedNoteIds" character varying(128) array NOT NULL DEFAULT '{}'`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "channel" DROP COLUMN "pinnedNoteIds"`);
}
}

View file

@ -23,41 +23,41 @@
}, },
"optionalDependencies": { "optionalDependencies": {
"@swc/core-android-arm64": "^1.3.11", "@swc/core-android-arm64": "^1.3.11",
"@swc/core-darwin-arm64": "^1.3.38", "@swc/core-darwin-arm64": "^1.3.42",
"@swc/core-darwin-x64": "^1.3.38", "@swc/core-darwin-x64": "^1.3.42",
"@swc/core-linux-arm-gnueabihf": "^1.3.38", "@swc/core-linux-arm-gnueabihf": "^1.3.42",
"@swc/core-linux-arm64-gnu": "^1.3.38", "@swc/core-linux-arm64-gnu": "^1.3.42",
"@swc/core-linux-arm64-musl": "^1.3.38", "@swc/core-linux-arm64-musl": "^1.3.42",
"@swc/core-linux-x64-gnu": "^1.3.38", "@swc/core-linux-x64-gnu": "^1.3.42",
"@swc/core-linux-x64-musl": "^1.3.38", "@swc/core-linux-x64-musl": "^1.3.42",
"@swc/core-win32-arm64-msvc": "^1.3.38", "@swc/core-win32-arm64-msvc": "^1.3.42",
"@swc/core-win32-ia32-msvc": "^1.3.38", "@swc/core-win32-ia32-msvc": "^1.3.42",
"@swc/core-win32-x64-msvc": "^1.3.38", "@swc/core-win32-x64-msvc": "^1.3.42",
"@tensorflow/tfjs": "4.2.0", "@tensorflow/tfjs": "4.2.0",
"@tensorflow/tfjs-node": "4.2.0" "@tensorflow/tfjs-node": "4.2.0"
}, },
"dependencies": { "dependencies": {
"@aws-sdk/client-s3": "^3.294.0", "@aws-sdk/client-s3": "3.301.0",
"@aws-sdk/lib-storage": "^3.294.0", "@aws-sdk/lib-storage": "3.301.0",
"@aws-sdk/node-http-handler": "^3.292.0", "@aws-sdk/node-http-handler": "3.296.0",
"@bull-board/api": "5.0.0", "@bull-board/api": "5.0.0",
"@bull-board/fastify": "5.0.0", "@bull-board/fastify": "5.0.0",
"@bull-board/ui": "5.0.0", "@bull-board/ui": "5.0.0",
"@discordapp/twemoji": "14.0.2", "@discordapp/twemoji": "14.1.2",
"@fastify/accepts": "4.1.0", "@fastify/accepts": "4.1.0",
"@fastify/cookie": "8.3.0", "@fastify/cookie": "8.3.0",
"@fastify/cors": "8.2.0", "@fastify/cors": "8.2.1",
"@fastify/http-proxy": "8.4.0", "@fastify/http-proxy": "9.0.0",
"@fastify/multipart": "7.4.2", "@fastify/multipart": "7.5.0",
"@fastify/static": "6.9.0", "@fastify/static": "6.9.0",
"@fastify/view": "7.4.1", "@fastify/view": "7.4.1",
"@nestjs/common": "9.3.9", "@nestjs/common": "9.3.12",
"@nestjs/core": "9.3.9", "@nestjs/core": "9.3.12",
"@nestjs/testing": "9.3.9", "@nestjs/testing": "9.3.12",
"@peertube/http-signature": "1.7.0", "@peertube/http-signature": "1.7.0",
"@sinonjs/fake-timers": "10.0.2", "@sinonjs/fake-timers": "10.0.2",
"@swc/cli": "0.1.62", "@swc/cli": "0.1.62",
"@swc/core": "1.3.38", "@swc/core": "1.3.42",
"accepts": "1.3.8", "accepts": "1.3.8",
"ajv": "8.12.0", "ajv": "8.12.0",
"archiver": "5.3.1", "archiver": "5.3.1",
@ -76,7 +76,7 @@
"date-fns": "2.29.3", "date-fns": "2.29.3",
"deep-email-validator": "0.1.21", "deep-email-validator": "0.1.21",
"escape-regexp": "0.0.1", "escape-regexp": "0.0.1",
"fastify": "4.14.1", "fastify": "4.15.0",
"feed": "4.2.2", "feed": "4.2.2",
"file-type": "18.2.1", "file-type": "18.2.1",
"fluent-ffmpeg": "2.1.2", "fluent-ffmpeg": "2.1.2",
@ -88,21 +88,21 @@
"ip-cidr": "3.1.0", "ip-cidr": "3.1.0",
"is-svg": "4.3.2", "is-svg": "4.3.2",
"js-yaml": "4.1.0", "js-yaml": "4.1.0",
"jsdom": "21.1.0", "jsdom": "21.1.1",
"json5": "2.2.3", "json5": "2.2.3",
"jsonld": "8.1.1", "jsonld": "8.1.1",
"jsrsasign": "10.6.1", "jsrsasign": "10.7.0",
"mfm-js": "0.23.3", "mfm-js": "0.23.3",
"mime-types": "2.1.35", "mime-types": "2.1.35",
"misskey-js": "../misskey-js", "misskey-js": "workspace:*",
"ms": "3.0.0-canary.1", "ms": "3.0.0-canary.1",
"nested-property": "4.0.0", "nested-property": "4.0.0",
"node-fetch": "3.3.0", "node-fetch": "3.3.1",
"nodemailer": "6.9.1", "nodemailer": "6.9.1",
"nsfwjs": "2.4.2", "nsfwjs": "2.4.2",
"oauth": "0.10.0", "oauth": "0.10.0",
"os-utils": "0.0.14", "os-utils": "0.0.14",
"otpauth": "^9.0.2", "otpauth": "9.1.1",
"parse5": "7.1.2", "parse5": "7.1.2",
"pg": "8.10.0", "pg": "8.10.0",
"private-ip": "3.0.0", "private-ip": "3.0.0",
@ -125,7 +125,7 @@
"sanitize-html": "2.10.0", "sanitize-html": "2.10.0",
"seedrandom": "3.0.5", "seedrandom": "3.0.5",
"semver": "7.3.8", "semver": "7.3.8",
"sharp": "0.31.3", "sharp": "0.32.0",
"sharp-read-bmp": "github:misskey-dev/sharp-read-bmp", "sharp-read-bmp": "github:misskey-dev/sharp-read-bmp",
"strict-event-emitter-types": "2.0.0", "strict-event-emitter-types": "2.0.0",
"stringz": "2.1.0", "stringz": "2.1.0",
@ -133,25 +133,25 @@
"systeminformation": "5.17.12", "systeminformation": "5.17.12",
"tinycolor2": "1.6.0", "tinycolor2": "1.6.0",
"tmp": "0.2.1", "tmp": "0.2.1",
"tsc-alias": "1.8.3", "tsc-alias": "1.8.5",
"tsconfig-paths": "4.1.2", "tsconfig-paths": "4.2.0",
"twemoji-parser": "14.0.0", "twemoji-parser": "14.0.0",
"typeorm": "0.3.11", "typeorm": "0.3.11",
"typescript": "4.9.5", "typescript": "5.0.2",
"ulid": "2.3.0", "ulid": "2.3.0",
"unzipper": "0.10.11", "unzipper": "0.10.11",
"uuid": "9.0.0", "uuid": "9.0.0",
"vary": "1.1.2", "vary": "1.1.2",
"web-push": "3.5.0", "web-push": "3.5.0",
"websocket": "1.0.34", "websocket": "1.0.34",
"ws": "8.12.1", "ws": "8.13.0",
"xev": "3.0.2" "xev": "3.0.2"
}, },
"devDependencies": { "devDependencies": {
"@jest/globals": "29.5.0", "@jest/globals": "29.5.0",
"@swc/jest": "0.2.24", "@swc/jest": "0.2.24",
"@types/accepts": "1.3.5", "@types/accepts": "1.3.5",
"@types/archiver": "5.3.1", "@types/archiver": "5.3.2",
"@types/bcryptjs": "2.4.2", "@types/bcryptjs": "2.4.2",
"@types/bull": "4.10.0", "@types/bull": "4.10.0",
"@types/cbor": "6.0.0", "@types/cbor": "6.0.0",
@ -160,13 +160,13 @@
"@types/escape-regexp": "0.0.1", "@types/escape-regexp": "0.0.1",
"@types/fluent-ffmpeg": "2.1.21", "@types/fluent-ffmpeg": "2.1.21",
"@types/ioredis": "4.28.10", "@types/ioredis": "4.28.10",
"@types/jest": "29.4.0", "@types/jest": "29.5.0",
"@types/js-yaml": "4.0.5", "@types/js-yaml": "4.0.5",
"@types/jsdom": "21.1.0", "@types/jsdom": "21.1.1",
"@types/jsonld": "1.5.8", "@types/jsonld": "1.5.8",
"@types/jsrsasign": "10.5.5", "@types/jsrsasign": "10.5.8",
"@types/mime-types": "2.1.1", "@types/mime-types": "2.1.1",
"@types/node": "18.15.0", "@types/node": "18.15.11",
"@types/node-fetch": "3.0.3", "@types/node-fetch": "3.0.3",
"@types/nodemailer": "6.4.7", "@types/nodemailer": "6.4.7",
"@types/oauth": "0.9.1", "@types/oauth": "0.9.1",
@ -178,7 +178,7 @@
"@types/ratelimiter": "3.4.4", "@types/ratelimiter": "3.4.4",
"@types/redis": "4.0.11", "@types/redis": "4.0.11",
"@types/rename": "1.0.4", "@types/rename": "1.0.4",
"@types/sanitize-html": "2.8.1", "@types/sanitize-html": "2.9.0",
"@types/semver": "7.3.13", "@types/semver": "7.3.13",
"@types/sharp": "0.31.1", "@types/sharp": "0.31.1",
"@types/sinonjs__fake-timers": "8.1.2", "@types/sinonjs__fake-timers": "8.1.2",
@ -190,11 +190,11 @@
"@types/web-push": "3.3.2", "@types/web-push": "3.3.2",
"@types/websocket": "1.0.5", "@types/websocket": "1.0.5",
"@types/ws": "8.5.4", "@types/ws": "8.5.4",
"@typescript-eslint/eslint-plugin": "5.54.1", "@typescript-eslint/eslint-plugin": "5.57.0",
"@typescript-eslint/parser": "5.54.1", "@typescript-eslint/parser": "5.57.0",
"aws-sdk-client-mock": "^2.1.1", "aws-sdk-client-mock": "^2.1.1",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"eslint": "8.35.0", "eslint": "8.37.0",
"eslint-plugin-import": "2.27.5", "eslint-plugin-import": "2.27.5",
"execa": "6.1.0", "execa": "6.1.0",
"jest": "29.5.0", "jest": "29.5.0",

View file

@ -1,13 +1,14 @@
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import type { ChannelFollowingsRepository, ChannelsRepository, DriveFilesRepository, NoteUnreadsRepository } from '@/models/index.js'; import type { ChannelFavoritesRepository, ChannelFollowingsRepository, ChannelsRepository, DriveFilesRepository, NoteUnreadsRepository, NotesRepository } from '@/models/index.js';
import type { Packed } from '@/misc/json-schema.js'; import type { Packed } from '@/misc/json-schema.js';
import type { } from '@/models/entities/Blocking.js'; import type { } from '@/models/entities/Blocking.js';
import type { User } from '@/models/entities/User.js'; import type { User } from '@/models/entities/User.js';
import type { Channel } from '@/models/entities/Channel.js'; import type { Channel } from '@/models/entities/Channel.js';
import { bindThis } from '@/decorators.js'; import { bindThis } from '@/decorators.js';
import { UserEntityService } from './UserEntityService.js';
import { DriveFileEntityService } from './DriveFileEntityService.js'; import { DriveFileEntityService } from './DriveFileEntityService.js';
import { NoteEntityService } from './NoteEntityService.js';
import { In } from 'typeorm';
@Injectable() @Injectable()
export class ChannelEntityService { export class ChannelEntityService {
@ -18,13 +19,19 @@ export class ChannelEntityService {
@Inject(DI.channelFollowingsRepository) @Inject(DI.channelFollowingsRepository)
private channelFollowingsRepository: ChannelFollowingsRepository, private channelFollowingsRepository: ChannelFollowingsRepository,
@Inject(DI.channelFavoritesRepository)
private channelFavoritesRepository: ChannelFavoritesRepository,
@Inject(DI.notesRepository)
private notesRepository: NotesRepository,
@Inject(DI.noteUnreadsRepository) @Inject(DI.noteUnreadsRepository)
private noteUnreadsRepository: NoteUnreadsRepository, private noteUnreadsRepository: NoteUnreadsRepository,
@Inject(DI.driveFilesRepository) @Inject(DI.driveFilesRepository)
private driveFilesRepository: DriveFilesRepository, private driveFilesRepository: DriveFilesRepository,
private userEntityService: UserEntityService, private noteEntityService: NoteEntityService,
private driveFileEntityService: DriveFileEntityService, private driveFileEntityService: DriveFileEntityService,
) { ) {
} }
@ -33,6 +40,7 @@ export class ChannelEntityService {
public async pack( public async pack(
src: Channel['id'] | Channel, src: Channel['id'] | Channel,
me?: { id: User['id'] } | null | undefined, me?: { id: User['id'] } | null | undefined,
detailed?: boolean,
): Promise<Packed<'Channel'>> { ): Promise<Packed<'Channel'>> {
const channel = typeof src === 'object' ? src : await this.channelsRepository.findOneByOrFail({ id: src }); const channel = typeof src === 'object' ? src : await this.channelsRepository.findOneByOrFail({ id: src });
const meId = me ? me.id : null; const meId = me ? me.id : null;
@ -46,6 +54,17 @@ export class ChannelEntityService {
followeeId: channel.id, followeeId: channel.id,
}) : null; }) : null;
const favorite = meId ? await this.channelFavoritesRepository.findOneBy({
userId: meId,
channelId: channel.id,
}) : null;
const pinnedNotes = channel.pinnedNoteIds.length > 0 ? await this.notesRepository.find({
where: {
id: In(channel.pinnedNoteIds),
},
}) : [];
return { return {
id: channel.id, id: channel.id,
createdAt: channel.createdAt.toISOString(), createdAt: channel.createdAt.toISOString(),
@ -54,13 +73,19 @@ export class ChannelEntityService {
description: channel.description, description: channel.description,
userId: channel.userId, userId: channel.userId,
bannerUrl: banner ? this.driveFileEntityService.getPublicUrl(banner) : null, bannerUrl: banner ? this.driveFileEntityService.getPublicUrl(banner) : null,
pinnedNoteIds: channel.pinnedNoteIds,
usersCount: channel.usersCount, usersCount: channel.usersCount,
notesCount: channel.notesCount, notesCount: channel.notesCount,
...(me ? { ...(me ? {
isFollowing: following != null, isFollowing: following != null,
isFavorited: favorite != null,
hasUnreadNote, hasUnreadNote,
} : {}), } : {}),
...(detailed ? {
pinnedNotes: await this.noteEntityService.packMany(pinnedNotes, me),
} : {}),
}; };
} }
} }

View file

@ -61,7 +61,7 @@ export const DI = {
mutedNotesRepository: Symbol('mutedNotesRepository'), mutedNotesRepository: Symbol('mutedNotesRepository'),
channelsRepository: Symbol('channelsRepository'), channelsRepository: Symbol('channelsRepository'),
channelFollowingsRepository: Symbol('channelFollowingsRepository'), channelFollowingsRepository: Symbol('channelFollowingsRepository'),
channelNotePiningsRepository: Symbol('channelNotePiningsRepository'), channelFavoritesRepository: Symbol('channelFavoritesRepository'),
registryItemsRepository: Symbol('registryItemsRepository'), registryItemsRepository: Symbol('registryItemsRepository'),
webhooksRepository: Symbol('webhooksRepository'), webhooksRepository: Symbol('webhooksRepository'),
adsRepository: Symbol('adsRepository'), adsRepository: Symbol('adsRepository'),

View file

@ -1,6 +1,6 @@
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import { User, Note, Announcement, AnnouncementRead, App, NoteFavorite, NoteThreadMuting, NoteReaction, NoteUnread, Notification, Poll, PollVote, UserProfile, UserKeypair, UserPending, AttestationChallenge, UserSecurityKey, UserPublickey, UserList, UserListJoining, UserNotePining, UserIp, UsedUsername, Following, FollowRequest, Instance, Emoji, DriveFile, DriveFolder, Meta, Muting, RenoteMuting, Blocking, SwSubscription, Hashtag, AbuseUserReport, RegistrationTicket, AuthSession, AccessToken, Signin, Page, PageLike, GalleryPost, GalleryLike, ModerationLog, Clip, ClipNote, Antenna, AntennaNote, PromoNote, PromoRead, Relay, MutedNote, Channel, ChannelFollowing, ChannelNotePining, RegistryItem, Webhook, Ad, PasswordResetRequest, RetentionAggregation, FlashLike, Flash, Role, RoleAssignment, ClipFavorite } from './index.js'; import { User, Note, Announcement, AnnouncementRead, App, NoteFavorite, NoteThreadMuting, NoteReaction, NoteUnread, Notification, Poll, PollVote, UserProfile, UserKeypair, UserPending, AttestationChallenge, UserSecurityKey, UserPublickey, UserList, UserListJoining, UserNotePining, UserIp, UsedUsername, Following, FollowRequest, Instance, Emoji, DriveFile, DriveFolder, Meta, Muting, RenoteMuting, Blocking, SwSubscription, Hashtag, AbuseUserReport, RegistrationTicket, AuthSession, AccessToken, Signin, Page, PageLike, GalleryPost, GalleryLike, ModerationLog, Clip, ClipNote, Antenna, AntennaNote, PromoNote, PromoRead, Relay, MutedNote, Channel, ChannelFollowing, ChannelFavorite, RegistryItem, Webhook, Ad, PasswordResetRequest, RetentionAggregation, FlashLike, Flash, Role, RoleAssignment, ClipFavorite } from './index.js';
import type { DataSource } from 'typeorm'; import type { DataSource } from 'typeorm';
import type { Provider } from '@nestjs/common'; import type { Provider } from '@nestjs/common';
@ -340,9 +340,9 @@ const $channelFollowingsRepository: Provider = {
inject: [DI.db], inject: [DI.db],
}; };
const $channelNotePiningsRepository: Provider = { const $channelFavoritesRepository: Provider = {
provide: DI.channelNotePiningsRepository, provide: DI.channelFavoritesRepository,
useFactory: (db: DataSource) => db.getRepository(ChannelNotePining), useFactory: (db: DataSource) => db.getRepository(ChannelFavorite),
inject: [DI.db], inject: [DI.db],
}; };
@ -460,7 +460,7 @@ const $roleAssignmentsRepository: Provider = {
$mutedNotesRepository, $mutedNotesRepository,
$channelsRepository, $channelsRepository,
$channelFollowingsRepository, $channelFollowingsRepository,
$channelNotePiningsRepository, $channelFavoritesRepository,
$registryItemsRepository, $registryItemsRepository,
$webhooksRepository, $webhooksRepository,
$adsRepository, $adsRepository,
@ -528,7 +528,7 @@ const $roleAssignmentsRepository: Provider = {
$mutedNotesRepository, $mutedNotesRepository,
$channelsRepository, $channelsRepository,
$channelFollowingsRepository, $channelFollowingsRepository,
$channelNotePiningsRepository, $channelFavoritesRepository,
$registryItemsRepository, $registryItemsRepository,
$webhooksRepository, $webhooksRepository,
$adsRepository, $adsRepository,

View file

@ -59,6 +59,11 @@ export class Channel {
@JoinColumn() @JoinColumn()
public banner: DriveFile | null; public banner: DriveFile | null;
@Column('varchar', {
array: true, length: 128, default: '{}',
})
public pinnedNoteIds: string[];
@Index() @Index()
@Column('integer', { @Column('integer', {
default: 0, default: 0,

View file

@ -1,21 +1,24 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm'; import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
import { id } from '../id.js'; import { id } from '../id.js';
import { Note } from './Note.js'; import { User } from './User.js';
import { Channel } from './Channel.js'; import { Channel } from './Channel.js';
@Entity() @Entity()
@Index(['channelId', 'noteId'], { unique: true }) @Index(['userId', 'channelId'], { unique: true })
export class ChannelNotePining { export class ChannelFavorite {
@PrimaryColumn(id()) @PrimaryColumn(id())
public id: string; public id: string;
@Index()
@Column('timestamp with time zone', { @Column('timestamp with time zone', {
comment: 'The created date of the ChannelNotePining.', comment: 'The created date of the ChannelFavorite.',
}) })
public createdAt: Date; public createdAt: Date;
@Index() @Index()
@Column(id()) @Column({
...id(),
})
public channelId: Channel['id']; public channelId: Channel['id'];
@ManyToOne(type => Channel, { @ManyToOne(type => Channel, {
@ -24,12 +27,15 @@ export class ChannelNotePining {
@JoinColumn() @JoinColumn()
public channel: Channel | null; public channel: Channel | null;
@Column(id()) @Index()
public noteId: Note['id']; @Column({
...id(),
})
public userId: User['id'];
@ManyToOne(type => Note, { @ManyToOne(type => User, {
onDelete: 'CASCADE', onDelete: 'CASCADE',
}) })
@JoinColumn() @JoinColumn()
public note: Note | null; public user: User | null;
} }

View file

@ -10,7 +10,7 @@ import { AttestationChallenge } from '@/models/entities/AttestationChallenge.js'
import { AuthSession } from '@/models/entities/AuthSession.js'; import { AuthSession } from '@/models/entities/AuthSession.js';
import { Blocking } from '@/models/entities/Blocking.js'; import { Blocking } from '@/models/entities/Blocking.js';
import { ChannelFollowing } from '@/models/entities/ChannelFollowing.js'; import { ChannelFollowing } from '@/models/entities/ChannelFollowing.js';
import { ChannelNotePining } from '@/models/entities/ChannelNotePining.js'; import { ChannelFavorite } from '@/models/entities/ChannelFavorite.js';
import { Clip } from '@/models/entities/Clip.js'; import { Clip } from '@/models/entities/Clip.js';
import { ClipNote } from '@/models/entities/ClipNote.js'; import { ClipNote } from '@/models/entities/ClipNote.js';
import { ClipFavorite } from '@/models/entities/ClipFavorite.js'; import { ClipFavorite } from '@/models/entities/ClipFavorite.js';
@ -79,7 +79,7 @@ export {
AuthSession, AuthSession,
Blocking, Blocking,
ChannelFollowing, ChannelFollowing,
ChannelNotePining, ChannelFavorite,
Clip, Clip,
ClipNote, ClipNote,
ClipFavorite, ClipFavorite,
@ -147,7 +147,7 @@ export type AttestationChallengesRepository = Repository<AttestationChallenge>;
export type AuthSessionsRepository = Repository<AuthSession>; export type AuthSessionsRepository = Repository<AuthSession>;
export type BlockingsRepository = Repository<Blocking>; export type BlockingsRepository = Repository<Blocking>;
export type ChannelFollowingsRepository = Repository<ChannelFollowing>; export type ChannelFollowingsRepository = Repository<ChannelFollowing>;
export type ChannelNotePiningsRepository = Repository<ChannelNotePining>; export type ChannelFavoritesRepository = Repository<ChannelFavorite>;
export type ClipsRepository = Repository<Clip>; export type ClipsRepository = Repository<Clip>;
export type ClipNotesRepository = Repository<ClipNote>; export type ClipNotesRepository = Repository<ClipNote>;
export type ClipFavoritesRepository = Repository<ClipFavorite>; export type ClipFavoritesRepository = Repository<ClipFavorite>;

View file

@ -42,10 +42,22 @@ export const packedChannelSchema = {
type: 'boolean', type: 'boolean',
optional: true, nullable: false, optional: true, nullable: false,
}, },
isFavorited: {
type: 'boolean',
optional: true, nullable: false,
},
userId: { userId: {
type: 'string', type: 'string',
nullable: true, optional: false, nullable: true, optional: false,
format: 'id', format: 'id',
}, },
pinnedNoteIds: {
type: 'array',
nullable: false, optional: false,
items: {
type: 'string',
format: 'id',
},
},
}, },
} as const; } as const;

View file

@ -18,7 +18,7 @@ import { AttestationChallenge } from '@/models/entities/AttestationChallenge.js'
import { AuthSession } from '@/models/entities/AuthSession.js'; import { AuthSession } from '@/models/entities/AuthSession.js';
import { Blocking } from '@/models/entities/Blocking.js'; import { Blocking } from '@/models/entities/Blocking.js';
import { ChannelFollowing } from '@/models/entities/ChannelFollowing.js'; import { ChannelFollowing } from '@/models/entities/ChannelFollowing.js';
import { ChannelNotePining } from '@/models/entities/ChannelNotePining.js'; import { ChannelFavorite } from '@/models/entities/ChannelFavorite.js';
import { Clip } from '@/models/entities/Clip.js'; import { Clip } from '@/models/entities/Clip.js';
import { ClipNote } from '@/models/entities/ClipNote.js'; import { ClipNote } from '@/models/entities/ClipNote.js';
import { ClipFavorite } from '@/models/entities/ClipFavorite.js'; import { ClipFavorite } from '@/models/entities/ClipFavorite.js';
@ -175,7 +175,7 @@ export const entities = [
MutedNote, MutedNote,
Channel, Channel,
ChannelFollowing, ChannelFollowing,
ChannelNotePining, ChannelFavorite,
RegistryItem, RegistryItem,
Ad, Ad,
PasswordResetRequest, PasswordResetRequest,

View file

@ -95,6 +95,9 @@ import * as ep___channels_show from './endpoints/channels/show.js';
import * as ep___channels_timeline from './endpoints/channels/timeline.js'; import * as ep___channels_timeline from './endpoints/channels/timeline.js';
import * as ep___channels_unfollow from './endpoints/channels/unfollow.js'; import * as ep___channels_unfollow from './endpoints/channels/unfollow.js';
import * as ep___channels_update from './endpoints/channels/update.js'; import * as ep___channels_update from './endpoints/channels/update.js';
import * as ep___channels_favorite from './endpoints/channels/favorite.js';
import * as ep___channels_unfavorite from './endpoints/channels/unfavorite.js';
import * as ep___channels_myFavorites from './endpoints/channels/my-favorites.js';
import * as ep___charts_activeUsers from './endpoints/charts/active-users.js'; import * as ep___charts_activeUsers from './endpoints/charts/active-users.js';
import * as ep___charts_apRequest from './endpoints/charts/ap-request.js'; import * as ep___charts_apRequest from './endpoints/charts/ap-request.js';
import * as ep___charts_drive from './endpoints/charts/drive.js'; import * as ep___charts_drive from './endpoints/charts/drive.js';
@ -424,6 +427,9 @@ const $channels_show: Provider = { provide: 'ep:channels/show', useClass: ep___c
const $channels_timeline: Provider = { provide: 'ep:channels/timeline', useClass: ep___channels_timeline.default }; const $channels_timeline: Provider = { provide: 'ep:channels/timeline', useClass: ep___channels_timeline.default };
const $channels_unfollow: Provider = { provide: 'ep:channels/unfollow', useClass: ep___channels_unfollow.default }; const $channels_unfollow: Provider = { provide: 'ep:channels/unfollow', useClass: ep___channels_unfollow.default };
const $channels_update: Provider = { provide: 'ep:channels/update', useClass: ep___channels_update.default }; const $channels_update: Provider = { provide: 'ep:channels/update', useClass: ep___channels_update.default };
const $channels_favorite: Provider = { provide: 'ep:channels/favorite', useClass: ep___channels_favorite.default };
const $channels_unfavorite: Provider = { provide: 'ep:channels/unfavorite', useClass: ep___channels_unfavorite.default };
const $channels_myFavorites: Provider = { provide: 'ep:channels/my-favorites', useClass: ep___channels_myFavorites.default };
const $charts_activeUsers: Provider = { provide: 'ep:charts/active-users', useClass: ep___charts_activeUsers.default }; const $charts_activeUsers: Provider = { provide: 'ep:charts/active-users', useClass: ep___charts_activeUsers.default };
const $charts_apRequest: Provider = { provide: 'ep:charts/ap-request', useClass: ep___charts_apRequest.default }; const $charts_apRequest: Provider = { provide: 'ep:charts/ap-request', useClass: ep___charts_apRequest.default };
const $charts_drive: Provider = { provide: 'ep:charts/drive', useClass: ep___charts_drive.default }; const $charts_drive: Provider = { provide: 'ep:charts/drive', useClass: ep___charts_drive.default };
@ -757,6 +763,9 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention
$channels_timeline, $channels_timeline,
$channels_unfollow, $channels_unfollow,
$channels_update, $channels_update,
$channels_favorite,
$channels_unfavorite,
$channels_myFavorites,
$charts_activeUsers, $charts_activeUsers,
$charts_apRequest, $charts_apRequest,
$charts_drive, $charts_drive,
@ -1084,6 +1093,9 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention
$channels_timeline, $channels_timeline,
$channels_unfollow, $channels_unfollow,
$channels_update, $channels_update,
$channels_favorite,
$channels_unfavorite,
$channels_myFavorites,
$charts_activeUsers, $charts_activeUsers,
$charts_apRequest, $charts_apRequest,
$charts_drive, $charts_drive,

View file

@ -95,6 +95,9 @@ import * as ep___channels_show from './endpoints/channels/show.js';
import * as ep___channels_timeline from './endpoints/channels/timeline.js'; import * as ep___channels_timeline from './endpoints/channels/timeline.js';
import * as ep___channels_unfollow from './endpoints/channels/unfollow.js'; import * as ep___channels_unfollow from './endpoints/channels/unfollow.js';
import * as ep___channels_update from './endpoints/channels/update.js'; import * as ep___channels_update from './endpoints/channels/update.js';
import * as ep___channels_favorite from './endpoints/channels/favorite.js';
import * as ep___channels_unfavorite from './endpoints/channels/unfavorite.js';
import * as ep___channels_myFavorites from './endpoints/channels/my-favorites.js';
import * as ep___charts_activeUsers from './endpoints/charts/active-users.js'; import * as ep___charts_activeUsers from './endpoints/charts/active-users.js';
import * as ep___charts_apRequest from './endpoints/charts/ap-request.js'; import * as ep___charts_apRequest from './endpoints/charts/ap-request.js';
import * as ep___charts_drive from './endpoints/charts/drive.js'; import * as ep___charts_drive from './endpoints/charts/drive.js';
@ -422,6 +425,9 @@ const eps = [
['channels/timeline', ep___channels_timeline], ['channels/timeline', ep___channels_timeline],
['channels/unfollow', ep___channels_unfollow], ['channels/unfollow', ep___channels_unfollow],
['channels/update', ep___channels_update], ['channels/update', ep___channels_update],
['channels/favorite', ep___channels_favorite],
['channels/unfavorite', ep___channels_unfavorite],
['channels/my-favorites', ep___channels_myFavorites],
['charts/active-users', ep___charts_activeUsers], ['charts/active-users', ep___charts_activeUsers],
['charts/ap-request', ep___charts_apRequest], ['charts/ap-request', ep___charts_apRequest],
['charts/drive', ep___charts_drive], ['charts/drive', ep___charts_drive],

View file

@ -0,0 +1,61 @@
import { Inject, Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
import type { ChannelFavoritesRepository, ChannelsRepository } from '@/models/index.js';
import { IdService } from '@/core/IdService.js';
import { DI } from '@/di-symbols.js';
import { ApiError } from '../../error.js';
export const meta = {
tags: ['channels'],
requireCredential: true,
kind: 'write:channels',
errors: {
noSuchChannel: {
message: 'No such channel.',
code: 'NO_SUCH_CHANNEL',
id: '4938f5f3-6167-4c04-9149-6607b7542861',
},
},
} as const;
export const paramDef = {
type: 'object',
properties: {
channelId: { type: 'string', format: 'misskey:id' },
},
required: ['channelId'],
} as const;
// eslint-disable-next-line import/no-default-export
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> {
constructor(
@Inject(DI.channelsRepository)
private channelsRepository: ChannelsRepository,
@Inject(DI.channelFavoritesRepository)
private channelFavoritesRepository: ChannelFavoritesRepository,
private idService: IdService,
) {
super(meta, paramDef, async (ps, me) => {
const channel = await this.channelsRepository.findOneBy({
id: ps.channelId,
});
if (channel == null) {
throw new ApiError(meta.errors.noSuchChannel);
}
await this.channelFavoritesRepository.insert({
id: this.idService.genId(),
createdAt: new Date(),
userId: me.id,
channelId: channel.id,
});
});
}
}

View file

@ -0,0 +1,54 @@
import { Inject, Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
import type { ChannelFavoritesRepository } from '@/models/index.js';
import { QueryService } from '@/core/QueryService.js';
import { ChannelEntityService } from '@/core/entities/ChannelEntityService.js';
import { DI } from '@/di-symbols.js';
export const meta = {
tags: ['channels', 'account'],
requireCredential: true,
kind: 'read:channels',
res: {
type: 'array',
optional: false, nullable: false,
items: {
type: 'object',
optional: false, nullable: false,
ref: 'Channel',
},
},
} as const;
export const paramDef = {
type: 'object',
properties: {
},
required: [],
} as const;
// eslint-disable-next-line import/no-default-export
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> {
constructor(
@Inject(DI.channelFavoritesRepository)
private channelFavoritesRepository: ChannelFavoritesRepository,
private channelEntityService: ChannelEntityService,
private queryService: QueryService,
) {
super(meta, paramDef, async (ps, me) => {
const query = this.channelFavoritesRepository.createQueryBuilder('favorite')
.andWhere('favorite.userId = :meId', { meId: me.id })
.leftJoinAndSelect('favorite.channel', 'channel');
const favorites = await query
.getMany();
return await Promise.all(favorites.map(x => this.channelEntityService.pack(x.channel!, me)));
});
}
}

View file

@ -51,7 +51,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
throw new ApiError(meta.errors.noSuchChannel); throw new ApiError(meta.errors.noSuchChannel);
} }
return await this.channelEntityService.pack(channel, me); return await this.channelEntityService.pack(channel, me, true);
}); });
} }
} }

View file

@ -0,0 +1,56 @@
import { Inject, Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
import type { ChannelFavoritesRepository, ChannelsRepository } from '@/models/index.js';
import { DI } from '@/di-symbols.js';
import { ApiError } from '../../error.js';
export const meta = {
tags: ['channels'],
requireCredential: true,
kind: 'write:channels',
errors: {
noSuchChannel: {
message: 'No such channel.',
code: 'NO_SUCH_CHANNEL',
id: '353c68dd-131a-476c-aa99-88a345e83668',
},
},
} as const;
export const paramDef = {
type: 'object',
properties: {
channelId: { type: 'string', format: 'misskey:id' },
},
required: ['channelId'],
} as const;
// eslint-disable-next-line import/no-default-export
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> {
constructor(
@Inject(DI.channelsRepository)
private channelsRepository: ChannelsRepository,
@Inject(DI.channelFavoritesRepository)
private channelFavoritesRepository: ChannelFavoritesRepository,
) {
super(meta, paramDef, async (ps, me) => {
const channel = await this.channelsRepository.findOneBy({
id: ps.channelId,
});
if (channel == null) {
throw new ApiError(meta.errors.noSuchChannel);
}
await this.channelFavoritesRepository.delete({
userId: me.id,
channelId: channel.id,
});
});
}
}

View file

@ -3,8 +3,8 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
import type { DriveFilesRepository, ChannelsRepository } from '@/models/index.js'; import type { DriveFilesRepository, ChannelsRepository } from '@/models/index.js';
import { ChannelEntityService } from '@/core/entities/ChannelEntityService.js'; import { ChannelEntityService } from '@/core/entities/ChannelEntityService.js';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import { ApiError } from '../../error.js';
import { RoleService } from '@/core/RoleService.js'; import { RoleService } from '@/core/RoleService.js';
import { ApiError } from '../../error.js';
export const meta = { export const meta = {
tags: ['channels'], tags: ['channels'],
@ -47,6 +47,12 @@ export const paramDef = {
name: { type: 'string', minLength: 1, maxLength: 128 }, name: { type: 'string', minLength: 1, maxLength: 128 },
description: { type: 'string', nullable: true, minLength: 1, maxLength: 2048 }, description: { type: 'string', nullable: true, minLength: 1, maxLength: 2048 },
bannerId: { type: 'string', format: 'misskey:id', nullable: true }, bannerId: { type: 'string', format: 'misskey:id', nullable: true },
pinnedNoteIds: {
type: 'array',
items: {
type: 'string', format: 'misskey:id',
},
},
}, },
required: ['channelId'], required: ['channelId'],
} as const; } as const;
@ -64,7 +70,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
private channelEntityService: ChannelEntityService, private channelEntityService: ChannelEntityService,
private roleService: RoleService, private roleService: RoleService,
) { ) {
super(meta, paramDef, async (ps, me) => { super(meta, paramDef, async (ps, me) => {
const channel = await this.channelsRepository.findOneBy({ const channel = await this.channelsRepository.findOneBy({
id: ps.channelId, id: ps.channelId,
@ -97,6 +103,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
await this.channelsRepository.update(channel.id, { await this.channelsRepository.update(channel.id, {
...(ps.name !== undefined ? { name: ps.name } : {}), ...(ps.name !== undefined ? { name: ps.name } : {}),
...(ps.description !== undefined ? { description: ps.description } : {}), ...(ps.description !== undefined ? { description: ps.description } : {}),
...(ps.pinnedNoteIds !== undefined ? { pinnedNoteIds: ps.pinnedNoteIds } : {}),
...(banner ? { bannerId: banner.id } : {}), ...(banner ? { bannerId: banner.id } : {}),
}); });

View file

@ -59,7 +59,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
this.noteThreadMutingsRepository.count({ this.noteThreadMutingsRepository.count({
where: { where: {
userId: me.id, userId: me.id,
threadId: note.threadId || note.id, threadId: note.threadId ?? note.id,
}, },
take: 1, take: 1,
}), }),

View file

@ -36,7 +36,7 @@ html
link(rel='prefetch' href='https://xn--931a.moe/assets/not-found.jpg') link(rel='prefetch' href='https://xn--931a.moe/assets/not-found.jpg')
link(rel='prefetch' href='https://xn--931a.moe/assets/error.jpg') link(rel='prefetch' href='https://xn--931a.moe/assets/error.jpg')
//- https://github.com/misskey-dev/misskey/issues/9842 //- https://github.com/misskey-dev/misskey/issues/9842
link(rel='stylesheet' href='/assets/tabler-icons/tabler-icons.min.css?v2.10.0') link(rel='stylesheet' href='/assets/tabler-icons/tabler-icons.min.css?v2.12.0')
link(rel='modulepreload' href=`/vite/${clientEntry.file}`) link(rel='modulepreload' href=`/vite/${clientEntry.file}`)
if !config.clientManifestExists if !config.clientManifestExists

View file

@ -11,15 +11,14 @@
"lint": "pnpm typecheck && pnpm eslint" "lint": "pnpm typecheck && pnpm eslint"
}, },
"dependencies": { "dependencies": {
"@discordapp/twemoji": "14.0.2", "@discordapp/twemoji": "14.1.2",
"@rollup/plugin-alias": "4.0.3", "@rollup/plugin-alias": "4.0.3",
"@rollup/plugin-json": "6.0.0", "@rollup/plugin-json": "6.0.0",
"@rollup/pluginutils": "5.0.2", "@rollup/pluginutils": "5.0.2",
"@syuilo/aiscript": "0.13.1", "@syuilo/aiscript": "0.13.1",
"@tabler/icons-webfont": "2.10.0", "@tabler/icons-webfont": "2.12.0",
"@vitejs/plugin-vue": "4.0.0", "@vitejs/plugin-vue": "4.1.0",
"@vue/compiler-sfc": "3.2.47", "@vue/compiler-sfc": "3.2.47",
"autobind-decorator": "2.4.0",
"autosize": "5.0.2", "autosize": "5.0.2",
"blurhash": "2.0.5", "blurhash": "2.0.5",
"broadcast-channel": "4.20.2", "broadcast-channel": "4.20.2",
@ -29,29 +28,29 @@
"chartjs-adapter-date-fns": "3.0.0", "chartjs-adapter-date-fns": "3.0.0",
"chartjs-chart-matrix": "2.0.1", "chartjs-chart-matrix": "2.0.1",
"chartjs-plugin-gradient": "0.6.1", "chartjs-plugin-gradient": "0.6.1",
"chartjs-plugin-zoom": "2.0.0", "chartjs-plugin-zoom": "2.0.1",
"compare-versions": "5.0.1", "compare-versions": "5.0.1",
"cropperjs": "2.0.0-beta.2", "cropperjs": "2.0.0-beta.2",
"date-fns": "2.29.3", "date-fns": "2.29.3",
"escape-regexp": "0.0.1", "escape-regexp": "0.0.1",
"eventemitter3": "5.0.0", "eventemitter3": "5.0.0",
"gsap": "3.11.4", "gsap": "3.11.5",
"idb-keyval": "6.2.0", "idb-keyval": "6.2.0",
"insert-text-at-cursor": "0.3.0", "insert-text-at-cursor": "0.3.0",
"is-file-animated": "1.0.2", "is-file-animated": "1.0.2",
"json5": "2.2.3", "json5": "2.2.3",
"matter-js": "0.19.0", "matter-js": "0.19.0",
"mfm-js": "0.23.3", "mfm-js": "0.23.3",
"misskey-js": "../misskey-js", "misskey-js": "workspace:*",
"photoswipe": "5.3.6", "photoswipe": "5.3.7",
"prismjs": "1.29.0", "prismjs": "1.29.0",
"punycode": "2.3.0", "punycode": "2.3.0",
"querystring": "0.2.1", "querystring": "0.2.1",
"rndstr": "1.0.0", "rndstr": "1.0.0",
"rollup": "3.19.0", "rollup": "3.20.2",
"s-age": "1.1.2", "s-age": "1.1.2",
"sanitize-html": "2.10.0", "sanitize-html": "2.10.0",
"sass": "1.58.3", "sass": "1.60.0",
"seedrandom": "3.0.5", "seedrandom": "3.0.5",
"strict-event-emitter-types": "2.0.0", "strict-event-emitter-types": "2.0.0",
"syuilo-password-strength": "0.0.1", "syuilo-password-strength": "0.0.1",
@ -59,13 +58,13 @@
"three": "0.150.1", "three": "0.150.1",
"throttle-debounce": "5.0.0", "throttle-debounce": "5.0.0",
"tinycolor2": "1.6.0", "tinycolor2": "1.6.0",
"tsc-alias": "1.8.3", "tsc-alias": "1.8.5",
"tsconfig-paths": "4.1.2", "tsconfig-paths": "4.2.0",
"twemoji-parser": "14.0.0", "twemoji-parser": "14.0.0",
"typescript": "4.9.5", "typescript": "5.0.2",
"uuid": "9.0.0", "uuid": "9.0.0",
"vanilla-tilt": "1.8.0", "vanilla-tilt": "1.8.0",
"vite": "4.1.4", "vite": "4.2.1",
"vue": "3.2.47", "vue": "3.2.47",
"vue-plyr": "7.0.0", "vue-plyr": "7.0.0",
"vue-prism-editor": "2.0.0-alpha.2", "vue-prism-editor": "2.0.0-alpha.2",
@ -77,28 +76,28 @@
"@types/gulp": "4.0.10", "@types/gulp": "4.0.10",
"@types/gulp-rename": "2.0.1", "@types/gulp-rename": "2.0.1",
"@types/matter-js": "0.18.2", "@types/matter-js": "0.18.2",
"@types/node": "18.15.0", "@types/node": "18.15.11",
"@types/punycode": "2.1.0", "@types/punycode": "2.1.0",
"@types/sanitize-html": "2.8.1", "@types/sanitize-html": "2.9.0",
"@types/seedrandom": "3.0.5", "@types/seedrandom": "3.0.5",
"@types/throttle-debounce": "5.0.0", "@types/throttle-debounce": "5.0.0",
"@types/tinycolor2": "1.4.3", "@types/tinycolor2": "1.4.3",
"@types/uuid": "9.0.1", "@types/uuid": "9.0.1",
"@types/websocket": "1.0.5", "@types/websocket": "1.0.5",
"@types/ws": "8.5.4", "@types/ws": "8.5.4",
"@typescript-eslint/eslint-plugin": "5.54.1", "@typescript-eslint/eslint-plugin": "5.57.0",
"@typescript-eslint/parser": "5.54.1", "@typescript-eslint/parser": "5.57.0",
"@vitest/coverage-c8": "^0.29.2", "@vitest/coverage-c8": "^0.29.8",
"@vue/runtime-core": "3.2.47", "@vue/runtime-core": "3.2.47",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"cypress": "12.7.0", "cypress": "12.9.0",
"eslint": "8.35.0", "eslint": "8.37.0",
"eslint-plugin-import": "2.27.5", "eslint-plugin-import": "2.27.5",
"eslint-plugin-vue": "9.9.0", "eslint-plugin-vue": "9.10.0",
"happy-dom": "8.9.0", "happy-dom": "8.9.0",
"start-server-and-test": "2.0.0", "start-server-and-test": "2.0.0",
"summaly": "github:misskey-dev/summaly", "summaly": "github:misskey-dev/summaly",
"vitest": "^0.29.2", "vitest": "^0.29.8",
"vitest-fetch-mock": "^0.2.2", "vitest-fetch-mock": "^0.2.2",
"vue-eslint-parser": "9.1.0", "vue-eslint-parser": "9.1.0",
"vue-tsc": "1.2.0" "vue-tsc": "1.2.0"

View file

@ -169,6 +169,7 @@ const props = defineProps<{
}>(); }>();
const inChannel = inject('inChannel', null); const inChannel = inject('inChannel', null);
const currentClip = inject<Ref<misskey.entities.Clip> | null>('currentClip', null);
let note = $ref(deepClone(props.note)); let note = $ref(deepClone(props.note));
@ -370,8 +371,6 @@ function undoReact(note): void {
}); });
} }
const currentClipPage = inject<Ref<misskey.entities.Clip> | null>('currentClipPage', null);
function onContextmenu(ev: MouseEvent): void { function onContextmenu(ev: MouseEvent): void {
const isLink = (el: HTMLElement) => { const isLink = (el: HTMLElement) => {
if (el.tagName === 'A') return true; if (el.tagName === 'A') return true;
@ -386,18 +385,18 @@ function onContextmenu(ev: MouseEvent): void {
ev.preventDefault(); ev.preventDefault();
react(); react();
} else { } else {
os.contextMenu(getNoteMenu({ note: note, translating, translation, menuButton, isDeleted, currentClipPage }), ev).then(focus); os.contextMenu(getNoteMenu({ note: note, translating, translation, menuButton, isDeleted, currentClip: currentClip?.value }), ev).then(focus);
} }
} }
function menu(viaKeyboard = false): void { function menu(viaKeyboard = false): void {
os.popupMenu(getNoteMenu({ note: note, translating, translation, menuButton, isDeleted, currentClipPage }), menuButton.value, { os.popupMenu(getNoteMenu({ note: note, translating, translation, menuButton, isDeleted, currentClip: currentClip?.value }), menuButton.value, {
viaKeyboard, viaKeyboard,
}).then(focus); }).then(focus);
} }
async function clip() { async function clip() {
os.popupMenu(await getNoteClipMenu({ note: note, isDeleted, currentClipPage }), clipButton.value).then(focus); os.popupMenu(await getNoteClipMenu({ note: note, isDeleted, currentClip: currentClip?.value }), clipButton.value).then(focus);
} }
function showRenoteMenu(viaKeyboard = false): void { function showRenoteMenu(viaKeyboard = false): void {

View file

@ -19,7 +19,7 @@
:ad="true" :ad="true"
:class="$style.notes" :class="$style.notes"
> >
<XNote :key="note._featuredId_ || note._prId_ || note.id" :class="$style.note" :note="note"/> <MkNote :key="note._featuredId_ || note._prId_ || note.id" :class="$style.note" :note="note"/>
</MkDateSeparatedList> </MkDateSeparatedList>
</div> </div>
</template> </template>
@ -28,7 +28,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { shallowRef } from 'vue'; import { shallowRef } from 'vue';
import XNote from '@/components/MkNote.vue'; import MkNote from '@/components/MkNote.vue';
import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue'; import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue'; import MkPagination, { Paging } from '@/components/MkPagination.vue';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';

View file

@ -9,7 +9,7 @@
<template #default="{ items: notifications }"> <template #default="{ items: notifications }">
<MkDateSeparatedList v-slot="{ item: notification }" :class="$style.list" :items="notifications" :no-gap="true"> <MkDateSeparatedList v-slot="{ item: notification }" :class="$style.list" :items="notifications" :no-gap="true">
<XNote v-if="['reply', 'quote', 'mention'].includes(notification.type)" :key="notification.id" :note="notification.note"/> <MkNote v-if="['reply', 'quote', 'mention'].includes(notification.type)" :key="notification.id" :note="notification.note"/>
<XNotification v-else :key="notification.id" :notification="notification" :with-time="true" :full="true" class="_panel notification"/> <XNotification v-else :key="notification.id" :notification="notification" :with-time="true" :full="true" class="_panel notification"/>
</MkDateSeparatedList> </MkDateSeparatedList>
</template> </template>
@ -21,7 +21,7 @@ import { onUnmounted, onMounted, computed, shallowRef } from 'vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue'; import MkPagination, { Paging } from '@/components/MkPagination.vue';
import XNotification from '@/components/MkNotification.vue'; import XNotification from '@/components/MkNotification.vue';
import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue'; import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue';
import XNote from '@/components/MkNote.vue'; import MkNote from '@/components/MkNote.vue';
import { stream } from '@/stream'; import { stream } from '@/stream';
import { $i } from '@/account'; import { $i } from '@/account';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';

View file

@ -52,7 +52,7 @@
<input v-show="withHashtags" ref="hashtagsInputEl" v-model="hashtags" :class="$style.hashtags" :placeholder="i18n.ts.hashtags" list="hashtags"> <input v-show="withHashtags" ref="hashtagsInputEl" v-model="hashtags" :class="$style.hashtags" :placeholder="i18n.ts.hashtags" list="hashtags">
<XPostFormAttaches v-model="files" :class="$style.attaches" @detach="detachFile" @change-sensitive="updateFileSensitive" @change-name="updateFileName"/> <XPostFormAttaches v-model="files" :class="$style.attaches" @detach="detachFile" @change-sensitive="updateFileSensitive" @change-name="updateFileName"/>
<MkPollEditor v-if="poll" v-model="poll" @destroyed="poll = null"/> <MkPollEditor v-if="poll" v-model="poll" @destroyed="poll = null"/>
<XNotePreview v-if="showPreview" :class="$style.preview" :text="text"/> <MkNotePreview v-if="showPreview" :class="$style.preview" :text="text"/>
<div v-if="showingOptions" style="padding: 0 16px;"> <div v-if="showingOptions" style="padding: 0 16px;">
<MkSelect v-model="reactionAcceptance" small> <MkSelect v-model="reactionAcceptance" small>
<template #label>{{ i18n.ts.reactionAcceptance }}</template> <template #label>{{ i18n.ts.reactionAcceptance }}</template>
@ -87,7 +87,7 @@ import { toASCII } from 'punycode/';
import * as Acct from 'misskey-js/built/acct'; import * as Acct from 'misskey-js/built/acct';
import MkSelect from './MkSelect.vue'; import MkSelect from './MkSelect.vue';
import MkNoteSimple from '@/components/MkNoteSimple.vue'; import MkNoteSimple from '@/components/MkNoteSimple.vue';
import XNotePreview from '@/components/MkNotePreview.vue'; import MkNotePreview from '@/components/MkNotePreview.vue';
import XPostFormAttaches from '@/components/MkPostFormAttaches.vue'; import XPostFormAttaches from '@/components/MkPostFormAttaches.vue';
import MkPollEditor from '@/components/MkPollEditor.vue'; import MkPollEditor from '@/components/MkPollEditor.vue';
import { host, url } from '@/config'; import { host, url } from '@/config';

View file

@ -3,7 +3,7 @@
ref="buttonEl" ref="buttonEl"
v-ripple="canToggle" v-ripple="canToggle"
class="_button" class="_button"
:class="[$style.root, { [$style.reacted]: note.myReaction == reaction, [$style.canToggle]: canToggle }]" :class="[$style.root, { [$style.reacted]: note.myReaction == reaction, [$style.canToggle]: canToggle, [$style.large]: defaultStore.state.largeNoteReactions }]"
@click="toggleReaction()" @click="toggleReaction()"
> >
<MkReactionIcon :class="$style.icon" :reaction="reaction" :emoji-url="note.reactionEmojis[reaction.substr(1, reaction.length - 2)]"/> <MkReactionIcon :class="$style.icon" :reaction="reaction" :emoji-url="note.reactionEmojis[reaction.substr(1, reaction.length - 2)]"/>
@ -118,6 +118,17 @@ useTooltip(buttonEl, async (showing) => {
cursor: default; cursor: default;
} }
&.large {
height: 42px;
font-size: 1.5em;
border-radius: 6px;
> .count {
font-size: 0.7em;
line-height: 42px;
}
}
&.reacted { &.reacted {
background: var(--accent); background: var(--accent);

View file

@ -243,7 +243,7 @@ onUnmounted(() => {
display: flex; display: flex;
align-items: center; align-items: center;
max-width: min(30vw, 400px); max-width: min(30vw, 400px);
overflow: auto; overflow: clip;
white-space: nowrap; white-space: nowrap;
text-align: left; text-align: left;
font-weight: bold; font-weight: bold;

View file

@ -1,21 +1,21 @@
<template> <template>
<div class="voxdxuby"> <div class="voxdxuby">
<XNote v-if="note && !block.detailed" :key="note.id + ':normal'" v-model:note="note"/> <MkNote v-if="note && !block.detailed" :key="note.id + ':normal'" v-model:note="note"/>
<XNoteDetailed v-if="note && block.detailed" :key="note.id + ':detail'" v-model:note="note"/> <MkNoteDetailed v-if="note && block.detailed" :key="note.id + ':detail'" v-model:note="note"/>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, onMounted, PropType, Ref, ref } from 'vue'; import { defineComponent, onMounted, PropType, Ref, ref } from 'vue';
import XNote from '@/components/MkNote.vue'; import MkNote from '@/components/MkNote.vue';
import XNoteDetailed from '@/components/MkNoteDetailed.vue'; import MkNoteDetailed from '@/components/MkNoteDetailed.vue';
import * as os from '@/os'; import * as os from '@/os';
import { NoteBlock } from '@/scripts/hpml/block'; import { NoteBlock } from '@/scripts/hpml/block';
export default defineComponent({ export default defineComponent({
components: { components: {
XNote, MkNote,
XNoteDetailed, MkNoteDetailed,
}, },
props: { props: {
block: { block: {

View file

@ -1,5 +1,4 @@
import { defineAsyncComponent, Directive, ref } from 'vue'; import { defineAsyncComponent, Directive, ref } from 'vue';
import autobind from 'autobind-decorator';
import { popup } from '@/os'; import { popup } from '@/os';
export class UserPreview { export class UserPreview {
@ -15,9 +14,16 @@ export class UserPreview {
this.user = user; this.user = user;
this.attach(); this.attach();
this.show = this.show.bind(this);
this.close = this.close.bind(this);
this.onMouseover = this.onMouseover.bind(this);
this.onMouseleave = this.onMouseleave.bind(this);
this.onClick = this.onClick.bind(this);
this.attach = this.attach.bind(this);
this.detach = this.detach.bind(this);
} }
@autobind
private show() { private show() {
if (!document.body.contains(this.el)) return; if (!document.body.contains(this.el)) return;
if (this.promise) return; if (this.promise) return;
@ -53,7 +59,6 @@ export class UserPreview {
}, 1000); }, 1000);
} }
@autobind
private close() { private close() {
if (this.promise) { if (this.promise) {
window.clearInterval(this.checkTimer); window.clearInterval(this.checkTimer);
@ -62,34 +67,29 @@ export class UserPreview {
} }
} }
@autobind
private onMouseover() { private onMouseover() {
window.clearTimeout(this.showTimer); window.clearTimeout(this.showTimer);
window.clearTimeout(this.hideTimer); window.clearTimeout(this.hideTimer);
this.showTimer = window.setTimeout(this.show, 500); this.showTimer = window.setTimeout(this.show, 500);
} }
@autobind
private onMouseleave() { private onMouseleave() {
window.clearTimeout(this.showTimer); window.clearTimeout(this.showTimer);
window.clearTimeout(this.hideTimer); window.clearTimeout(this.hideTimer);
this.hideTimer = window.setTimeout(this.close, 500); this.hideTimer = window.setTimeout(this.close, 500);
} }
@autobind
private onClick() { private onClick() {
window.clearTimeout(this.showTimer); window.clearTimeout(this.showTimer);
this.close(); this.close();
} }
@autobind
public attach() { public attach() {
this.el.addEventListener('mouseover', this.onMouseover); this.el.addEventListener('mouseover', this.onMouseover);
this.el.addEventListener('mouseleave', this.onMouseleave); this.el.addEventListener('mouseleave', this.onMouseleave);
this.el.addEventListener('click', this.onClick); this.el.addEventListener('click', this.onClick);
} }
@autobind
public detach() { public detach() {
this.el.removeEventListener('mouseover', this.onMouseover); this.el.removeEventListener('mouseover', this.onMouseover);
this.el.removeEventListener('mouseleave', this.onMouseleave); this.el.removeEventListener('mouseleave', this.onMouseleave);

View file

@ -2,7 +2,7 @@
<MkStickyContainer> <MkStickyContainer>
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template> <template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
<MkSpacer :content-max="700"> <MkSpacer :content-max="700">
<div class="_gaps_m"> <div v-if="channel" class="_gaps_m">
<MkInput v-model="name"> <MkInput v-model="name">
<template #label>{{ i18n.ts.name }}</template> <template #label>{{ i18n.ts.name }}</template>
</MkInput> </MkInput>
@ -11,13 +11,37 @@
<template #label>{{ i18n.ts.description }}</template> <template #label>{{ i18n.ts.description }}</template>
</MkTextarea> </MkTextarea>
<div class="banner"> <div>
<MkButton v-if="bannerId == null" @click="setBannerImage"><i class="ti ti-plus"></i> {{ i18n.ts._channel.setBanner }}</MkButton> <MkButton v-if="bannerId == null" @click="setBannerImage"><i class="ti ti-plus"></i> {{ i18n.ts._channel.setBanner }}</MkButton>
<div v-else-if="bannerUrl"> <div v-else-if="bannerUrl">
<img :src="bannerUrl" style="width: 100%;"/> <img :src="bannerUrl" style="width: 100%;"/>
<MkButton @click="removeBannerImage()"><i class="ti ti-trash"></i> {{ i18n.ts._channel.removeBanner }}</MkButton> <MkButton @click="removeBannerImage()"><i class="ti ti-trash"></i> {{ i18n.ts._channel.removeBanner }}</MkButton>
</div> </div>
</div> </div>
<MkFolder :default-open="true">
<template #label>{{ i18n.ts.pinnedNotes }}</template>
<div class="_gaps">
<MkButton primary rounded @click="addPinnedNote()"><i class="ti ti-plus"></i></MkButton>
<Sortable
v-model="pinnedNotes"
item-key="id"
:handle="'.' + $style.pinnedNoteHandle"
:animation="150"
>
<template #item="{element,index}">
<div :class="$style.pinnedNote">
<button class="_button" :class="$style.pinnedNoteHandle"><i class="ti ti-menu"></i></button>
{{ element.id }}
<button class="_button" :class="$style.pinnedNoteRemove" @click="removePinnedNote(index)"><i class="ti ti-x"></i></button>
</div>
</template>
</Sortable>
</div>
</MkFolder>
<div> <div>
<MkButton primary @click="save()"><i class="ti ti-device-floppy"></i> {{ channelId ? i18n.ts.save : i18n.ts.create }}</MkButton> <MkButton primary @click="save()"><i class="ti ti-device-floppy"></i> {{ channelId ? i18n.ts.save : i18n.ts.create }}</MkButton>
</div> </div>
@ -27,7 +51,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed, watch } from 'vue'; import { computed, ref, watch, defineAsyncComponent } from 'vue';
import MkTextarea from '@/components/MkTextarea.vue'; import MkTextarea from '@/components/MkTextarea.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import MkInput from '@/components/MkInput.vue'; import MkInput from '@/components/MkInput.vue';
@ -36,6 +60,9 @@ import * as os from '@/os';
import { useRouter } from '@/router'; import { useRouter } from '@/router';
import { definePageMetadata } from '@/scripts/page-metadata'; import { definePageMetadata } from '@/scripts/page-metadata';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import MkFolder from '@/components/MkFolder.vue';
const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default));
const router = useRouter(); const router = useRouter();
@ -48,6 +75,7 @@ let name = $ref(null);
let description = $ref(null); let description = $ref(null);
let bannerUrl = $ref<string | null>(null); let bannerUrl = $ref<string | null>(null);
let bannerId = $ref<string | null>(null); let bannerId = $ref<string | null>(null);
const pinnedNotes = ref([]);
watch(() => bannerId, async () => { watch(() => bannerId, async () => {
if (bannerId == null) { if (bannerId == null) {
@ -70,15 +98,36 @@ async function fetchChannel() {
description = channel.description; description = channel.description;
bannerId = channel.bannerId; bannerId = channel.bannerId;
bannerUrl = channel.bannerUrl; bannerUrl = channel.bannerUrl;
pinnedNotes.value = channel.pinnedNoteIds.map(id => ({
id,
}));
} }
fetchChannel(); fetchChannel();
async function addPinnedNote() {
const { canceled, result: value } = await os.inputText({
title: i18n.ts.noteIdOrUrl,
});
if (canceled) return;
const note = await os.apiWithDialog('notes/show', {
noteId: value.includes('/') ? value.split('/').pop() : value,
});
pinnedNotes.value = [{
id: note.id,
}, ...pinnedNotes.value];
}
function removePinnedNote(index: number) {
pinnedNotes.value.splice(index, 1);
}
function save() { function save() {
const params = { const params = {
name: name, name: name,
description: description, description: description,
bannerId: bannerId, bannerId: bannerId,
pinnedNoteIds: pinnedNotes.value.map(x => x.id),
}; };
if (props.channelId) { if (props.channelId) {
@ -117,6 +166,32 @@ definePageMetadata(computed(() => props.channelId ? {
})); }));
</script> </script>
<style lang="scss" scoped> <style lang="scss" module>
.pinnedNote {
position: relative;
display: block;
line-height: 2.85rem;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
color: var(--navFg);
}
.pinnedNoteRemove {
position: absolute;
z-index: 10000;
width: 32px;
height: 32px;
color: #ff2a2a;
right: 8px;
opacity: 0.8;
}
.pinnedNoteHandle {
cursor: move;
width: 32px;
height: 32px;
margin: 0 8px;
opacity: 0.5;
}
</style> </style>

View file

@ -16,6 +16,16 @@
<Mfm :text="channel.description" :is-note="false" :i="$i"/> <Mfm :text="channel.description" :is-note="false" :i="$i"/>
</div> </div>
</div> </div>
<MkButton v-if="favorited" v-tooltip="i18n.ts.unfavorite" as-like class="button" rounded primary @click="unfavorite()"><i class="ti ti-star"></i></MkButton>
<MkButton v-else v-tooltip="i18n.ts.favorite" as-like class="button" rounded @click="favorite()"><i class="ti ti-star"></i></MkButton>
<MkFoldableSection>
<template #header><i class="ti ti-pin ti-fw" style="margin-right: 0.5em;"></i>{{ i18n.ts.pinnedNotes }}</template>
<div v-if="channel.pinnedNotes.length > 0" class="_gaps">
<MkNote v-for="note in channel.pinnedNotes" :key="note.id" class="_panel" :note="note"/>
</div>
</MkFoldableSection>
</div> </div>
<div v-if="channel && tab === 'timeline'" class="_gaps"> <div v-if="channel && tab === 'timeline'" class="_gaps">
<!-- スマホタブレットの場合キーボードが表示されると投稿が見づらくなるのでデスクトップ場合のみ自動でフォーカスを当てる --> <!-- スマホタブレットの場合キーボードが表示されると投稿が見づらくなるのでデスクトップ場合のみ自動でフォーカスを当てる -->
@ -54,6 +64,8 @@ import MkNotes from '@/components/MkNotes.vue';
import { url } from '@/config'; import { url } from '@/config';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { defaultStore } from '@/store'; import { defaultStore } from '@/store';
import MkNote from '@/components/MkNote.vue';
import MkFoldableSection from '@/components/MkFoldableSection.vue';
const router = useRouter(); const router = useRouter();
@ -63,6 +75,7 @@ const props = defineProps<{
let tab = $ref('timeline'); let tab = $ref('timeline');
let channel = $ref(null); let channel = $ref(null);
let favorited = $ref(false);
const featuredPagination = $computed(() => ({ const featuredPagination = $computed(() => ({
endpoint: 'notes/featured' as const, endpoint: 'notes/featured' as const,
limit: 10, limit: 10,
@ -76,6 +89,7 @@ watch(() => props.channelId, async () => {
channel = await os.api('channels/show', { channel = await os.api('channels/show', {
channelId: props.channelId, channelId: props.channelId,
}); });
favorited = channel.isFavorited;
}, { immediate: true }); }, { immediate: true });
function edit() { function edit() {
@ -90,6 +104,27 @@ function openPostForm() {
}); });
} }
function favorite() {
os.apiWithDialog('channels/favorite', {
channelId: channel.id,
}).then(() => {
favorited = true;
});
}
async function unfavorite() {
const confirm = await os.confirm({
type: 'warning',
text: i18n.ts.unfavoriteConfirm,
});
if (confirm.canceled) return;
os.apiWithDialog('channels/unfavorite', {
channelId: channel.id,
}).then(() => {
favorited = false;
});
}
const headerActions = $computed(() => { const headerActions = $computed(() => {
if (channel && channel.userId) { if (channel && channel.userId) {
const share = { const share = {

View file

@ -2,17 +2,22 @@
<MkStickyContainer> <MkStickyContainer>
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template> <template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
<MkSpacer :content-max="700"> <MkSpacer :content-max="700">
<div v-if="tab === 'featured'" class="grwlizim featured"> <div v-if="tab === 'featured'">
<MkPagination v-slot="{items}" :pagination="featuredPagination"> <MkPagination v-slot="{items}" :pagination="featuredPagination">
<MkChannelPreview v-for="channel in items" :key="channel.id" class="_margin" :channel="channel"/> <MkChannelPreview v-for="channel in items" :key="channel.id" class="_margin" :channel="channel"/>
</MkPagination> </MkPagination>
</div> </div>
<div v-else-if="tab === 'following'" class="grwlizim following"> <div v-else-if="tab === 'favorites'">
<MkPagination v-slot="{items}" :pagination="favoritesPagination">
<MkChannelPreview v-for="channel in items" :key="channel.id" class="_margin" :channel="channel"/>
</MkPagination>
</div>
<div v-else-if="tab === 'following'">
<MkPagination v-slot="{items}" :pagination="followingPagination"> <MkPagination v-slot="{items}" :pagination="followingPagination">
<MkChannelPreview v-for="channel in items" :key="channel.id" class="_margin" :channel="channel"/> <MkChannelPreview v-for="channel in items" :key="channel.id" class="_margin" :channel="channel"/>
</MkPagination> </MkPagination>
</div> </div>
<div v-else-if="tab === 'owned'" class="grwlizim owned"> <div v-else-if="tab === 'owned'">
<MkButton class="new" @click="create()"><i class="ti ti-plus"></i></MkButton> <MkButton class="new" @click="create()"><i class="ti ti-plus"></i></MkButton>
<MkPagination v-slot="{items}" :pagination="ownedPagination"> <MkPagination v-slot="{items}" :pagination="ownedPagination">
<MkChannelPreview v-for="channel in items" :key="channel.id" class="_margin" :channel="channel"/> <MkChannelPreview v-for="channel in items" :key="channel.id" class="_margin" :channel="channel"/>
@ -39,13 +44,17 @@ const featuredPagination = {
endpoint: 'channels/featured' as const, endpoint: 'channels/featured' as const,
noPaging: true, noPaging: true,
}; };
const favoritesPagination = {
endpoint: 'channels/my-favorites' as const,
limit: 100,
};
const followingPagination = { const followingPagination = {
endpoint: 'channels/followed' as const, endpoint: 'channels/followed' as const,
limit: 5, limit: 10,
}; };
const ownedPagination = { const ownedPagination = {
endpoint: 'channels/owned' as const, endpoint: 'channels/owned' as const,
limit: 5, limit: 10,
}; };
function create() { function create() {
@ -62,10 +71,14 @@ const headerTabs = $computed(() => [{
key: 'featured', key: 'featured',
title: i18n.ts._channel.featured, title: i18n.ts._channel.featured,
icon: 'ti ti-comet', icon: 'ti ti-comet',
}, {
key: 'favorites',
title: i18n.ts.favorites,
icon: 'ti ti-star',
}, { }, {
key: 'following', key: 'following',
title: i18n.ts._channel.following, title: i18n.ts._channel.following,
icon: 'ti ti-heart', icon: 'ti ti-eye',
}, { }, {
key: 'owned', key: 'owned',
title: i18n.ts._channel.owned, title: i18n.ts._channel.owned,

View file

@ -57,7 +57,7 @@ watch(() => props.clipId, async () => {
immediate: true, immediate: true,
}); });
provide('currentClipPage', $$(clip)); provide('currentClip', $$(clip));
function favorite() { function favorite() {
os.apiWithDialog('clips/favorite', { os.apiWithDialog('clips/favorite', {

View file

@ -12,7 +12,7 @@
<template #default="{ items }"> <template #default="{ items }">
<MkDateSeparatedList v-slot="{ item }" :items="items" :direction="'down'" :no-gap="false" :ad="false"> <MkDateSeparatedList v-slot="{ item }" :items="items" :direction="'down'" :no-gap="false" :ad="false">
<XNote :key="item.id" :note="item.note" :class="$style.note"/> <MkNote :key="item.id" :note="item.note" :class="$style.note"/>
</MkDateSeparatedList> </MkDateSeparatedList>
</template> </template>
</MkPagination> </MkPagination>
@ -22,7 +22,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import MkPagination from '@/components/MkPagination.vue'; import MkPagination from '@/components/MkPagination.vue';
import XNote from '@/components/MkNote.vue'; import MkNote from '@/components/MkNote.vue';
import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue'; import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata'; import { definePageMetadata } from '@/scripts/page-metadata';

View file

@ -13,7 +13,7 @@
<MkButton v-if="!showNext && hasNext" class="load next" @click="showNext = true"><i class="ti ti-chevron-up"></i></MkButton> <MkButton v-if="!showNext && hasNext" class="load next" @click="showNext = true"><i class="ti ti-chevron-up"></i></MkButton>
<div class="note _margin _gaps_s"> <div class="note _margin _gaps_s">
<MkRemoteCaution v-if="note.user.host != null" :href="note.url ?? note.uri"/> <MkRemoteCaution v-if="note.user.host != null" :href="note.url ?? note.uri"/>
<XNoteDetailed :key="note.id" v-model:note="note" class="note"/> <MkNoteDetailed :key="note.id" v-model:note="note" class="note"/>
</div> </div>
<div v-if="clips && clips.length > 0" class="clips _margin"> <div v-if="clips && clips.length > 0" class="clips _margin">
<div class="title">{{ i18n.ts.clip }}</div> <div class="title">{{ i18n.ts.clip }}</div>
@ -41,7 +41,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed, watch } from 'vue'; import { computed, watch } from 'vue';
import * as misskey from 'misskey-js'; import * as misskey from 'misskey-js';
import XNoteDetailed from '@/components/MkNoteDetailed.vue'; import MkNoteDetailed from '@/components/MkNoteDetailed.vue';
import MkNotes from '@/components/MkNotes.vue'; import MkNotes from '@/components/MkNotes.vue';
import MkRemoteCaution from '@/components/MkRemoteCaution.vue'; import MkRemoteCaution from '@/components/MkRemoteCaution.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';

View file

@ -10,8 +10,8 @@
</MkInput> </MkInput>
<MkSwitch v-model="props.modelValue.detailed"><span>{{ $ts._pages.blocks._note.detailed }}</span></MkSwitch> <MkSwitch v-model="props.modelValue.detailed"><span>{{ $ts._pages.blocks._note.detailed }}</span></MkSwitch>
<XNote v-if="note && !props.modelValue.detailed" :key="note.id + ':normal'" v-model:note="note" style="margin-bottom: 16px;"/> <MkNote v-if="note && !props.modelValue.detailed" :key="note.id + ':normal'" v-model:note="note" style="margin-bottom: 16px;"/>
<XNoteDetailed v-if="note && props.modelValue.detailed" :key="note.id + ':detail'" v-model:note="note" style="margin-bottom: 16px;"/> <MkNoteDetailed v-if="note && props.modelValue.detailed" :key="note.id + ':detail'" v-model:note="note" style="margin-bottom: 16px;"/>
</section> </section>
</XContainer> </XContainer>
</template> </template>
@ -22,8 +22,8 @@ import { watch } from 'vue';
import XContainer from '../page-editor.container.vue'; import XContainer from '../page-editor.container.vue';
import MkInput from '@/components/MkInput.vue'; import MkInput from '@/components/MkInput.vue';
import MkSwitch from '@/components/MkSwitch.vue'; import MkSwitch from '@/components/MkSwitch.vue';
import XNote from '@/components/MkNote.vue'; import MkNote from '@/components/MkNote.vue';
import XNoteDetailed from '@/components/MkNoteDetailed.vue'; import MkNoteDetailed from '@/components/MkNoteDetailed.vue';
import * as os from '@/os'; import * as os from '@/os';
const props = defineProps<{ const props = defineProps<{

View file

@ -56,6 +56,9 @@ import MkFoldableSection from '@/components/MkFoldableSection.vue';
import { $i } from '@/account'; import { $i } from '@/account';
import { instance } from '@/instance'; import { instance } from '@/instance';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import { useRouter } from '@/router';
const router = useRouter();
const props = defineProps<{ const props = defineProps<{
query: string; query: string;
@ -84,6 +87,24 @@ async function search() {
if (query == null || query === '') return; if (query == null || query === '') return;
if (query.startsWith('https://')) {
const promise = os.api('ap/show', {
uri: query,
});
os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
const res = await promise;
if (res.type === 'User') {
router.push(`/@${res.object.username}@${res.object.host}`);
} else if (res.type === 'Note') {
router.push(`/notes/${res.object.id}`);
}
return;
}
if (tab === 'note') { if (tab === 'note') {
notePagination = { notePagination = {
endpoint: 'notes/search', endpoint: 'notes/search',

View file

@ -48,6 +48,7 @@
<div class="_gaps_s"> <div class="_gaps_s">
<MkSwitch v-model="showNoteActionsOnlyHover">{{ i18n.ts.showNoteActionsOnlyHover }}</MkSwitch> <MkSwitch v-model="showNoteActionsOnlyHover">{{ i18n.ts.showNoteActionsOnlyHover }}</MkSwitch>
<MkSwitch v-model="showClipButtonInNoteFooter">{{ i18n.ts.showClipButtonInNoteFooter }}</MkSwitch> <MkSwitch v-model="showClipButtonInNoteFooter">{{ i18n.ts.showClipButtonInNoteFooter }}</MkSwitch>
<MkSwitch v-model="largeNoteReactions">{{ i18n.ts.largeNoteReactions }}</MkSwitch>
<MkSwitch v-model="collapseRenotes">{{ i18n.ts.collapseRenotes }}</MkSwitch> <MkSwitch v-model="collapseRenotes">{{ i18n.ts.collapseRenotes }}</MkSwitch>
<MkSwitch v-model="advancedMfm">{{ i18n.ts.enableAdvancedMfm }}</MkSwitch> <MkSwitch v-model="advancedMfm">{{ i18n.ts.enableAdvancedMfm }}</MkSwitch>
<MkSwitch v-if="advancedMfm" v-model="animatedMfm">{{ i18n.ts.enableAnimatedMfm }}</MkSwitch> <MkSwitch v-if="advancedMfm" v-model="animatedMfm">{{ i18n.ts.enableAnimatedMfm }}</MkSwitch>
@ -145,6 +146,7 @@ const overridedDeviceKind = computed(defaultStore.makeGetterSetter('overridedDev
const serverDisconnectedBehavior = computed(defaultStore.makeGetterSetter('serverDisconnectedBehavior')); const serverDisconnectedBehavior = computed(defaultStore.makeGetterSetter('serverDisconnectedBehavior'));
const showNoteActionsOnlyHover = computed(defaultStore.makeGetterSetter('showNoteActionsOnlyHover')); const showNoteActionsOnlyHover = computed(defaultStore.makeGetterSetter('showNoteActionsOnlyHover'));
const showClipButtonInNoteFooter = computed(defaultStore.makeGetterSetter('showClipButtonInNoteFooter')); const showClipButtonInNoteFooter = computed(defaultStore.makeGetterSetter('showClipButtonInNoteFooter'));
const largeNoteReactions = computed(defaultStore.makeGetterSetter('largeNoteReactions'));
const collapseRenotes = computed(defaultStore.makeGetterSetter('collapseRenotes')); const collapseRenotes = computed(defaultStore.makeGetterSetter('collapseRenotes'));
const reduceAnimation = computed(defaultStore.makeGetterSetter('animation', v => !v, v => !v)); const reduceAnimation = computed(defaultStore.makeGetterSetter('animation', v => !v, v => !v));
const useBlurEffectForModal = computed(defaultStore.makeGetterSetter('useBlurEffectForModal')); const useBlurEffectForModal = computed(defaultStore.makeGetterSetter('useBlurEffectForModal'));

View file

@ -83,7 +83,7 @@ async function chooseAntenna(ev: MouseEvent): Promise<void> {
} }
async function chooseChannel(ev: MouseEvent): Promise<void> { async function chooseChannel(ev: MouseEvent): Promise<void> {
const channels = await os.api('channels/followed', { const channels = await os.api('channels/my-favorites', {
limit: 100, limit: 100,
}); });
const items = channels.map(channel => ({ const items = channels.map(channel => ({

View file

@ -93,7 +93,7 @@
<div class="contents _gaps"> <div class="contents _gaps">
<div v-if="user.pinnedNotes.length > 0" class="_gaps"> <div v-if="user.pinnedNotes.length > 0" class="_gaps">
<XNote v-for="note in user.pinnedNotes" :key="note.id" class="note _panel" :note="note" :pinned="true"/> <MkNote v-for="note in user.pinnedNotes" :key="note.id" class="note _panel" :note="note" :pinned="true"/>
</div> </div>
<MkInfo v-else-if="$i && $i.id === user.id">{{ i18n.ts.userPagePinTip }}</MkInfo> <MkInfo v-else-if="$i && $i.id === user.id">{{ i18n.ts.userPagePinTip }}</MkInfo>
<template v-if="narrow"> <template v-if="narrow">
@ -115,7 +115,7 @@
import { defineAsyncComponent, computed, onMounted, onUnmounted } from 'vue'; import { defineAsyncComponent, computed, onMounted, onUnmounted } from 'vue';
import calcAge from 's-age'; import calcAge from 's-age';
import * as misskey from 'misskey-js'; import * as misskey from 'misskey-js';
import XNote from '@/components/MkNote.vue'; import MkNote from '@/components/MkNote.vue';
import MkFollowButton from '@/components/MkFollowButton.vue'; import MkFollowButton from '@/components/MkFollowButton.vue';
import MkRemoteCaution from '@/components/MkRemoteCaution.vue'; import MkRemoteCaution from '@/components/MkRemoteCaution.vue';
import MkOmit from '@/components/MkOmit.vue'; import MkOmit from '@/components/MkOmit.vue';

View file

@ -38,12 +38,12 @@
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import { toUnicode } from 'punycode/'; import { toUnicode } from 'punycode/';
import XTimeline from './welcome.timeline.vue';
import XSigninDialog from '@/components/MkSigninDialog.vue'; import XSigninDialog from '@/components/MkSigninDialog.vue';
import XSignupDialog from '@/components/MkSignupDialog.vue'; import XSignupDialog from '@/components/MkSignupDialog.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import XNote from '@/components/MkNote.vue'; import MkNote from '@/components/MkNote.vue';
import MkFeaturedPhotos from '@/components/MkFeaturedPhotos.vue'; import MkFeaturedPhotos from '@/components/MkFeaturedPhotos.vue';
import XTimeline from './welcome.timeline.vue';
import { host, instanceName } from '@/config'; import { host, instanceName } from '@/config';
import * as os from '@/os'; import * as os from '@/os';
import number from '@/filters/number'; import number from '@/filters/number';
@ -51,7 +51,7 @@ import number from '@/filters/number';
export default defineComponent({ export default defineComponent({
components: { components: {
MkButton, MkButton,
XNote, MkNote,
XTimeline, XTimeline,
MkFeaturedPhotos, MkFeaturedPhotos,
}, },
@ -118,7 +118,7 @@ export default defineComponent({
text: this.$ts.help, text: this.$ts.help,
icon: 'ti ti-question-circle', icon: 'ti ti-question-circle',
action: () => { action: () => {
window.open(`https://misskey-hub.net/help.md`, '_blank'); window.open('https://misskey-hub.net/help.md', '_blank');
}, },
}], ev.currentTarget ?? ev.target); }], ev.currentTarget ?? ev.target);
}, },

View file

@ -61,7 +61,7 @@ import { toUnicode } from 'punycode/';
import XSigninDialog from '@/components/MkSigninDialog.vue'; import XSigninDialog from '@/components/MkSigninDialog.vue';
import XSignupDialog from '@/components/MkSignupDialog.vue'; import XSignupDialog from '@/components/MkSignupDialog.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import XNote from '@/components/MkNote.vue'; import MkNote from '@/components/MkNote.vue';
import MkFeaturedPhotos from '@/components/MkFeaturedPhotos.vue'; import MkFeaturedPhotos from '@/components/MkFeaturedPhotos.vue';
import XTimeline from './welcome.timeline.vue'; import XTimeline from './welcome.timeline.vue';
import { host, instanceName } from '@/config'; import { host, instanceName } from '@/config';
@ -71,7 +71,7 @@ import number from '@/filters/number';
export default defineComponent({ export default defineComponent({
components: { components: {
MkButton, MkButton,
XNote, MkNote,
MkFeaturedPhotos, MkFeaturedPhotos,
XTimeline, XTimeline,
}, },

View file

@ -15,7 +15,7 @@ import { clipsCache } from '@/cache';
export async function getNoteClipMenu(props: { export async function getNoteClipMenu(props: {
note: misskey.entities.Note; note: misskey.entities.Note;
isDeleted: Ref<boolean>; isDeleted: Ref<boolean>;
currentClipPage?: Ref<misskey.entities.Clip>; currentClip?: misskey.entities.Clip;
}) { }) {
const isRenote = ( const isRenote = (
props.note.renote != null && props.note.renote != null &&
@ -42,7 +42,7 @@ export async function getNoteClipMenu(props: {
}); });
if (!confirm.canceled) { if (!confirm.canceled) {
os.apiWithDialog('clips/remove-note', { clipId: clip.id, noteId: appearNote.id }); os.apiWithDialog('clips/remove-note', { clipId: clip.id, noteId: appearNote.id });
if (props.currentClipPage?.value.id === clip.id) props.isDeleted.value = true; if (props.currentClip?.id === clip.id) props.isDeleted.value = true;
} }
} else { } else {
os.alert({ os.alert({
@ -92,7 +92,7 @@ export function getNoteMenu(props: {
translation: Ref<any>; translation: Ref<any>;
translating: Ref<boolean>; translating: Ref<boolean>;
isDeleted: Ref<boolean>; isDeleted: Ref<boolean>;
currentClipPage?: Ref<misskey.entities.Clip>; currentClip?: misskey.entities.Clip;
}) { }) {
const isRenote = ( const isRenote = (
props.note.renote != null && props.note.renote != null &&
@ -176,7 +176,7 @@ export function getNoteMenu(props: {
} }
async function unclip(): Promise<void> { async function unclip(): Promise<void> {
os.apiWithDialog('clips/remove-note', { clipId: props.currentClipPage.value.id, noteId: appearNote.id }); os.apiWithDialog('clips/remove-note', { clipId: props.currentClip.id, noteId: appearNote.id });
props.isDeleted.value = true; props.isDeleted.value = true;
} }
@ -230,7 +230,7 @@ export function getNoteMenu(props: {
menu = [ menu = [
...( ...(
props.currentClipPage?.value.userId === $i.id ? [{ props.currentClip?.userId === $i.id ? [{
icon: 'ti ti-backspace', icon: 'ti ti-backspace',
text: i18n.ts.unclip, text: i18n.ts.unclip,
danger: true, danger: true,
@ -294,7 +294,7 @@ export function getNoteMenu(props: {
text: i18n.ts.muteThread, text: i18n.ts.muteThread,
action: () => toggleThreadMute(true), action: () => toggleThreadMute(true),
}), }),
appearNote.userId === $i.id ? ($i.pinnedNoteIds || []).includes(appearNote.id) ? { appearNote.userId === $i.id ? ($i.pinnedNoteIds ?? []).includes(appearNote.id) ? {
icon: 'ti ti-pinned-off', icon: 'ti ti-pinned-off',
text: i18n.ts.unpin, text: i18n.ts.unpin,
action: () => togglePin(false), action: () => togglePin(false),

View file

@ -1,4 +1,3 @@
import autobind from 'autobind-decorator';
import { ref, Ref, unref } from 'vue'; import { ref, Ref, unref } from 'vue';
import { collectPageVars } from '../collect-page-vars'; import { collectPageVars } from '../collect-page-vars';
import { initHpmlLib } from './lib'; import { initHpmlLib } from './lib';
@ -51,7 +50,6 @@ export class Hpml {
this.eval(); this.eval();
} }
@autobind
public eval() { public eval() {
try { try {
this.vars.value = this.evaluateVars(); this.vars.value = this.evaluateVars();
@ -60,7 +58,6 @@ export class Hpml {
} }
} }
@autobind
public interpolate(str: string) { public interpolate(str: string) {
if (str == null) return null; if (str == null) return null;
return str.replace(/{(.+?)}/g, match => { return str.replace(/{(.+?)}/g, match => {
@ -69,12 +66,10 @@ export class Hpml {
}); });
} }
@autobind
public registerCanvas(id: string, canvas: any) { public registerCanvas(id: string, canvas: any) {
this.canvases[id] = canvas; this.canvases[id] = canvas;
} }
@autobind
public updatePageVar(name: string, value: any) { public updatePageVar(name: string, value: any) {
const pageVar = this.pageVars.find(v => v.name === name); const pageVar = this.pageVars.find(v => v.name === name);
if (pageVar !== undefined) { if (pageVar !== undefined) {
@ -84,13 +79,11 @@ export class Hpml {
} }
} }
@autobind
public updateRandomSeed(seed: string) { public updateRandomSeed(seed: string) {
this.opts.randomSeed = seed; this.opts.randomSeed = seed;
this.envVars.SEED = seed; this.envVars.SEED = seed;
} }
@autobind
private _interpolateScope(str: string, scope: HpmlScope) { private _interpolateScope(str: string, scope: HpmlScope) {
return str.replace(/{(.+?)}/g, match => { return str.replace(/{(.+?)}/g, match => {
const v = scope.getState(match.slice(1, -1).trim()); const v = scope.getState(match.slice(1, -1).trim());
@ -98,7 +91,6 @@ export class Hpml {
}); });
} }
@autobind
public evaluateVars(): Record<string, any> { public evaluateVars(): Record<string, any> {
const values: Record<string, any> = {}; const values: Record<string, any> = {};
@ -117,7 +109,6 @@ export class Hpml {
return values; return values;
} }
@autobind
private evaluate(expr: Expr, scope: HpmlScope): any { private evaluate(expr: Expr, scope: HpmlScope): any {
if (isLiteralValue(expr)) { if (isLiteralValue(expr)) {
if (expr.type === null) { if (expr.type === null) {

View file

@ -2,7 +2,6 @@
* Hpml * Hpml
*/ */
import autobind from 'autobind-decorator';
import { Hpml } from './evaluator'; import { Hpml } from './evaluator';
import { funcDefs } from './lib'; import { funcDefs } from './lib';
@ -61,7 +60,6 @@ export class HpmlScope {
this.name = name ?? 'anonymous'; this.name = name ?? 'anonymous';
} }
@autobind
public createChildScope(states: Record<string, any>, name?: HpmlScope['name']): HpmlScope { public createChildScope(states: Record<string, any>, name?: HpmlScope['name']): HpmlScope {
const layer = [states, ...this.layerdStates]; const layer = [states, ...this.layerdStates];
return new HpmlScope(layer, name); return new HpmlScope(layer, name);
@ -71,7 +69,6 @@ export class HpmlScope {
* *
* @param name * @param name
*/ */
@autobind
public getState(name: string): any { public getState(name: string): any {
for (const later of this.layerdStates) { for (const later of this.layerdStates) {
const state = later[name]; const state = later[name];

View file

@ -1,4 +1,3 @@
import autobind from 'autobind-decorator';
import { isLiteralValue } from './expr'; import { isLiteralValue } from './expr';
import { funcDefs } from './lib'; import { funcDefs } from './lib';
import { envVarsDef } from '.'; import { envVarsDef } from '.';
@ -23,7 +22,6 @@ export class HpmlTypeChecker {
this.pageVars = pageVars; this.pageVars = pageVars;
} }
@autobind
public typeCheck(v: Expr): TypeError | null { public typeCheck(v: Expr): TypeError | null {
if (isLiteralValue(v)) return null; if (isLiteralValue(v)) return null;
@ -61,7 +59,6 @@ export class HpmlTypeChecker {
return null; return null;
} }
@autobind
public getExpectedType(v: Expr, slot: number): Type { public getExpectedType(v: Expr, slot: number): Type {
const def = funcDefs[v.type ?? '']; const def = funcDefs[v.type ?? ''];
if (def == null) { if (def == null) {
@ -89,7 +86,6 @@ export class HpmlTypeChecker {
} }
} }
@autobind
public infer(v: Expr): Type { public infer(v: Expr): Type {
if (v.type === null) return null; if (v.type === null) return null;
if (v.type === 'text') return 'string'; if (v.type === 'text') return 'string';
@ -144,7 +140,6 @@ export class HpmlTypeChecker {
} }
} }
@autobind
public getVarByName(name: string): Variable { public getVarByName(name: string): Variable {
const v = this.variables.find(x => x.name === name); const v = this.variables.find(x => x.name === name);
if (v !== undefined) { if (v !== undefined) {
@ -154,25 +149,21 @@ export class HpmlTypeChecker {
} }
} }
@autobind
public getVarsByType(type: Type): Variable[] { public getVarsByType(type: Type): Variable[] {
if (type == null) return this.variables; if (type == null) return this.variables;
return this.variables.filter(x => (this.infer(x) === null) || (this.infer(x) === type)); return this.variables.filter(x => (this.infer(x) === null) || (this.infer(x) === type));
} }
@autobind
public getEnvVarsByType(type: Type): string[] { public getEnvVarsByType(type: Type): string[] {
if (type == null) return Object.keys(envVarsDef); if (type == null) return Object.keys(envVarsDef);
return Object.entries(envVarsDef).filter(([k, v]) => v === null || type === v).map(([k, v]) => k); return Object.entries(envVarsDef).filter(([k, v]) => v === null || type === v).map(([k, v]) => k);
} }
@autobind
public getPageVarsByType(type: Type): string[] { public getPageVarsByType(type: Type): string[] {
if (type == null) return this.pageVars.map(v => v.name); if (type == null) return this.pageVars.map(v => v.name);
return this.pageVars.filter(v => type === v.type).map(v => v.name); return this.pageVars.filter(v => type === v.type).map(v => v.name);
} }
@autobind
public isUsedName(name: string) { public isUsedName(name: string) {
if (this.variables.some(v => v.name === name)) { if (this.variables.some(v => v.name === name)) {
return true; return true;

View file

@ -294,6 +294,10 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device', where: 'device',
default: false, default: false,
}, },
largeNoteReactions: {
where: 'device',
default: false,
},
aiChanMode: { aiChanMode: {
where: 'device', where: 'device',
default: false, default: false,

View file

@ -0,0 +1,9 @@
module.exports = {
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
extends: [
'../shared/.eslintrc.js',
],
};

View file

@ -1,57 +0,0 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
'indent': ['error', 'tab', {
'SwitchCase': 1,
'MemberExpression': 'off',
'flatTernaryExpressions': true,
'ArrayExpression': 'first',
'ObjectExpression': 'first',
}],
'eol-last': ['error', 'always'],
'semi': ['error', 'always'],
'quotes': ['error', 'single'],
'comma-dangle': ['error', 'always-multiline'],
'keyword-spacing': ['error', {
'before': true,
'after': true,
}],
'key-spacing': ['error', {
'beforeColon': false,
'afterColon': true,
}],
'space-infix-ops': ['error'],
'space-before-blocks': ['error', 'always'],
'object-curly-spacing': ['error', 'always'],
'nonblock-statement-body-position': ['error', 'beside'],
'eqeqeq': ['error', 'always', { 'null': 'ignore' }],
'no-multiple-empty-lines': ['error', { 'max': 1 }],
'no-multi-spaces': ['error'],
'no-var': ['error'],
'prefer-arrow-callback': ['error'],
'no-throw-literal': ['error'],
'no-param-reassign': ['warn'],
'no-constant-condition': ['warn'],
'no-empty-pattern': ['warn'],
'@typescript-eslint/no-unnecessary-condition': ['error'],
'@typescript-eslint/no-inferrable-types': ['warn'],
'@typescript-eslint/no-non-null-assertion': ['warn'],
'@typescript-eslint/explicit-function-return-type': ['warn'],
'@typescript-eslint/no-misused-promises': ['error', {
'checksVoidReturn': false,
}],
'@typescript-eslint/consistent-type-imports': 'error',
},
};

View file

@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"parser": {
"syntax": "typescript",
"dynamicImport": true,
"decorators": true
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true
},
"experimental": {
"keepImportAssertions": true
},
"baseUrl": "src",
"paths": {
"@/*": ["*"]
},
"target": "es2022"
},
"minify": false
}

View file

@ -3,7 +3,7 @@
* https://jestjs.io/docs/en/configuration.html * https://jestjs.io/docs/en/configuration.html
*/ */
export default { module.exports = {
// All imported modules in your tests should be mocked automatically // All imported modules in your tests should be mocked automatically
// automock: false, // automock: false,
@ -174,7 +174,7 @@ export default {
// A map from regular expressions to paths to transformers // A map from regular expressions to paths to transformers
transform: { transform: {
"^.+\\.(ts|tsx)$": "ts-jest" "^.+\\.(t|j)sx?$": ["@swc/jest"],
}, },
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation

View file

@ -6,42 +6,41 @@
"types": "./built/index.d.ts", "types": "./built/index.d.ts",
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"tsc": "tsc",
"tsd": "tsd", "tsd": "tsd",
"api": "pnpm api-extractor run --local --verbose", "api": "pnpm api-extractor run --local --verbose",
"api-prod": "pnpm api-extractor run --verbose", "api-prod": "pnpm api-extractor run --verbose",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx", "eslint": "eslint . --ext .js,.jsx,.ts,.tsx",
"typecheck": "tsc --noEmit",
"lint": "pnpm typecheck && pnpm eslint",
"jest": "jest --coverage --detectOpenHandles", "jest": "jest --coverage --detectOpenHandles",
"test": "pnpm jest && pnpm tsd", "test": "pnpm jest && pnpm tsd"
"eslint": "pnpm lint",
"typecheck": "tsc --noEmit"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/misskey-dev/misskey.js.git" "url": "git+https://github.com/misskey-dev/misskey.js.git"
}, },
"devDependencies": { "devDependencies": {
"@microsoft/api-extractor": "^7.19.3", "@microsoft/api-extractor": "7.34.4",
"@types/jest": "^29.5.0", "@types/jest": "29.5.0",
"@types/node": "18.15.0", "@types/node": "18.15.11",
"@typescript-eslint/eslint-plugin": "5.8.1", "@typescript-eslint/eslint-plugin": "5.57.0",
"@typescript-eslint/parser": "5.8.1", "@typescript-eslint/parser": "5.57.0",
"eslint": "8.6.0", "@swc/jest": "0.2.24",
"eslint": "8.37.0",
"jest": "^29.5.0", "jest": "^29.5.0",
"jest-fetch-mock": "^3.0.3", "jest-fetch-mock": "^3.0.3",
"jest-websocket-mock": "^2.2.1", "jest-websocket-mock": "2.4.0",
"mock-socket": "^9.0.8", "mock-socket": "9.2.1",
"ts-jest": "^29.0.5", "tsd": "0.28.1",
"ts-node": "10.4.0", "typescript": "5.0.2"
"tsd": "^0.19.1",
"typescript": "4.5.4"
}, },
"files": [ "files": [
"built" "built"
], ],
"dependencies": { "dependencies": {
"autobind-decorator": "^2.4.0", "@swc/cli": "0.1.62",
"eventemitter3": "^4.0.7", "@swc/core": "1.3.42",
"eventemitter3": "5.0.0",
"reconnecting-websocket": "^4.4.0" "reconnecting-websocket": "^4.4.0"
} }
} }

View file

@ -1,4 +1,4 @@
import type { Endpoints } from './api.types'; import type { Endpoints } from './api.types.js';
const MK_API_ERROR = Symbol(); const MK_API_ERROR = Symbol();
@ -49,7 +49,7 @@ export class APIClient {
this.credential = opts.credential; this.credential = opts.credential;
// ネイティブ関数をそのまま変数に代入して使おうとするとChromiumではIllegal invocationエラーが発生するため、 // ネイティブ関数をそのまま変数に代入して使おうとするとChromiumではIllegal invocationエラーが発生するため、
// 環境で実装されているfetchを使う場合は無名関数でラップして使用する // 環境で実装されているfetchを使う場合は無名関数でラップして使用する
this.fetch = opts.fetch || ((...args) => fetch(...args)); this.fetch = opts.fetch ?? ((...args) => fetch(...args));
} }
public request<E extends keyof Endpoints, P extends Endpoints[E]['req']>( public request<E extends keyof Endpoints, P extends Endpoints[E]['req']>(

View file

@ -3,7 +3,7 @@ import type {
LiteInstanceMetadata, LiteInstanceMetadata,
MeDetailed, MeDetailed,
Note, NoteFavorite, OriginType, Page, ServerInfo, Stats, User, UserDetailed, UserGroup, UserList, UserSorting, Notification, NoteReaction, Signin, MessagingMessage, Note, NoteFavorite, OriginType, Page, ServerInfo, Stats, User, UserDetailed, UserGroup, UserList, UserSorting, Notification, NoteReaction, Signin, MessagingMessage,
} from './entities'; } from './entities.js';
type TODO = Record<string, any> | null; type TODO = Record<string, any> | null;

View file

@ -1,8 +1,8 @@
import { Endpoints } from './api.types'; import { Endpoints } from './api.types.js';
import Stream, { Connection } from './streaming'; import Stream, { Connection } from './streaming.js';
import { Channels } from './streaming.types'; import { Channels } from './streaming.types.js';
import { Acct } from './acct'; import { Acct } from './acct.js';
import * as consts from './consts'; import * as consts from './consts.js';
export { export {
Endpoints, Endpoints,
@ -19,8 +19,8 @@ export const mutedNoteReasons = consts.mutedNoteReasons;
export const ffVisibility = consts.ffVisibility; export const ffVisibility = consts.ffVisibility;
// api extractor not supported yet // api extractor not supported yet
//export * as api from './api'; //export * as api from './api.js';
//export * as entities from './entities'; //export * as entities from './entities.js';
import * as api from './api'; import * as api from './api.js';
import * as entities from './entities'; import * as entities from './entities.js';
export { api, entities }; export { api, entities };

View file

@ -1,7 +1,6 @@
import autobind from 'autobind-decorator';
import { EventEmitter } from 'eventemitter3'; import { EventEmitter } from 'eventemitter3';
import ReconnectingWebsocket from 'reconnecting-websocket'; import ReconnectingWebsocket from 'reconnecting-websocket';
import type { BroadcastEvents, Channels } from './streaming.types'; import type { BroadcastEvents, Channels } from './streaming.types.js';
export function urlQuery(obj: Record<string, string | number | boolean | undefined>): string { export function urlQuery(obj: Record<string, string | number | boolean | undefined>): string {
const params = Object.entries(obj) const params = Object.entries(obj)
@ -36,7 +35,21 @@ export default class Stream extends EventEmitter<StreamEvents> {
WebSocket?: any; WebSocket?: any;
}) { }) {
super(); super();
options = options || { };
this.genId = this.genId.bind(this);
this.useChannel = this.useChannel.bind(this);
this.useSharedConnection = this.useSharedConnection.bind(this);
this.removeSharedConnection = this.removeSharedConnection.bind(this);
this.removeSharedConnectionPool = this.removeSharedConnectionPool.bind(this);
this.connectToChannel = this.connectToChannel.bind(this);
this.disconnectToChannel = this.disconnectToChannel.bind(this);
this.onOpen = this.onOpen.bind(this);
this.onClose = this.onClose.bind(this);
this.onMessage = this.onMessage.bind(this);
this.send = this.send.bind(this);
this.close = this.close.bind(this);
options = options ?? { };
const query = urlQuery({ const query = urlQuery({
i: user?.token, i: user?.token,
@ -56,12 +69,10 @@ export default class Stream extends EventEmitter<StreamEvents> {
this.stream.addEventListener('message', this.onMessage); this.stream.addEventListener('message', this.onMessage);
} }
@autobind
private genId(): string { private genId(): string {
return (++this.idCounter).toString(); return (++this.idCounter).toString();
} }
@autobind
public useChannel<C extends keyof Channels>(channel: C, params?: Channels[C]['params'], name?: string): Connection<Channels[C]> { public useChannel<C extends keyof Channels>(channel: C, params?: Channels[C]['params'], name?: string): Connection<Channels[C]> {
if (params) { if (params) {
return this.connectToChannel(channel, params); return this.connectToChannel(channel, params);
@ -70,7 +81,6 @@ export default class Stream extends EventEmitter<StreamEvents> {
} }
} }
@autobind
private useSharedConnection<C extends keyof Channels>(channel: C, name?: string): SharedConnection<Channels[C]> { private useSharedConnection<C extends keyof Channels>(channel: C, name?: string): SharedConnection<Channels[C]> {
let pool = this.sharedConnectionPools.find(p => p.channel === channel); let pool = this.sharedConnectionPools.find(p => p.channel === channel);
@ -84,24 +94,20 @@ export default class Stream extends EventEmitter<StreamEvents> {
return connection; return connection;
} }
@autobind
public removeSharedConnection(connection: SharedConnection): void { public removeSharedConnection(connection: SharedConnection): void {
this.sharedConnections = this.sharedConnections.filter(c => c !== connection); this.sharedConnections = this.sharedConnections.filter(c => c !== connection);
} }
@autobind
public removeSharedConnectionPool(pool: Pool): void { public removeSharedConnectionPool(pool: Pool): void {
this.sharedConnectionPools = this.sharedConnectionPools.filter(p => p !== pool); this.sharedConnectionPools = this.sharedConnectionPools.filter(p => p !== pool);
} }
@autobind
private connectToChannel<C extends keyof Channels>(channel: C, params: Channels[C]['params']): NonSharedConnection<Channels[C]> { private connectToChannel<C extends keyof Channels>(channel: C, params: Channels[C]['params']): NonSharedConnection<Channels[C]> {
const connection = new NonSharedConnection(this, channel, this.genId(), params); const connection = new NonSharedConnection(this, channel, this.genId(), params);
this.nonSharedConnections.push(connection); this.nonSharedConnections.push(connection);
return connection; return connection;
} }
@autobind
public disconnectToChannel(connection: NonSharedConnection): void { public disconnectToChannel(connection: NonSharedConnection): void {
this.nonSharedConnections = this.nonSharedConnections.filter(c => c !== connection); this.nonSharedConnections = this.nonSharedConnections.filter(c => c !== connection);
} }
@ -109,7 +115,6 @@ export default class Stream extends EventEmitter<StreamEvents> {
/** /**
* Callback of when open connection * Callback of when open connection
*/ */
@autobind
private onOpen(): void { private onOpen(): void {
const isReconnect = this.state === 'reconnecting'; const isReconnect = this.state === 'reconnecting';
@ -126,7 +131,6 @@ export default class Stream extends EventEmitter<StreamEvents> {
/** /**
* Callback of when close connection * Callback of when close connection
*/ */
@autobind
private onClose(): void { private onClose(): void {
if (this.state === 'connected') { if (this.state === 'connected') {
this.state = 'reconnecting'; this.state = 'reconnecting';
@ -137,7 +141,6 @@ export default class Stream extends EventEmitter<StreamEvents> {
/** /**
* Callback of when received a message from connection * Callback of when received a message from connection
*/ */
@autobind
private onMessage(message: { data: string; }): void { private onMessage(message: { data: string; }): void {
const { type, body } = JSON.parse(message.data); const { type, body } = JSON.parse(message.data);
@ -167,7 +170,6 @@ export default class Stream extends EventEmitter<StreamEvents> {
/** /**
* Send a message to connection * Send a message to connection
*/ */
@autobind
public send(typeOrPayload: any, payload?: any): void { public send(typeOrPayload: any, payload?: any): void {
const data = payload === undefined ? typeOrPayload : { const data = payload === undefined ? typeOrPayload : {
type: typeOrPayload, type: typeOrPayload,
@ -180,7 +182,6 @@ export default class Stream extends EventEmitter<StreamEvents> {
/** /**
* Close this connection * Close this connection
*/ */
@autobind
public close(): void { public close(): void {
this.stream.close(); this.stream.close();
} }
@ -197,6 +198,12 @@ class Pool {
private isConnected = false; private isConnected = false;
constructor(stream: Stream, channel: string, id: string) { constructor(stream: Stream, channel: string, id: string) {
this.onStreamDisconnected = this.onStreamDisconnected.bind(this);
this.inc = this.inc.bind(this);
this.dec = this.dec.bind(this);
this.connect = this.connect.bind(this);
this.disconnect = this.disconnect.bind(this);
this.channel = channel; this.channel = channel;
this.stream = stream; this.stream = stream;
this.id = id; this.id = id;
@ -204,12 +211,10 @@ class Pool {
this.stream.on('_disconnected_', this.onStreamDisconnected); this.stream.on('_disconnected_', this.onStreamDisconnected);
} }
@autobind
private onStreamDisconnected(): void { private onStreamDisconnected(): void {
this.isConnected = false; this.isConnected = false;
} }
@autobind
public inc(): void { public inc(): void {
if (this.users === 0 && !this.isConnected) { if (this.users === 0 && !this.isConnected) {
this.connect(); this.connect();
@ -224,7 +229,6 @@ class Pool {
} }
} }
@autobind
public dec(): void { public dec(): void {
this.users--; this.users--;
@ -238,7 +242,6 @@ class Pool {
} }
} }
@autobind
public connect(): void { public connect(): void {
if (this.isConnected) return; if (this.isConnected) return;
this.isConnected = true; this.isConnected = true;
@ -248,7 +251,6 @@ class Pool {
}); });
} }
@autobind
private disconnect(): void { private disconnect(): void {
this.stream.off('_disconnected_', this.onStreamDisconnected); this.stream.off('_disconnected_', this.onStreamDisconnected);
this.stream.send('disconnect', { id: this.id }); this.stream.send('disconnect', { id: this.id });
@ -268,12 +270,13 @@ export abstract class Connection<Channel extends AnyOf<Channels> = any> extends
constructor(stream: Stream, channel: string, name?: string) { constructor(stream: Stream, channel: string, name?: string) {
super(); super();
this.send = this.send.bind(this);
this.stream = stream; this.stream = stream;
this.channel = channel; this.channel = channel;
this.name = name; this.name = name;
} }
@autobind
public send<T extends keyof Channel['receives']>(type: T, body: Channel['receives'][T]): void { public send<T extends keyof Channel['receives']>(type: T, body: Channel['receives'][T]): void {
this.stream.send('ch', { this.stream.send('ch', {
id: this.id, id: this.id,
@ -297,11 +300,12 @@ class SharedConnection<Channel extends AnyOf<Channels> = any> extends Connection
constructor(stream: Stream, channel: string, pool: Pool, name?: string) { constructor(stream: Stream, channel: string, pool: Pool, name?: string) {
super(stream, channel, name); super(stream, channel, name);
this.dispose = this.dispose.bind(this);
this.pool = pool; this.pool = pool;
this.pool.inc(); this.pool.inc();
} }
@autobind
public dispose(): void { public dispose(): void {
this.pool.dec(); this.pool.dec();
this.removeAllListeners(); this.removeAllListeners();
@ -316,13 +320,15 @@ class NonSharedConnection<Channel extends AnyOf<Channels> = any> extends Connect
constructor(stream: Stream, channel: string, id: string, params: Channel['params']) { constructor(stream: Stream, channel: string, id: string, params: Channel['params']) {
super(stream, channel); super(stream, channel);
this.connect = this.connect.bind(this);
this.dispose = this.dispose.bind(this);
this.params = params; this.params = params;
this.id = id; this.id = id;
this.connect(); this.connect();
} }
@autobind
public connect(): void { public connect(): void {
this.stream.send('connect', { this.stream.send('connect', {
channel: this.channel, channel: this.channel,
@ -331,7 +337,6 @@ class NonSharedConnection<Channel extends AnyOf<Channels> = any> extends Connect
}); });
} }
@autobind
public dispose(): void { public dispose(): void {
this.removeAllListeners(); this.removeAllListeners();
this.stream.send('disconnect', { id: this.id }); this.stream.send('disconnect', { id: this.id });

View file

@ -1,4 +1,4 @@
import type { Antenna, CustomEmoji, DriveFile, MeDetailed, MessagingMessage, Note, Notification, PageEvent, User, UserGroup } from './entities'; import type { Antenna, CustomEmoji, DriveFile, MeDetailed, MessagingMessage, Note, Notification, PageEvent, User, UserGroup } from './entities.js';
type FIXME = any; type FIXME = any;

View file

@ -1,5 +1,5 @@
import { APIClient, isAPIError } from '../src/api';
import { enableFetchMocks } from 'jest-fetch-mock'; import { enableFetchMocks } from 'jest-fetch-mock';
import { APIClient, isAPIError } from '../src/api';
enableFetchMocks(); enableFetchMocks();

View file

@ -1,8 +1,9 @@
{ {
"$schema": "http://json.schemastore.org/tsconfig", "$schema": "http://json.schemastore.org/tsconfig",
"compilerOptions": { "compilerOptions": {
"target": "es2020", "target": "es2022",
"module": "commonjs", "module": "ES2020",
"moduleResolution": "node",
"declaration": true, "declaration": true,
"declarationMap": true, "declarationMap": true,
"sourceMap": true, "sourceMap": true,
@ -13,7 +14,14 @@
"strictNullChecks": true, "strictNullChecks": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"noImplicitReturns": true, "noImplicitReturns": true,
"esModuleInterop": true "esModuleInterop": true,
"typeRoots": [
"node_modules/@types"
],
"lib": [
"esnext",
"dom"
]
}, },
"include": [ "include": [
"src/**/*" "src/**/*"

View file

@ -11,13 +11,13 @@
"dependencies": { "dependencies": {
"esbuild": "0.14.42", "esbuild": "0.14.42",
"idb-keyval": "6.2.0", "idb-keyval": "6.2.0",
"misskey-js": "../misskey-js" "misskey-js": "workspace:*"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/parser": "5.52.0", "@typescript-eslint/parser": "5.57.0",
"@typescript/lib-webworker": "npm:@types/serviceworker@0.0.62", "@typescript/lib-webworker": "npm:@types/serviceworker@0.0.67",
"eslint": "8.34.0", "eslint": "8.37.0",
"eslint-plugin-import": "2.27.5", "eslint-plugin-import": "2.27.5",
"typescript": "4.9.5" "typescript": "5.0.2"
} }
} }

File diff suppressed because it is too large Load diff