feat: ✨ remote featured notes
This commit is contained in:
parent
5a20d2af27
commit
4fe24fec1a
|
@ -27,6 +27,11 @@ export const paramDef = {
|
||||||
properties: {
|
properties: {
|
||||||
limit: { type: "integer", minimum: 1, maximum: 100, default: 10 },
|
limit: { type: "integer", minimum: 1, maximum: 100, default: 10 },
|
||||||
offset: { type: "integer", default: 0 },
|
offset: { type: "integer", default: 0 },
|
||||||
|
origin: {
|
||||||
|
type: "string",
|
||||||
|
enum: ["combined", "local", "remote"],
|
||||||
|
default: "local",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
required: [],
|
required: [],
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -37,7 +42,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
|
|
||||||
const query = Notes.createQueryBuilder("note")
|
const query = Notes.createQueryBuilder("note")
|
||||||
.addSelect("note.score")
|
.addSelect("note.score")
|
||||||
.where("note.userHost IS NULL")
|
// .where("note.userHost IS NULL")
|
||||||
.andWhere("note.score > 0")
|
.andWhere("note.score > 0")
|
||||||
.andWhere("note.createdAt > :date", { date: new Date(Date.now() - day) })
|
.andWhere("note.createdAt > :date", { date: new Date(Date.now() - day) })
|
||||||
.andWhere("note.visibility = 'public'")
|
.andWhere("note.visibility = 'public'")
|
||||||
|
@ -53,6 +58,15 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
.leftJoinAndSelect("renoteUser.avatar", "renoteUserAvatar")
|
.leftJoinAndSelect("renoteUser.avatar", "renoteUserAvatar")
|
||||||
.leftJoinAndSelect("renoteUser.banner", "renoteUserBanner");
|
.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) generateMutedUserQuery(query, user);
|
||||||
if (user) generateBlockedUserQuery(query, user);
|
if (user) generateBlockedUserQuery(query, user);
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<MkSpacer :content-max="800">
|
<MkSpacer :content-max="800">
|
||||||
<MkTab v-model="tab" style="margin-bottom: var(--margin);">
|
<MkTab v-model="tab" style="margin-bottom: var(--margin);">
|
||||||
<option value="notes">{{ i18n.ts.notes }}</option>
|
<option value="local">{{ i18n.ts.local }}</option>
|
||||||
<option value="polls">{{ i18n.ts.poll }}</option>
|
<option value="remote">{{ i18n.ts.remote }}</option>
|
||||||
</MkTab>
|
</MkTab>
|
||||||
<XNotes v-if="tab === 'notes'" :pagination="paginationForNotes"/>
|
<XNotes v-if="tab === 'local'" :pagination="paginationForLocal"/>
|
||||||
<XNotes v-else-if="tab === 'polls'" :pagination="paginationForPolls"/>
|
<XNotes v-else-if="tab === 'remote'" :pagination="paginationForRemote"/>
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -14,17 +14,24 @@ import XNotes from '@/components/MkNotes.vue';
|
||||||
import MkTab from '@/components/MkTab.vue';
|
import MkTab from '@/components/MkTab.vue';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
|
|
||||||
const paginationForNotes = {
|
const paginationForLocal = {
|
||||||
endpoint: 'notes/featured' as const,
|
endpoint: 'notes/featured' as const,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
offsetMode: true,
|
offsetMode: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const paginationForPolls = {
|
const paginationForRemote = {
|
||||||
endpoint: 'notes/polls/recommendation' as const,
|
endpoint: 'notes/featured' as const,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
|
origin: 'remote',
|
||||||
offsetMode: true,
|
offsetMode: true,
|
||||||
};
|
}
|
||||||
|
|
||||||
|
// const paginationForRemote = {
|
||||||
|
// endpoint: 'notes/polls/recommendation' as const,
|
||||||
|
// limit: 10,
|
||||||
|
// offsetMode: true,
|
||||||
|
// };
|
||||||
|
|
||||||
let tab = $ref('notes');
|
let tab = $ref('notes');
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue