mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-13 21:40:45 +01:00
parent
f0a70a70c3
commit
9bc5d52e41
18 changed files with 155 additions and 72 deletions
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
### General
|
### General
|
||||||
- チャンネルをお気に入りに登録できるように
|
- チャンネルをお気に入りに登録できるように
|
||||||
|
- チャンネルにノートをピン留めできるように
|
||||||
|
|
||||||
### Client
|
### Client
|
||||||
- 検索ページでURLを入力した際に照会したときと同等の挙動をするように
|
- 検索ページでURLを入力した際に照会したときと同等の挙動をするように
|
||||||
|
|
|
@ -984,6 +984,7 @@ enableChartsForRemoteUser: "リモートユーザーのチャートを生成"
|
||||||
enableChartsForFederatedInstances: "リモートサーバーのチャートを生成"
|
enableChartsForFederatedInstances: "リモートサーバーのチャートを生成"
|
||||||
showClipButtonInNoteFooter: "ノートのアクションにクリップを追加"
|
showClipButtonInNoteFooter: "ノートのアクションにクリップを追加"
|
||||||
largeNoteReactions: "ノートのリアクションを大きく表示"
|
largeNoteReactions: "ノートのリアクションを大きく表示"
|
||||||
|
noteIdOrUrl: "ノートIDまたはURL"
|
||||||
|
|
||||||
_achievements:
|
_achievements:
|
||||||
earnedAt: "獲得日時"
|
earnedAt: "獲得日時"
|
||||||
|
|
|
@ -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"`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 { ChannelFavoritesRepository, 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 {
|
||||||
|
@ -21,13 +22,16 @@ export class ChannelEntityService {
|
||||||
@Inject(DI.channelFavoritesRepository)
|
@Inject(DI.channelFavoritesRepository)
|
||||||
private channelFavoritesRepository: 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,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
@ -36,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;
|
||||||
|
@ -54,6 +59,12 @@ export class ChannelEntityService {
|
||||||
channelId: channel.id,
|
channelId: channel.id,
|
||||||
}) : null;
|
}) : 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(),
|
||||||
|
@ -62,6 +73,7 @@ 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,
|
||||||
|
|
||||||
|
@ -70,6 +82,10 @@ export class ChannelEntityService {
|
||||||
isFavorited: favorite != null,
|
isFavorited: favorite != null,
|
||||||
hasUnreadNote,
|
hasUnreadNote,
|
||||||
} : {}),
|
} : {}),
|
||||||
|
|
||||||
|
...(detailed ? {
|
||||||
|
pinnedNotes: await this.noteEntityService.packMany(pinnedNotes, me),
|
||||||
|
} : {}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,6 @@ export const DI = {
|
||||||
channelsRepository: Symbol('channelsRepository'),
|
channelsRepository: Symbol('channelsRepository'),
|
||||||
channelFollowingsRepository: Symbol('channelFollowingsRepository'),
|
channelFollowingsRepository: Symbol('channelFollowingsRepository'),
|
||||||
channelFavoritesRepository: Symbol('channelFavoritesRepository'),
|
channelFavoritesRepository: Symbol('channelFavoritesRepository'),
|
||||||
channelNotePiningsRepository: Symbol('channelNotePiningsRepository'),
|
|
||||||
registryItemsRepository: Symbol('registryItemsRepository'),
|
registryItemsRepository: Symbol('registryItemsRepository'),
|
||||||
webhooksRepository: Symbol('webhooksRepository'),
|
webhooksRepository: Symbol('webhooksRepository'),
|
||||||
adsRepository: Symbol('adsRepository'),
|
adsRepository: Symbol('adsRepository'),
|
||||||
|
|
|
@ -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, ChannelFavorite, 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';
|
||||||
|
|
||||||
|
@ -346,12 +346,6 @@ const $channelFavoritesRepository: Provider = {
|
||||||
inject: [DI.db],
|
inject: [DI.db],
|
||||||
};
|
};
|
||||||
|
|
||||||
const $channelNotePiningsRepository: Provider = {
|
|
||||||
provide: DI.channelNotePiningsRepository,
|
|
||||||
useFactory: (db: DataSource) => db.getRepository(ChannelNotePining),
|
|
||||||
inject: [DI.db],
|
|
||||||
};
|
|
||||||
|
|
||||||
const $registryItemsRepository: Provider = {
|
const $registryItemsRepository: Provider = {
|
||||||
provide: DI.registryItemsRepository,
|
provide: DI.registryItemsRepository,
|
||||||
useFactory: (db: DataSource) => db.getRepository(RegistryItem),
|
useFactory: (db: DataSource) => db.getRepository(RegistryItem),
|
||||||
|
@ -467,7 +461,6 @@ const $roleAssignmentsRepository: Provider = {
|
||||||
$channelsRepository,
|
$channelsRepository,
|
||||||
$channelFollowingsRepository,
|
$channelFollowingsRepository,
|
||||||
$channelFavoritesRepository,
|
$channelFavoritesRepository,
|
||||||
$channelNotePiningsRepository,
|
|
||||||
$registryItemsRepository,
|
$registryItemsRepository,
|
||||||
$webhooksRepository,
|
$webhooksRepository,
|
||||||
$adsRepository,
|
$adsRepository,
|
||||||
|
@ -536,7 +529,6 @@ const $roleAssignmentsRepository: Provider = {
|
||||||
$channelsRepository,
|
$channelsRepository,
|
||||||
$channelFollowingsRepository,
|
$channelFollowingsRepository,
|
||||||
$channelFavoritesRepository,
|
$channelFavoritesRepository,
|
||||||
$channelNotePiningsRepository,
|
|
||||||
$registryItemsRepository,
|
$registryItemsRepository,
|
||||||
$webhooksRepository,
|
$webhooksRepository,
|
||||||
$adsRepository,
|
$adsRepository,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
|
|
||||||
import { id } from '../id.js';
|
|
||||||
import { Note } from './Note.js';
|
|
||||||
import { Channel } from './Channel.js';
|
|
||||||
|
|
||||||
@Entity()
|
|
||||||
@Index(['channelId', 'noteId'], { unique: true })
|
|
||||||
export class ChannelNotePining {
|
|
||||||
@PrimaryColumn(id())
|
|
||||||
public id: string;
|
|
||||||
|
|
||||||
@Column('timestamp with time zone', {
|
|
||||||
comment: 'The created date of the ChannelNotePining.',
|
|
||||||
})
|
|
||||||
public createdAt: Date;
|
|
||||||
|
|
||||||
@Index()
|
|
||||||
@Column(id())
|
|
||||||
public channelId: Channel['id'];
|
|
||||||
|
|
||||||
@ManyToOne(type => Channel, {
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
})
|
|
||||||
@JoinColumn()
|
|
||||||
public channel: Channel | null;
|
|
||||||
|
|
||||||
@Column(id())
|
|
||||||
public noteId: Note['id'];
|
|
||||||
|
|
||||||
@ManyToOne(type => Note, {
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
})
|
|
||||||
@JoinColumn()
|
|
||||||
public note: Note | null;
|
|
||||||
}
|
|
|
@ -11,7 +11,6 @@ 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 { ChannelFavorite } from '@/models/entities/ChannelFavorite.js';
|
import { ChannelFavorite } from '@/models/entities/ChannelFavorite.js';
|
||||||
import { ChannelNotePining } from '@/models/entities/ChannelNotePining.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';
|
||||||
|
@ -81,7 +80,6 @@ export {
|
||||||
Blocking,
|
Blocking,
|
||||||
ChannelFollowing,
|
ChannelFollowing,
|
||||||
ChannelFavorite,
|
ChannelFavorite,
|
||||||
ChannelNotePining,
|
|
||||||
Clip,
|
Clip,
|
||||||
ClipNote,
|
ClipNote,
|
||||||
ClipFavorite,
|
ClipFavorite,
|
||||||
|
@ -150,7 +148,6 @@ 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 ChannelFavoritesRepository = Repository<ChannelFavorite>;
|
export type ChannelFavoritesRepository = Repository<ChannelFavorite>;
|
||||||
export type ChannelNotePiningsRepository = Repository<ChannelNotePining>;
|
|
||||||
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>;
|
||||||
|
|
|
@ -51,5 +51,13 @@ export const packedChannelSchema = {
|
||||||
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;
|
||||||
|
|
|
@ -19,7 +19,6 @@ 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 { ChannelFavorite } from '@/models/entities/ChannelFavorite.js';
|
import { ChannelFavorite } from '@/models/entities/ChannelFavorite.js';
|
||||||
import { ChannelNotePining } from '@/models/entities/ChannelNotePining.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';
|
||||||
|
@ -177,7 +176,6 @@ export const entities = [
|
||||||
Channel,
|
Channel,
|
||||||
ChannelFollowing,
|
ChannelFollowing,
|
||||||
ChannelFavorite,
|
ChannelFavorite,
|
||||||
ChannelNotePining,
|
|
||||||
RegistryItem,
|
RegistryItem,
|
||||||
Ad,
|
Ad,
|
||||||
PasswordResetRequest,
|
PasswordResetRequest,
|
||||||
|
|
|
@ -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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -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 } : {}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -19,6 +19,13 @@
|
||||||
|
|
||||||
<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-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>
|
<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">
|
||||||
<!-- スマホ・タブレットの場合、キーボードが表示されると投稿が見づらくなるので、デスクトップ場合のみ自動でフォーカスを当てる -->
|
<!-- スマホ・タブレットの場合、キーボードが表示されると投稿が見づらくなるので、デスクトップ場合のみ自動でフォーカスを当てる -->
|
||||||
|
@ -57,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();
|
||||||
|
|
||||||
|
|
|
@ -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', {
|
||||||
|
|
|
@ -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),
|
||||||
|
|
Loading…
Reference in a new issue