feat: remote featured notes

This commit is contained in:
ThatOneCalculator 2023-02-12 12:07:07 -08:00
parent 5925703cc9
commit dd45c01b68
2 changed files with 30 additions and 9 deletions

View File

@ -27,6 +27,11 @@ export const paramDef = {
properties: {
limit: { type: "integer", minimum: 1, maximum: 100, default: 10 },
offset: { type: "integer", default: 0 },
origin: {
type: "string",
enum: ["combined", "local", "remote"],
default: "local",
},
},
required: [],
} as const;
@ -37,7 +42,7 @@ export default define(meta, paramDef, async (ps, user) => {
const query = Notes.createQueryBuilder("note")
.addSelect("note.score")
.where("note.userHost IS NULL")
// .where("note.userHost IS NULL")
.andWhere("note.score > 0")
.andWhere("note.createdAt > :date", { date: new Date(Date.now() - day) })
.andWhere("note.visibility = 'public'")
@ -53,6 +58,15 @@ export default define(meta, paramDef, async (ps, user) => {
.leftJoinAndSelect("renoteUser.avatar", "renoteUserAvatar")
.leftJoinAndSelect("renoteUser.banner", "renoteUserBanner");
switch (ps.origin) {
case "local":
query.andWhere("note.userHost IS NULL");
break;
case "remote":
query.andWhere("note.userHost IS NOT NULL");
break;
}
if (user) generateMutedUserQuery(query, user);
if (user) generateBlockedUserQuery(query, user);

View File

@ -1,11 +1,11 @@
<template>
<MkSpacer :content-max="800">
<MkTab v-model="tab" style="margin-bottom: var(--margin);">
<option value="notes">{{ i18n.ts.notes }}</option>
<option value="polls">{{ i18n.ts.poll }}</option>
<option value="local">{{ i18n.ts.local }}</option>
<option value="remote">{{ i18n.ts.remote }}</option>
</MkTab>
<XNotes v-if="tab === 'notes'" :pagination="paginationForNotes"/>
<XNotes v-else-if="tab === 'polls'" :pagination="paginationForPolls"/>
<XNotes v-if="tab === 'local'" :pagination="paginationForLocal"/>
<XNotes v-else-if="tab === 'remote'" :pagination="paginationForRemote"/>
</MkSpacer>
</template>
@ -14,17 +14,24 @@ import XNotes from '@/components/MkNotes.vue';
import MkTab from '@/components/MkTab.vue';
import { i18n } from '@/i18n';
const paginationForNotes = {
const paginationForLocal = {
endpoint: 'notes/featured' as const,
limit: 10,
offsetMode: true,
};
const paginationForPolls = {
endpoint: 'notes/polls/recommendation' as const,
const paginationForRemote = {
endpoint: 'notes/featured' as const,
limit: 10,
origin: 'remote',
offsetMode: true,
};
}
// const paginationForRemote = {
// endpoint: 'notes/polls/recommendation' as const,
// limit: 10,
// offsetMode: true,
// };
let tab = $ref('notes');
</script>