merge: Add feed of latest posts by followed users (!640)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/640 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
commit
32a97a5a05
28 changed files with 1036 additions and 4 deletions
|
@ -91,6 +91,7 @@ note: "Note"
|
|||
notes: "Notes"
|
||||
following: "Following"
|
||||
followers: "Followers"
|
||||
mutuals: "Mutuals"
|
||||
followsYou: "Follows you"
|
||||
createList: "Create list"
|
||||
manageLists: "Manage lists"
|
||||
|
@ -706,6 +707,7 @@ regexpError: "Regular Expression error"
|
|||
regexpErrorDescription: "An error occurred in the regular expression on line {line} of your {tab} word mutes:"
|
||||
instanceMute: "Instance Mutes"
|
||||
userSaysSomething: "{name} said something"
|
||||
postFiltered: "post is hidden by a filter"
|
||||
makeActive: "Activate"
|
||||
display: "Display"
|
||||
copy: "Copy"
|
||||
|
|
8
locales/index.d.ts
vendored
8
locales/index.d.ts
vendored
|
@ -380,6 +380,10 @@ export interface Locale extends ILocale {
|
|||
* フォロワー
|
||||
*/
|
||||
"followers": string;
|
||||
/**
|
||||
* Mutuals
|
||||
*/
|
||||
"mutuals": string;
|
||||
/**
|
||||
* フォローされています
|
||||
*/
|
||||
|
@ -2840,6 +2844,10 @@ export interface Locale extends ILocale {
|
|||
* {name}が何かを言いました
|
||||
*/
|
||||
"userSaysSomething": ParameterizedString<"name">;
|
||||
/**
|
||||
* post is hidden by a filter
|
||||
*/
|
||||
"postFiltered": string;
|
||||
/**
|
||||
* アクティブにする
|
||||
*/
|
||||
|
|
|
@ -91,6 +91,7 @@ note: "ノート"
|
|||
notes: "ノート"
|
||||
following: "フォロー"
|
||||
followers: "フォロワー"
|
||||
mutuals: "Mutuals"
|
||||
followsYou: "フォローされています"
|
||||
createList: "リスト作成"
|
||||
manageLists: "リストの管理"
|
||||
|
@ -706,6 +707,7 @@ regexpError: "正規表現エラー"
|
|||
regexpErrorDescription: "{tab}ワードミュートの{line}行目の正規表現にエラーが発生しました:"
|
||||
instanceMute: "サーバーミュート"
|
||||
userSaysSomething: "{name}が何かを言いました"
|
||||
postFiltered: "post is hidden by a filter"
|
||||
makeActive: "アクティブにする"
|
||||
display: "表示"
|
||||
copy: "コピー"
|
||||
|
|
20
packages/backend/migration/1727659258948-add_latest_note.js
Normal file
20
packages/backend/migration/1727659258948-add_latest_note.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class AddLatestNote1727659258948 {
|
||||
name = 'AddLatestNote1727659258948';
|
||||
|
||||
async up(queryRunner) {
|
||||
await queryRunner.query('CREATE TABLE "latest_note" ("user_id" character varying(32) NOT NULL, "note_id" character varying(32) NOT NULL, CONSTRAINT "PK_f619b62bfaafabe68f52fb50c9a" PRIMARY KEY ("user_id"))');
|
||||
await queryRunner.query('ALTER TABLE "latest_note" ADD CONSTRAINT "FK_20e346fffe4a2174585005d6d80" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION');
|
||||
await queryRunner.query('ALTER TABLE "latest_note" ADD CONSTRAINT "FK_47a38b1c13de6ce4e5090fb1acd" FOREIGN KEY ("note_id") REFERENCES "note"("id") ON DELETE CASCADE ON UPDATE NO ACTION');
|
||||
}
|
||||
|
||||
async down(queryRunner) {
|
||||
await queryRunner.query('ALTER TABLE "latest_note" DROP CONSTRAINT "FK_47a38b1c13de6ce4e5090fb1acd"');
|
||||
await queryRunner.query('ALTER TABLE "latest_note" DROP CONSTRAINT "FK_20e346fffe4a2174585005d6d80"');
|
||||
await queryRunner.query('DROP TABLE "latest_note"');
|
||||
}
|
||||
}
|
|
@ -14,7 +14,8 @@ import { extractCustomEmojisFromMfm } from '@/misc/extract-custom-emojis-from-mf
|
|||
import { extractHashtags } from '@/misc/extract-hashtags.js';
|
||||
import type { IMentionedRemoteUsers } from '@/models/Note.js';
|
||||
import { MiNote } from '@/models/Note.js';
|
||||
import type { ChannelFollowingsRepository, ChannelsRepository, FollowingsRepository, InstancesRepository, MiFollowing, MutingsRepository, NotesRepository, NoteThreadMutingsRepository, UserListMembershipsRepository, UserProfilesRepository, UsersRepository } from '@/models/_.js';
|
||||
import { LatestNote } from '@/models/LatestNote.js';
|
||||
import type { ChannelFollowingsRepository, ChannelsRepository, FollowingsRepository, InstancesRepository, LatestNotesRepository, MiFollowing, MutingsRepository, NotesRepository, NoteThreadMutingsRepository, UserListMembershipsRepository, UserProfilesRepository, UsersRepository } from '@/models/_.js';
|
||||
import type { MiDriveFile } from '@/models/DriveFile.js';
|
||||
import type { MiApp } from '@/models/App.js';
|
||||
import { concat } from '@/misc/prelude/array.js';
|
||||
|
@ -62,6 +63,7 @@ import { isReply } from '@/misc/is-reply.js';
|
|||
import { trackPromise } from '@/misc/promise-tracker.js';
|
||||
import { isUserRelated } from '@/misc/is-user-related.js';
|
||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import { isQuote, isRenote } from '@/misc/is-renote.js';
|
||||
|
||||
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
|
||||
|
||||
|
@ -170,6 +172,9 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||
@Inject(DI.notesRepository)
|
||||
private notesRepository: NotesRepository,
|
||||
|
||||
@Inject(DI.latestNotesRepository)
|
||||
private latestNotesRepository: LatestNotesRepository,
|
||||
|
||||
@Inject(DI.mutingsRepository)
|
||||
private mutingsRepository: MutingsRepository,
|
||||
|
||||
|
@ -514,6 +519,8 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||
await this.notesRepository.insert(insert);
|
||||
}
|
||||
|
||||
await this.updateLatestNote(insert);
|
||||
|
||||
return insert;
|
||||
} catch (e) {
|
||||
// duplicate key error
|
||||
|
@ -1125,4 +1132,25 @@ export class NoteCreateService implements OnApplicationShutdown {
|
|||
public onApplicationShutdown(signal?: string | undefined): void {
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
private async updateLatestNote(note: MiNote) {
|
||||
// Ignore DMs.
|
||||
// Followers-only posts are *included*, as this table is used to back the "following" feed.
|
||||
if (note.visibility === 'specified') return;
|
||||
|
||||
// Ignore pure renotes
|
||||
if (isRenote(note) && !isQuote(note)) return;
|
||||
|
||||
// Make sure that this isn't an *older* post.
|
||||
// We can get older posts through replies, lookups, etc.
|
||||
const currentLatest = await this.latestNotesRepository.findOneBy({ userId: note.userId });
|
||||
if (currentLatest != null && currentLatest.noteId >= note.id) return;
|
||||
|
||||
// Record this as the latest note for the given user
|
||||
const latestNote = new LatestNote({
|
||||
userId: note.userId,
|
||||
noteId: note.id,
|
||||
});
|
||||
await this.latestNotesRepository.upsert(latestNote, ['userId']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Brackets, In } from 'typeorm';
|
||||
import { Brackets, In, Not } from 'typeorm';
|
||||
import { Injectable, Inject } from '@nestjs/common';
|
||||
import type { MiUser, MiLocalUser, MiRemoteUser } from '@/models/User.js';
|
||||
import type { MiNote, IMentionedRemoteUsers } from '@/models/Note.js';
|
||||
import type { InstancesRepository, NotesRepository, UsersRepository } from '@/models/_.js';
|
||||
import { LatestNote } from '@/models/LatestNote.js';
|
||||
import type { InstancesRepository, LatestNotesRepository, NotesRepository, UsersRepository } from '@/models/_.js';
|
||||
import { RelayService } from '@/core/RelayService.js';
|
||||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
|
@ -38,6 +39,9 @@ export class NoteDeleteService {
|
|||
@Inject(DI.notesRepository)
|
||||
private notesRepository: NotesRepository,
|
||||
|
||||
@Inject(DI.latestNotesRepository)
|
||||
private latestNotesRepository: LatestNotesRepository,
|
||||
|
||||
@Inject(DI.instancesRepository)
|
||||
private instancesRepository: InstancesRepository,
|
||||
|
||||
|
@ -148,6 +152,8 @@ export class NoteDeleteService {
|
|||
userId: user.id,
|
||||
});
|
||||
|
||||
await this.updateLatestNote(note);
|
||||
|
||||
if (deleter && (note.userId !== deleter.id)) {
|
||||
const user = await this.usersRepository.findOneByOrFail({ id: note.userId });
|
||||
this.moderationLogService.log(deleter, 'deleteNote', {
|
||||
|
@ -229,4 +235,52 @@ export class NoteDeleteService {
|
|||
this.apDeliverManagerService.deliverToUser(user, content, remoteUser);
|
||||
}
|
||||
}
|
||||
|
||||
private async updateLatestNote(note: MiNote) {
|
||||
// If it's a DM, then it can't possibly be the latest note so we can safely skip this.
|
||||
if (note.visibility === 'specified') return;
|
||||
|
||||
// Check if the deleted note was possibly the latest for the user
|
||||
const hasLatestNote = await this.latestNotesRepository.existsBy({ userId: note.userId });
|
||||
if (hasLatestNote) return;
|
||||
|
||||
// Find the newest remaining note for the user.
|
||||
// We exclude DMs and pure renotes.
|
||||
const nextLatest = await this.notesRepository
|
||||
.createQueryBuilder('note')
|
||||
.select()
|
||||
.where({
|
||||
userId: note.userId,
|
||||
visibility: Not('specified'),
|
||||
})
|
||||
.andWhere(`
|
||||
(
|
||||
note."renoteId" IS NULL
|
||||
OR note.text IS NOT NULL
|
||||
OR note.cw IS NOT NULL
|
||||
OR note."replyId" IS NOT NULL
|
||||
OR note."hasPoll"
|
||||
OR note."fileIds" != '{}'
|
||||
)
|
||||
`)
|
||||
.orderBy({ id: 'DESC' })
|
||||
.getOne();
|
||||
if (!nextLatest) return;
|
||||
|
||||
// Record it as the latest
|
||||
const latestNote = new LatestNote({
|
||||
userId: note.userId,
|
||||
noteId: nextLatest.id,
|
||||
});
|
||||
|
||||
// When inserting the latest note, it's possible that another worker has "raced" the insert and already added a newer note.
|
||||
// We must use orIgnore() to ensure that the query ignores conflicts, otherwise an exception may be thrown.
|
||||
await this.latestNotesRepository
|
||||
.createQueryBuilder('latest')
|
||||
.insert()
|
||||
.into(LatestNote)
|
||||
.values(latestNote)
|
||||
.orIgnore()
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ export const DI = {
|
|||
announcementReadsRepository: Symbol('announcementReadsRepository'),
|
||||
appsRepository: Symbol('appsRepository'),
|
||||
avatarDecorationsRepository: Symbol('avatarDecorationsRepository'),
|
||||
latestNotesRepository: Symbol('latestNotesRepository'),
|
||||
noteFavoritesRepository: Symbol('noteFavoritesRepository'),
|
||||
noteThreadMutingsRepository: Symbol('noteThreadMutingsRepository'),
|
||||
noteReactionsRepository: Symbol('noteReactionsRepository'),
|
||||
|
|
54
packages/backend/src/models/LatestNote.ts
Normal file
54
packages/backend/src/models/LatestNote.ts
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { PrimaryColumn, Entity, JoinColumn, Column, ManyToOne } from 'typeorm';
|
||||
import { MiUser } from '@/models/User.js';
|
||||
import { MiNote } from '@/models/Note.js';
|
||||
|
||||
/**
|
||||
* Maps a user to the most recent post by that user.
|
||||
* Public, home-only, and followers-only posts are included.
|
||||
* DMs are not counted.
|
||||
*/
|
||||
@Entity('latest_note')
|
||||
export class LatestNote {
|
||||
@PrimaryColumn({
|
||||
name: 'user_id',
|
||||
type: 'varchar' as const,
|
||||
length: 32,
|
||||
})
|
||||
public userId: string;
|
||||
|
||||
@ManyToOne(() => MiUser, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({
|
||||
name: 'user_id',
|
||||
})
|
||||
public user: MiUser | null;
|
||||
|
||||
@Column({
|
||||
name: 'note_id',
|
||||
type: 'varchar' as const,
|
||||
length: 32,
|
||||
})
|
||||
public noteId: string;
|
||||
|
||||
@ManyToOne(() => MiNote, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({
|
||||
name: 'note_id',
|
||||
})
|
||||
public note: MiNote | null;
|
||||
|
||||
constructor(data?: Partial<LatestNote>) {
|
||||
if (!data) return;
|
||||
|
||||
for (const [k, v] of Object.entries(data)) {
|
||||
(this as Record<string, unknown>)[k] = v;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import type { Provider } from '@nestjs/common';
|
|||
import { Module } from '@nestjs/common';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import {
|
||||
LatestNote,
|
||||
MiAbuseReportNotificationRecipient,
|
||||
MiAbuseUserReport,
|
||||
MiAccessToken,
|
||||
|
@ -118,6 +119,12 @@ const $avatarDecorationsRepository: Provider = {
|
|||
inject: [DI.db],
|
||||
};
|
||||
|
||||
const $latestNotesRepository: Provider = {
|
||||
provide: DI.latestNotesRepository,
|
||||
useFactory: (db: DataSource) => db.getRepository(LatestNote).extend(miRepository as MiRepository<LatestNote>),
|
||||
inject: [DI.db],
|
||||
};
|
||||
|
||||
const $noteFavoritesRepository: Provider = {
|
||||
provide: DI.noteFavoritesRepository,
|
||||
useFactory: (db: DataSource) => db.getRepository(MiNoteFavorite).extend(miRepository as MiRepository<MiNoteFavorite>),
|
||||
|
@ -511,6 +518,7 @@ const $reversiGamesRepository: Provider = {
|
|||
$announcementReadsRepository,
|
||||
$appsRepository,
|
||||
$avatarDecorationsRepository,
|
||||
$latestNotesRepository,
|
||||
$noteFavoritesRepository,
|
||||
$noteThreadMutingsRepository,
|
||||
$noteReactionsRepository,
|
||||
|
@ -583,6 +591,7 @@ const $reversiGamesRepository: Provider = {
|
|||
$announcementReadsRepository,
|
||||
$appsRepository,
|
||||
$avatarDecorationsRepository,
|
||||
$latestNotesRepository,
|
||||
$noteFavoritesRepository,
|
||||
$noteThreadMutingsRepository,
|
||||
$noteReactionsRepository,
|
||||
|
|
|
@ -10,6 +10,7 @@ import { RelationIdLoader } from 'typeorm/query-builder/relation-id/RelationIdLo
|
|||
import { RawSqlResultsToEntityTransformer } from 'typeorm/query-builder/transformer/RawSqlResultsToEntityTransformer.js';
|
||||
import { ObjectUtils } from 'typeorm/util/ObjectUtils.js';
|
||||
import { OrmUtils } from 'typeorm/util/OrmUtils.js';
|
||||
import { LatestNote } from '@/models/LatestNote.js';
|
||||
import { MiAbuseUserReport } from '@/models/AbuseUserReport.js';
|
||||
import { MiAbuseReportNotificationRecipient } from '@/models/AbuseReportNotificationRecipient.js';
|
||||
import { MiAccessToken } from '@/models/AccessToken.js';
|
||||
|
@ -126,6 +127,7 @@ export const miRepository = {
|
|||
} satisfies MiRepository<ObjectLiteral>;
|
||||
|
||||
export {
|
||||
LatestNote,
|
||||
MiAbuseUserReport,
|
||||
MiAbuseReportNotificationRecipient,
|
||||
MiAccessToken,
|
||||
|
@ -224,6 +226,7 @@ export type GalleryPostsRepository = Repository<MiGalleryPost> & MiRepository<Mi
|
|||
export type HashtagsRepository = Repository<MiHashtag> & MiRepository<MiHashtag>;
|
||||
export type InstancesRepository = Repository<MiInstance> & MiRepository<MiInstance>;
|
||||
export type MetasRepository = Repository<MiMeta> & MiRepository<MiMeta>;
|
||||
export type LatestNotesRepository = Repository<LatestNote> & MiRepository<LatestNote>;
|
||||
export type ModerationLogsRepository = Repository<MiModerationLog> & MiRepository<MiModerationLog>;
|
||||
export type MutingsRepository = Repository<MiMuting> & MiRepository<MiMuting>;
|
||||
export type RenoteMutingsRepository = Repository<MiRenoteMuting> & MiRepository<MiRenoteMuting>;
|
||||
|
|
|
@ -83,6 +83,7 @@ import { MiReversiGame } from '@/models/ReversiGame.js';
|
|||
import { Config } from '@/config.js';
|
||||
import MisskeyLogger from '@/logger.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { LatestNote } from '@/models/LatestNote.js';
|
||||
|
||||
pg.types.setTypeParser(20, Number);
|
||||
|
||||
|
@ -130,6 +131,7 @@ class MyCustomLogger implements Logger {
|
|||
}
|
||||
|
||||
export const entities = [
|
||||
LatestNote,
|
||||
MiAnnouncement,
|
||||
MiAnnouncementRead,
|
||||
MiMeta,
|
||||
|
|
|
@ -290,6 +290,7 @@ import * as ep___notes_delete from './endpoints/notes/delete.js';
|
|||
import * as ep___notes_favorites_create from './endpoints/notes/favorites/create.js';
|
||||
import * as ep___notes_favorites_delete from './endpoints/notes/favorites/delete.js';
|
||||
import * as ep___notes_featured from './endpoints/notes/featured.js';
|
||||
import * as ep___notes_following from './endpoints/notes/following.js';
|
||||
import * as ep___notes_globalTimeline from './endpoints/notes/global-timeline.js';
|
||||
import * as ep___notes_bubbleTimeline from './endpoints/notes/bubble-timeline.js';
|
||||
import * as ep___notes_hybridTimeline from './endpoints/notes/hybrid-timeline.js';
|
||||
|
@ -686,6 +687,7 @@ const $notes_delete: Provider = { provide: 'ep:notes/delete', useClass: ep___not
|
|||
const $notes_favorites_create: Provider = { provide: 'ep:notes/favorites/create', useClass: ep___notes_favorites_create.default };
|
||||
const $notes_favorites_delete: Provider = { provide: 'ep:notes/favorites/delete', useClass: ep___notes_favorites_delete.default };
|
||||
const $notes_featured: Provider = { provide: 'ep:notes/featured', useClass: ep___notes_featured.default };
|
||||
const $notes_following: Provider = { provide: 'ep:notes/following', useClass: ep___notes_following.default };
|
||||
const $notes_globalTimeline: Provider = { provide: 'ep:notes/global-timeline', useClass: ep___notes_globalTimeline.default };
|
||||
const $notes_bubbleTimeline: Provider = { provide: 'ep:notes/bubble-timeline', useClass: ep___notes_bubbleTimeline.default };
|
||||
const $notes_hybridTimeline: Provider = { provide: 'ep:notes/hybrid-timeline', useClass: ep___notes_hybridTimeline.default };
|
||||
|
@ -1086,6 +1088,7 @@ const $reversi_verify: Provider = { provide: 'ep:reversi/verify', useClass: ep__
|
|||
$notes_favorites_create,
|
||||
$notes_favorites_delete,
|
||||
$notes_featured,
|
||||
$notes_following,
|
||||
$notes_globalTimeline,
|
||||
$notes_bubbleTimeline,
|
||||
$notes_hybridTimeline,
|
||||
|
@ -1480,6 +1483,7 @@ const $reversi_verify: Provider = { provide: 'ep:reversi/verify', useClass: ep__
|
|||
$notes_favorites_create,
|
||||
$notes_favorites_delete,
|
||||
$notes_featured,
|
||||
$notes_following,
|
||||
$notes_globalTimeline,
|
||||
$notes_bubbleTimeline,
|
||||
$notes_hybridTimeline,
|
||||
|
|
|
@ -296,6 +296,7 @@ import * as ep___notes_delete from './endpoints/notes/delete.js';
|
|||
import * as ep___notes_favorites_create from './endpoints/notes/favorites/create.js';
|
||||
import * as ep___notes_favorites_delete from './endpoints/notes/favorites/delete.js';
|
||||
import * as ep___notes_featured from './endpoints/notes/featured.js';
|
||||
import * as ep___notes_following from './endpoints/notes/following.js';
|
||||
import * as ep___notes_globalTimeline from './endpoints/notes/global-timeline.js';
|
||||
import * as ep___notes_bubbleTimeline from './endpoints/notes/bubble-timeline.js';
|
||||
import * as ep___notes_hybridTimeline from './endpoints/notes/hybrid-timeline.js';
|
||||
|
@ -690,6 +691,7 @@ const eps = [
|
|||
['notes/favorites/create', ep___notes_favorites_create],
|
||||
['notes/favorites/delete', ep___notes_favorites_delete],
|
||||
['notes/featured', ep___notes_featured],
|
||||
['notes/following', ep___notes_following],
|
||||
['notes/global-timeline', ep___notes_globalTimeline],
|
||||
['notes/bubble-timeline', ep___notes_bubbleTimeline],
|
||||
['notes/hybrid-timeline', ep___notes_hybridTimeline],
|
||||
|
|
95
packages/backend/src/server/api/endpoints/notes/following.ts
Normal file
95
packages/backend/src/server/api/endpoints/notes/following.ts
Normal file
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { LatestNote, MiFollowing } from '@/models/_.js';
|
||||
import type { NotesRepository } from '@/models/_.js';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { QueryService } from '@/core/QueryService.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['notes'],
|
||||
|
||||
requireCredential: true,
|
||||
kind: 'read:account',
|
||||
allowGet: true,
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
items: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'Note',
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
export const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
mutualsOnly: { type: 'boolean', default: false },
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
sinceDate: { type: 'integer' },
|
||||
untilDate: { type: 'integer' },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
||||
constructor(
|
||||
@Inject(DI.notesRepository)
|
||||
private notesRepository: NotesRepository,
|
||||
|
||||
private noteEntityService: NoteEntityService,
|
||||
private queryService: QueryService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
let query = this.notesRepository
|
||||
.createQueryBuilder('note')
|
||||
.setParameter('me', me.id)
|
||||
|
||||
// Limit to latest notes
|
||||
.innerJoin(LatestNote, 'latest', 'note.id = latest.note_id')
|
||||
|
||||
// Avoid N+1 queries from the "pack" method
|
||||
.innerJoinAndSelect('note.user', 'user')
|
||||
.leftJoinAndSelect('note.reply', 'reply')
|
||||
.leftJoinAndSelect('note.renote', 'renote')
|
||||
.leftJoinAndSelect('reply.user', 'replyUser')
|
||||
.leftJoinAndSelect('renote.user', 'renoteUser')
|
||||
.leftJoinAndSelect('note.channel', 'channel')
|
||||
|
||||
// Limit to followers
|
||||
.innerJoin(MiFollowing, 'following', 'latest.user_id = following."followeeId"')
|
||||
.andWhere('following."followerId" = :me');
|
||||
|
||||
// Limit to mutuals, if requested
|
||||
if (ps.mutualsOnly) {
|
||||
query = query
|
||||
.innerJoin(MiFollowing, 'mutuals', 'latest.user_id = mutuals."followerId" AND mutuals."followeeId" = :me');
|
||||
}
|
||||
|
||||
// Respect blocks and mutes
|
||||
this.queryService.generateBlockedUserQuery(query, me);
|
||||
this.queryService.generateMutedUserQuery(query, me);
|
||||
|
||||
// Support pagination
|
||||
query = this.queryService
|
||||
.makePaginationQuery(query, ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
|
||||
.orderBy('note.id', 'DESC')
|
||||
.take(ps.limit);
|
||||
|
||||
// Query and return the next page
|
||||
const notes = await query.getMany();
|
||||
return await this.noteEntityService.packMany(notes, me);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -104,6 +104,7 @@ const props = withDefaults(defineProps<{
|
|||
const emit = defineEmits<{
|
||||
(ev: 'queue', count: number): void;
|
||||
(ev: 'status', error: boolean): void;
|
||||
(ev: 'init'): void;
|
||||
}>();
|
||||
|
||||
const rootEl = shallowRef<HTMLElement>();
|
||||
|
@ -232,6 +233,8 @@ async function init(): Promise<void> {
|
|||
offset.value = res.length;
|
||||
error.value = false;
|
||||
fetching.value = false;
|
||||
|
||||
emit('init');
|
||||
}, err => {
|
||||
error.value = true;
|
||||
fetching.value = false;
|
||||
|
|
123
packages/frontend/src/components/SkFollowingFeedEntry.vue
Normal file
123
packages/frontend/src/components/SkFollowingFeedEntry.vue
Normal file
|
@ -0,0 +1,123 @@
|
|||
<!--
|
||||
SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div :class="$style.root" @click="$emit('select', note.user)">
|
||||
<div :class="$style.avatar">
|
||||
<MkAvatar :class="$style.icon" :user="note.user" indictor/>
|
||||
</div>
|
||||
<div :class="$style.contents">
|
||||
<header :class="$style.header">
|
||||
<MkA v-user-preview="note.user.id" :class="$style.headerName" :to="userPage(note.user)">
|
||||
<MkUserName :user="note.user"/>
|
||||
</MkA>
|
||||
<MkA :to="notePage(note)">
|
||||
<MkTime :time="note.createdAt" :class="$style.headerTime" colored/>
|
||||
</MkA>
|
||||
</header>
|
||||
<div>
|
||||
<div v-if="isMuted" :class="[$style.text, $style.muted]">({{ i18n.ts.postFiltered }})</div>
|
||||
<Mfm v-else :class="$style.text" :text="getNoteSummary(note)" :isBlock="true" :plain="true" :nowrap="false" :isNote="true" nyaize="respect" :author="note.user"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import * as Misskey from 'misskey-js';
|
||||
import { getNoteSummary } from '@/scripts/get-note-summary.js';
|
||||
import { userPage } from '@/filters/user.js';
|
||||
import { notePage } from '@/filters/note.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
|
||||
withDefaults(defineProps<{
|
||||
note: Misskey.entities.Note,
|
||||
isMuted: boolean
|
||||
}>(), {
|
||||
isMuted: false,
|
||||
});
|
||||
|
||||
defineEmits<{
|
||||
(event: 'select', user: Misskey.entities.UserLite): void
|
||||
}>();
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" module>
|
||||
.root {
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
padding: 12px 16px;
|
||||
font-size: 0.9em;
|
||||
overflow-wrap: break-word;
|
||||
display: flex;
|
||||
contain: content;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
align-self: center;
|
||||
flex-shrink: 0;
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.contents {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.headerName {
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.headerTime {
|
||||
margin-left: auto;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.icon {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.text {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
overflow: clip;
|
||||
line-height: 1.25em;
|
||||
height: 2.5em;
|
||||
}
|
||||
|
||||
.muted {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@container (max-width: 600px) {
|
||||
.root {
|
||||
padding: 16px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
}
|
||||
|
||||
@container (max-width: 500px) {
|
||||
.root {
|
||||
padding: 12px;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
}
|
||||
</style>
|
108
packages/frontend/src/components/SkUserRecentNotes.vue
Normal file
108
packages/frontend/src/components/SkUserRecentNotes.vue
Normal file
|
@ -0,0 +1,108 @@
|
|||
<!--
|
||||
SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
-->
|
||||
|
||||
<template>
|
||||
<MkPullToRefresh :refresher="() => reload()">
|
||||
<div v-if="user" :class="$style.userInfo">
|
||||
<MkUserInfo :class="$style.userInfo" class="user" :user="user"/>
|
||||
<MkNotes :noGap="true" :pagination="pagination"/>
|
||||
</div>
|
||||
<div v-else-if="loadError" :class="$style.panel">{{ loadError }}</div>
|
||||
<MkLoading v-else-if="userId"/>
|
||||
</MkPullToRefresh>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, Ref, watch } from 'vue';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import MkLoading from '@/components/global/MkLoading.vue';
|
||||
import MkNotes from '@/components/MkNotes.vue';
|
||||
import MkUserInfo from '@/components/MkUserInfo.vue';
|
||||
import MkPullToRefresh from '@/components/MkPullToRefresh.vue';
|
||||
import { Paging } from '@/components/MkPagination.vue';
|
||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
userId: string;
|
||||
withRenotes?: boolean;
|
||||
withReplies?: boolean;
|
||||
onlyFiles?: boolean;
|
||||
}>(), {
|
||||
withRenotes: false,
|
||||
withReplies: true,
|
||||
onlyFiles: false,
|
||||
});
|
||||
|
||||
const loadError: Ref<string | null> = ref(null);
|
||||
const user: Ref<Misskey.entities.UserDetailed | null> = ref(null);
|
||||
|
||||
const pagination: Paging<'users/notes'> = {
|
||||
endpoint: 'users/notes' as const,
|
||||
limit: 10,
|
||||
params: computed(() => ({
|
||||
userId: props.userId,
|
||||
withRenotes: props.withRenotes,
|
||||
withReplies: props.withReplies,
|
||||
withFiles: props.onlyFiles,
|
||||
})),
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
reload,
|
||||
user,
|
||||
});
|
||||
|
||||
async function reload(): Promise<void> {
|
||||
loadError.value = null;
|
||||
user.value = null;
|
||||
|
||||
await Promise
|
||||
.all([
|
||||
// We need a User entity, but the pagination returns only UserLite.
|
||||
// An additional request is needed to "upgrade" the object.
|
||||
misskeyApi('users/show', { userId: props.userId }),
|
||||
|
||||
// Wait for 1 second to match the animation effects in MkHorizontalSwipe, MkPullToRefresh, and MkPagination.
|
||||
// Otherwise, the page appears to load "backwards".
|
||||
new Promise(resolve => setTimeout(resolve, 1000)),
|
||||
])
|
||||
.then(([u]) => user.value = u)
|
||||
.catch(error => {
|
||||
console.error('Error fetching user info', error);
|
||||
|
||||
loadError.value =
|
||||
typeof(error) === 'string'
|
||||
? String(error)
|
||||
: JSON.stringify(error);
|
||||
});
|
||||
}
|
||||
|
||||
watch(() => props.userId, async () => {
|
||||
await reload();
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
await reload();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" module>
|
||||
|
||||
.panel {
|
||||
background: var(--panel);
|
||||
}
|
||||
|
||||
.userInfo {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
@container (min-width: 451px) {
|
||||
.userInfo {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
|
@ -68,6 +68,11 @@ export const navbarItemDef = reactive({
|
|||
lookup();
|
||||
},
|
||||
},
|
||||
following: {
|
||||
title: i18n.ts.following,
|
||||
icon: 'ph-user-check ph-bold ph-lg',
|
||||
to: '/following-feed',
|
||||
},
|
||||
lists: {
|
||||
title: i18n.ts.lists,
|
||||
icon: 'ti ti-list',
|
||||
|
|
299
packages/frontend/src/pages/following-feed.vue
Normal file
299
packages/frontend/src/pages/following-feed.vue
Normal file
|
@ -0,0 +1,299 @@
|
|||
<!--
|
||||
SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div :class="$style.root">
|
||||
<MkPageHeader v-model:tab="currentTab" :class="$style.header" :tabs="headerTabs" :actions="headerActions" :displayBackButton="true" @update:tab="onChangeTab"/>
|
||||
|
||||
<div ref="noteScroll" :class="$style.notes">
|
||||
<MkHorizontalSwipe v-model:tab="currentTab" :tabs="headerTabs">
|
||||
<MkPullToRefresh :refresher="() => reloadLatestNotes()">
|
||||
<MkPagination ref="latestNotesPaging" :pagination="latestNotesPagination" @init="onListReady">
|
||||
<template #empty>
|
||||
<div class="_fullinfo">
|
||||
<img :src="infoImageUrl" class="_ghost" :alt="i18n.ts.noNotes" aria-hidden="true"/>
|
||||
<div>{{ i18n.ts.noNotes }}</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #default="{ items: notes }">
|
||||
<MkDateSeparatedList v-slot="{ item: note }" :items="notes" :class="$style.panel" :noGap="true">
|
||||
<SkFollowingFeedEntry v-if="!isHardMuted(note)" :isMuted="isSoftMuted(note)" :note="note" @select="userSelected"/>
|
||||
</MkDateSeparatedList>
|
||||
</template>
|
||||
</MkPagination>
|
||||
</MkPullToRefresh>
|
||||
</MkHorizontalSwipe>
|
||||
</div>
|
||||
|
||||
<div v-if="isWideViewport" ref="userScroll" :class="$style.user">
|
||||
<MkHorizontalSwipe v-if="selectedUserId" v-model:tab="currentTab" :tabs="headerTabs">
|
||||
<SkUserRecentNotes ref="userRecentNotes" :userId="selectedUserId" :withRenotes="withUserRenotes" :withReplies="withUserReplies" :onlyFiles="withOnlyFiles"/>
|
||||
</MkHorizontalSwipe>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export type FollowingFeedTab = typeof followingTab | typeof mutualsTab;
|
||||
export const followingTab = 'following' as const;
|
||||
export const mutualsTab = 'mutuals' as const;
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, Ref, ref, shallowRef } from 'vue';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue';
|
||||
import MkPullToRefresh from '@/components/MkPullToRefresh.vue';
|
||||
import MkPagination, { Paging } from '@/components/MkPagination.vue';
|
||||
import { infoImageUrl } from '@/instance.js';
|
||||
import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue';
|
||||
import { Tab } from '@/components/global/MkPageHeader.tabs.vue';
|
||||
import { PageHeaderItem } from '@/types/page-header.js';
|
||||
import SkFollowingFeedEntry from '@/components/SkFollowingFeedEntry.vue';
|
||||
import { useRouter } from '@/router/supplier.js';
|
||||
import * as os from '@/os.js';
|
||||
import MkPageHeader from '@/components/global/MkPageHeader.vue';
|
||||
import { $i } from '@/account.js';
|
||||
import { checkWordMute } from '@/scripts/check-word-mute.js';
|
||||
import SkUserRecentNotes from '@/components/SkUserRecentNotes.vue';
|
||||
import { useScrollPositionManager } from '@/nirax.js';
|
||||
import { getScrollContainer } from '@/scripts/scroll.js';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
initialTab?: FollowingFeedTab,
|
||||
}>(), {
|
||||
initialTab: followingTab,
|
||||
});
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
// Vue complains, but we *want* to lose reactivity here.
|
||||
// Otherwise, the user would be unable to change the tab.
|
||||
// eslint-disable-next-line vue/no-setup-props-reactivity-loss
|
||||
const currentTab: Ref<FollowingFeedTab> = ref(props.initialTab);
|
||||
const mutualsOnly: Ref<boolean> = computed(() => currentTab.value === mutualsTab);
|
||||
const userRecentNotes = shallowRef<InstanceType<typeof SkUserRecentNotes>>();
|
||||
const userScroll = shallowRef<HTMLElement>();
|
||||
const noteScroll = shallowRef<HTMLElement>();
|
||||
|
||||
// We have to disable the per-user feed on small displays, and it must be done through JS instead of CSS.
|
||||
// Otherwise, the second column will waste resources in the background.
|
||||
const wideViewportQuery = window.matchMedia('(min-width: 750px)');
|
||||
const isWideViewport: Ref<boolean> = ref(wideViewportQuery.matches);
|
||||
wideViewportQuery.addEventListener('change', () => isWideViewport.value = wideViewportQuery.matches);
|
||||
|
||||
const selectedUserId: Ref<string | null> = ref(null);
|
||||
|
||||
function userSelected(user: Misskey.entities.UserLite): void {
|
||||
if (isWideViewport.value) {
|
||||
selectedUserId.value = user.id;
|
||||
} else {
|
||||
router.push(`/following-feed/${user.id}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function reloadLatestNotes() {
|
||||
await latestNotesPaging.value?.reload();
|
||||
}
|
||||
|
||||
async function reloadUserNotes() {
|
||||
await userRecentNotes.value?.reload();
|
||||
}
|
||||
|
||||
async function reload() {
|
||||
await Promise.all([
|
||||
reloadLatestNotes(),
|
||||
reloadUserNotes(),
|
||||
]);
|
||||
}
|
||||
|
||||
async function onListReady(): Promise<void> {
|
||||
if (!selectedUserId.value && latestNotesPaging.value?.items.size) {
|
||||
// This just gets the first user ID
|
||||
const selectedNote: Misskey.entities.Note = latestNotesPaging.value.items.values().next().value;
|
||||
selectedUserId.value = selectedNote.userId;
|
||||
}
|
||||
}
|
||||
|
||||
async function onChangeTab(): Promise<void> {
|
||||
selectedUserId.value = null;
|
||||
}
|
||||
|
||||
function isSoftMuted(note: Misskey.entities.Note): boolean {
|
||||
return isMuted(note, $i?.mutedWords);
|
||||
}
|
||||
|
||||
function isHardMuted(note: Misskey.entities.Note): boolean {
|
||||
return isMuted(note, $i?.hardMutedWords);
|
||||
}
|
||||
|
||||
// Match the typing used by Misskey
|
||||
type Mutes = (string | string[])[] | null | undefined;
|
||||
|
||||
// Adapted from MkNote.ts
|
||||
function isMuted(note: Misskey.entities.Note, mutes: Mutes): boolean {
|
||||
return checkMute(note, mutes)
|
||||
|| checkMute(note.reply, mutes)
|
||||
|| checkMute(note.renote, mutes);
|
||||
}
|
||||
|
||||
// Adapted from check-word-mute.ts
|
||||
function checkMute(note: Misskey.entities.Note | undefined | null, mutes: Mutes): boolean {
|
||||
if (!note) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mutes || mutes.length < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return checkWordMute(note, $i, mutes);
|
||||
}
|
||||
|
||||
const latestNotesPaging = shallowRef<InstanceType<typeof MkPagination>>();
|
||||
|
||||
const latestNotesPagination: Paging<'notes/following'> = {
|
||||
endpoint: 'notes/following' as const,
|
||||
limit: 20,
|
||||
params: computed(() => ({
|
||||
mutualsOnly: mutualsOnly.value,
|
||||
})),
|
||||
};
|
||||
|
||||
const withUserRenotes = ref(false);
|
||||
const withUserReplies = ref(true);
|
||||
const withOnlyFiles = ref(false);
|
||||
|
||||
const headerActions = computed(() => {
|
||||
const actions: PageHeaderItem[] = [
|
||||
{
|
||||
icon: 'ti ti-refresh',
|
||||
text: i18n.ts.reload,
|
||||
handler: () => reload(),
|
||||
},
|
||||
];
|
||||
|
||||
if (isWideViewport.value) {
|
||||
actions.push({
|
||||
icon: 'ti ti-dots',
|
||||
text: i18n.ts.options,
|
||||
handler: (ev) => {
|
||||
os.popupMenu([
|
||||
{
|
||||
type: 'switch',
|
||||
text: i18n.ts.showRenotes,
|
||||
ref: withUserRenotes,
|
||||
}, {
|
||||
type: 'switch',
|
||||
text: i18n.ts.showRepliesToOthersInTimeline,
|
||||
ref: withUserReplies,
|
||||
disabled: withOnlyFiles,
|
||||
},
|
||||
{
|
||||
type: 'divider',
|
||||
},
|
||||
{
|
||||
type: 'switch',
|
||||
text: i18n.ts.fileAttachedOnly,
|
||||
ref: withOnlyFiles,
|
||||
disabled: withUserReplies,
|
||||
},
|
||||
], ev.currentTarget ?? ev.target);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return actions;
|
||||
});
|
||||
|
||||
const headerTabs = computed(() => [
|
||||
{
|
||||
key: followingTab,
|
||||
icon: 'ph-user-check ph-bold ph-lg',
|
||||
title: i18n.ts.following,
|
||||
} satisfies Tab,
|
||||
{
|
||||
key: mutualsTab,
|
||||
icon: 'ph-user-switch ph-bold ph-lg',
|
||||
title: i18n.ts.mutuals,
|
||||
} satisfies Tab,
|
||||
]);
|
||||
|
||||
useScrollPositionManager(() => getScrollContainer(userScroll.value ?? null), router);
|
||||
useScrollPositionManager(() => getScrollContainer(noteScroll.value ?? null), router);
|
||||
definePageMetadata(() => ({
|
||||
title: i18n.ts.following,
|
||||
icon: 'ph-user-check ph-bold ph-lg',
|
||||
}));
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" module>
|
||||
//This inspection complains about duplicate "height" properties, but this is needed because "dvh" units are not supported in all browsers.
|
||||
//The earlier "vh" provide a "close enough" approximation for older browsers.
|
||||
//noinspection CssOverwrittenProperties
|
||||
.root {
|
||||
display: grid;
|
||||
grid-template-columns: min-content 1fr min-content;
|
||||
grid-template-rows: min-content 1fr;
|
||||
grid-template-areas:
|
||||
"header header header"
|
||||
"lm notes rm";
|
||||
gap: 12px;
|
||||
|
||||
height: 100vh;
|
||||
height: 100dvh;
|
||||
|
||||
// The universal layout inserts a "spacer" thing that causes a stray scroll bar.
|
||||
// We have to create fake "space" for it to "roll up" and back into the viewport, which removes the scrollbar.
|
||||
margin-bottom: calc(-1 * var(--minBottomSpacing));
|
||||
|
||||
// Some "just in case" backup properties.
|
||||
// These should not be needed, but help to maintain the layout if the above trick ever stops working.
|
||||
overflow: hidden;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.header {
|
||||
grid-area: header;
|
||||
}
|
||||
|
||||
.notes {
|
||||
grid-area: notes;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.user {
|
||||
grid-area: user;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.userInfo {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
@media (min-width: 750px) {
|
||||
.root {
|
||||
grid-template-columns: min-content 4fr 6fr min-content;
|
||||
grid-template-rows: min-content 1fr;
|
||||
grid-template-areas:
|
||||
"header header header header"
|
||||
"lm notes user rm";
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.userInfo {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.panel {
|
||||
background: var(--panel);
|
||||
}
|
||||
</style>
|
|
@ -55,9 +55,12 @@ import { MenuItem } from '@/types/menu.js';
|
|||
import { miLocalStorage } from '@/local-storage.js';
|
||||
import { availableBasicTimelines, hasWithReplies, isAvailableBasicTimeline, isBasicTimeline, basicTimelineIconClass } from '@/timelines.js';
|
||||
import type { BasicTimelineType } from '@/timelines.js';
|
||||
import { useRouter } from '@/router/supplier.js';
|
||||
|
||||
provide('shouldOmitHeaderTitle', true);
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const tlComponent = shallowRef<InstanceType<typeof MkTimeline>>();
|
||||
const rootEl = shallowRef<HTMLElement>();
|
||||
|
||||
|
@ -309,6 +312,11 @@ const headerTabs = computed(() => [...(defaultStore.reactiveState.pinnedUserList
|
|||
icon: basicTimelineIconClass(tl),
|
||||
iconOnly: true,
|
||||
})), {
|
||||
icon: 'ph-user-check ph-bold ph-lg',
|
||||
title: i18n.ts.following,
|
||||
iconOnly: true,
|
||||
onClick: () => router.push('/following-feed'),
|
||||
}, {
|
||||
icon: 'ti ti-list',
|
||||
title: i18n.ts.lists,
|
||||
iconOnly: true,
|
||||
|
|
91
packages/frontend/src/pages/user/recent-notes.vue
Normal file
91
packages/frontend/src/pages/user/recent-notes.vue
Normal file
|
@ -0,0 +1,91 @@
|
|||
<!--
|
||||
SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
-->
|
||||
|
||||
<template>
|
||||
<MkStickyContainer>
|
||||
<template #header>
|
||||
<MkPageHeader :actions="headerActions" :displayBackButton="true"/>
|
||||
</template>
|
||||
<SkUserRecentNotes ref="userRecentNotes" :userId="userId" :withRenotes="withRenotes" :withReplies="withReplies" :onlyFiles="onlyFiles"/>
|
||||
</MkStickyContainer>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
import { computed, ref, shallowRef } from 'vue';
|
||||
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { PageHeaderItem } from '@/types/page-header.js';
|
||||
import * as os from '@/os.js';
|
||||
import MkPageHeader from '@/components/global/MkPageHeader.vue';
|
||||
import SkUserRecentNotes from '@/components/SkUserRecentNotes.vue';
|
||||
import { acct } from '@/filters/user.js';
|
||||
|
||||
defineProps<{
|
||||
userId: string;
|
||||
}>();
|
||||
|
||||
const userRecentNotes = shallowRef<InstanceType<typeof SkUserRecentNotes>>();
|
||||
const user = computed(() => userRecentNotes.value?.user);
|
||||
const withRenotes = ref(false);
|
||||
const withReplies = ref(true);
|
||||
const onlyFiles = ref(false);
|
||||
|
||||
const headerActions = [
|
||||
{
|
||||
icon: 'ti ti-refresh',
|
||||
text: i18n.ts.reload,
|
||||
handler: () => userRecentNotes.value?.reload(),
|
||||
} satisfies PageHeaderItem,
|
||||
{
|
||||
icon: 'ti ti-dots',
|
||||
text: i18n.ts.options,
|
||||
handler: (ev) => {
|
||||
os.popupMenu([
|
||||
{
|
||||
type: 'switch',
|
||||
text: i18n.ts.showRenotes,
|
||||
ref: withRenotes,
|
||||
}, {
|
||||
type: 'switch',
|
||||
text: i18n.ts.showRepliesToOthersInTimeline,
|
||||
ref: withReplies,
|
||||
disabled: onlyFiles,
|
||||
},
|
||||
{
|
||||
type: 'divider',
|
||||
},
|
||||
{
|
||||
type: 'switch',
|
||||
text: i18n.ts.fileAttachedOnly,
|
||||
ref: onlyFiles,
|
||||
disabled: withReplies,
|
||||
},
|
||||
], ev.currentTarget ?? ev.target);
|
||||
},
|
||||
} satisfies PageHeaderItem,
|
||||
];
|
||||
|
||||
// Based on user/index.vue
|
||||
definePageMetadata(() => ({
|
||||
title: i18n.ts.user,
|
||||
icon: 'ti ti-user',
|
||||
...user.value ? {
|
||||
title: user.value.name ? ` (@${user.value.username})` : `@${user.value.username}`,
|
||||
subtitle: `@${acct(user.value)}`,
|
||||
userName: user.value,
|
||||
avatar: user.value,
|
||||
path: `/@${user.value.username}`,
|
||||
share: {
|
||||
title: user.value.name,
|
||||
},
|
||||
} : {},
|
||||
}));
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" module>
|
||||
|
||||
</style>
|
|
@ -227,6 +227,13 @@ const routes: RouteDef[] = [{
|
|||
path: '/explore',
|
||||
component: page(() => import('@/pages/explore.vue')),
|
||||
hash: 'initialTab',
|
||||
}, {
|
||||
path: '/following-feed',
|
||||
component: page(() => import('@/pages/following-feed.vue')),
|
||||
hash: 'initialTab',
|
||||
}, {
|
||||
path: '/following-feed/:userId',
|
||||
component: page(() => import('@/pages/user/recent-notes.vue')),
|
||||
}, {
|
||||
path: '/search',
|
||||
component: page(() => import('@/pages/search.vue')),
|
||||
|
|
|
@ -344,7 +344,7 @@ export function pluginReplaceIcons() {
|
|||
'ti ti-universe': 'ph-rocket-launch ph-bold ph-lg',
|
||||
'ti ti-upload': 'ph-upload ph-bold ph-lg',
|
||||
'ti ti-user': 'ph-user ph-bold ph-lg',
|
||||
'ti ti-user-check': 'ph-check ph-bold ph-lg',
|
||||
'ti ti-user-check': 'ph-user-check ph-bold ph-lg',
|
||||
'ti ti-user-circle': 'ph-user-circle ph-bold ph-lg',
|
||||
'ti ti-user-edit': 'ph-user-list ph-bold ph-lg',
|
||||
'ti ti-user-exclamation': 'ph-warning-circle ph-bold ph-lg',
|
||||
|
|
|
@ -1642,6 +1642,8 @@ declare namespace entities {
|
|||
NotesFavoritesDeleteRequest,
|
||||
NotesFeaturedRequest,
|
||||
NotesFeaturedResponse,
|
||||
NotesFollowingRequest,
|
||||
NotesFollowingResponse,
|
||||
NotesGlobalTimelineRequest,
|
||||
NotesGlobalTimelineResponse,
|
||||
NotesBubbleTimelineRequest,
|
||||
|
@ -2648,6 +2650,12 @@ type NotesFeaturedRequest = operations['notes___featured']['requestBody']['conte
|
|||
// @public (undocumented)
|
||||
type NotesFeaturedResponse = operations['notes___featured']['responses']['200']['content']['application/json'];
|
||||
|
||||
// @public (undocumented)
|
||||
type NotesFollowingRequest = operations['notes___following']['requestBody']['content']['application/json'];
|
||||
|
||||
// @public (undocumented)
|
||||
type NotesFollowingResponse = operations['notes___following']['responses']['200']['content']['application/json'];
|
||||
|
||||
// @public (undocumented)
|
||||
type NotesGlobalTimelineRequest = operations['notes___global-timeline']['requestBody']['content']['application/json'];
|
||||
|
||||
|
|
|
@ -3174,6 +3174,17 @@ declare module '../api.js' {
|
|||
credential?: string | null,
|
||||
): Promise<SwitchCaseResponseType<E, P>>;
|
||||
|
||||
/**
|
||||
* No description provided.
|
||||
*
|
||||
* **Credential required**: *Yes* / **Permission**: *read:account*
|
||||
*/
|
||||
request<E extends 'notes/following', P extends Endpoints[E]['req']>(
|
||||
endpoint: E,
|
||||
params: P,
|
||||
credential?: string | null,
|
||||
): Promise<SwitchCaseResponseType<E, P>>;
|
||||
|
||||
/**
|
||||
* No description provided.
|
||||
*
|
||||
|
|
|
@ -420,6 +420,8 @@ import type {
|
|||
NotesFavoritesDeleteRequest,
|
||||
NotesFeaturedRequest,
|
||||
NotesFeaturedResponse,
|
||||
NotesFollowingRequest,
|
||||
NotesFollowingResponse,
|
||||
NotesGlobalTimelineRequest,
|
||||
NotesGlobalTimelineResponse,
|
||||
NotesBubbleTimelineRequest,
|
||||
|
@ -873,6 +875,7 @@ export type Endpoints = {
|
|||
'notes/favorites/create': { req: NotesFavoritesCreateRequest; res: EmptyResponse };
|
||||
'notes/favorites/delete': { req: NotesFavoritesDeleteRequest; res: EmptyResponse };
|
||||
'notes/featured': { req: NotesFeaturedRequest; res: NotesFeaturedResponse };
|
||||
'notes/following': { req: NotesFollowingRequest; res: NotesFollowingResponse };
|
||||
'notes/global-timeline': { req: NotesGlobalTimelineRequest; res: NotesGlobalTimelineResponse };
|
||||
'notes/bubble-timeline': { req: NotesBubbleTimelineRequest; res: NotesBubbleTimelineResponse };
|
||||
'notes/hybrid-timeline': { req: NotesHybridTimelineRequest; res: NotesHybridTimelineResponse };
|
||||
|
@ -1268,6 +1271,7 @@ export const endpointReqTypes: Record<keyof Endpoints, 'application/json' | 'mul
|
|||
'notes/favorites/create': 'application/json',
|
||||
'notes/favorites/delete': 'application/json',
|
||||
'notes/featured': 'application/json',
|
||||
'notes/following': 'application/json',
|
||||
'notes/global-timeline': 'application/json',
|
||||
'notes/bubble-timeline': 'application/json',
|
||||
'notes/hybrid-timeline': 'application/json',
|
||||
|
|
|
@ -423,6 +423,8 @@ export type NotesFavoritesCreateRequest = operations['notes___favorites___create
|
|||
export type NotesFavoritesDeleteRequest = operations['notes___favorites___delete']['requestBody']['content']['application/json'];
|
||||
export type NotesFeaturedRequest = operations['notes___featured']['requestBody']['content']['application/json'];
|
||||
export type NotesFeaturedResponse = operations['notes___featured']['responses']['200']['content']['application/json'];
|
||||
export type NotesFollowingRequest = operations['notes___following']['requestBody']['content']['application/json'];
|
||||
export type NotesFollowingResponse = operations['notes___following']['responses']['200']['content']['application/json'];
|
||||
export type NotesGlobalTimelineRequest = operations['notes___global-timeline']['requestBody']['content']['application/json'];
|
||||
export type NotesGlobalTimelineResponse = operations['notes___global-timeline']['responses']['200']['content']['application/json'];
|
||||
export type NotesBubbleTimelineRequest = operations['notes___bubble-timeline']['requestBody']['content']['application/json'];
|
||||
|
|
|
@ -2748,6 +2748,22 @@ export type paths = {
|
|||
*/
|
||||
post: operations['notes___featured'];
|
||||
};
|
||||
'/notes/following': {
|
||||
/**
|
||||
* notes/following
|
||||
* @description No description provided.
|
||||
*
|
||||
* **Credential required**: *Yes* / **Permission**: *read:account*
|
||||
*/
|
||||
get: operations['notes___following'];
|
||||
/**
|
||||
* notes/following
|
||||
* @description No description provided.
|
||||
*
|
||||
* **Credential required**: *Yes* / **Permission**: *read:account*
|
||||
*/
|
||||
post: operations['notes___following'];
|
||||
};
|
||||
'/notes/global-timeline': {
|
||||
/**
|
||||
* notes/global-timeline
|
||||
|
@ -7955,6 +7971,7 @@ export type operations = {
|
|||
host: string;
|
||||
isSuspended?: boolean;
|
||||
isNSFW?: boolean;
|
||||
rejectReports?: boolean;
|
||||
moderationNote?: string;
|
||||
};
|
||||
};
|
||||
|
@ -22181,6 +22198,68 @@ export type operations = {
|
|||
};
|
||||
};
|
||||
};
|
||||
/**
|
||||
* notes/following
|
||||
* @description No description provided.
|
||||
*
|
||||
* **Credential required**: *Yes* / **Permission**: *read:account*
|
||||
*/
|
||||
notes___following: {
|
||||
requestBody: {
|
||||
content: {
|
||||
'application/json': {
|
||||
/** @default false */
|
||||
mutualsOnly?: boolean;
|
||||
/** @default 10 */
|
||||
limit?: number;
|
||||
/** Format: misskey:id */
|
||||
sinceId?: string;
|
||||
/** Format: misskey:id */
|
||||
untilId?: string;
|
||||
sinceDate?: number;
|
||||
untilDate?: number;
|
||||
};
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
/** @description OK (with results) */
|
||||
200: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Note'][];
|
||||
};
|
||||
};
|
||||
/** @description Client error */
|
||||
400: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Error'];
|
||||
};
|
||||
};
|
||||
/** @description Authentication error */
|
||||
401: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Error'];
|
||||
};
|
||||
};
|
||||
/** @description Forbidden error */
|
||||
403: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Error'];
|
||||
};
|
||||
};
|
||||
/** @description I'm Ai */
|
||||
418: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Error'];
|
||||
};
|
||||
};
|
||||
/** @description Internal server error */
|
||||
500: {
|
||||
content: {
|
||||
'application/json': components['schemas']['Error'];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
/**
|
||||
* notes/global-timeline
|
||||
* @description No description provided.
|
||||
|
|
Loading…
Reference in a new issue