Finishing up comment tree paging.

This commit is contained in:
Dessalines 2022-07-27 09:44:31 -04:00
parent 4f164a05e4
commit af00b4cc40
4 changed files with 56 additions and 9 deletions

View file

@ -2,7 +2,7 @@ import { Option } from "@sniptt/monads";
import { Expose, Transform, Type } from "class-transformer";
import "reflect-metadata";
import { toOption, toUndefined } from "../../utils";
import { ListingType, SortType } from "../others";
import { CommentSortType, ListingType } from "../others";
import { CommentReportView, CommentView } from "../views";
export class CreateComment {
@ -120,7 +120,11 @@ export class GetComments {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
sort: Option<SortType>;
sort: Option<CommentSortType>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
max_depth: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()

View file

@ -2,7 +2,7 @@ import { Option } from "@sniptt/monads";
import { Expose, Transform, Type } from "class-transformer";
import "reflect-metadata";
import { toOption, toUndefined } from "../../utils";
import { SortType } from "../others";
import { CommentSortType, SortType } from "../others";
import {
CommentReplyView,
CommentView,
@ -347,7 +347,7 @@ export class GetReplies {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
sort: Option<SortType>;
sort: Option<CommentSortType>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@ -371,7 +371,7 @@ export class GetPersonMentions {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
sort: Option<SortType>;
sort: Option<CommentSortType>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()

View file

@ -42,7 +42,14 @@ export class PostResponse {
}
export class GetPost {
id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
id: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
comment_id: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()

View file

@ -1,6 +1,7 @@
import { Option } from "@sniptt/monads";
import { Expose, Transform } from "class-transformer";
import { toOption, toUndefined } from "../utils";
import { CommentReplyView, CommentView, PersonMentionView } from "./views";
export const VERSION = "v3";
/**
@ -89,18 +90,25 @@ export enum UserOperation {
}
/**
* Different sort types used in lemmy.
* Different post sort types used in lemmy.
*/
export enum SortType {
/**
* Posts sorted by the most recent comment.
* Posts sorted by hot, but bumped by new comments up to 2 days
*/
Active = "Active",
/**
* Posts sorted by the published time.
* Posts sorted by a decaying rank.
*/
Hot = "Hot",
/**
* Posts sorted by the published time.
*/
New = "New",
/**
* Posts sorted by the published time ascending
*/
Old = "Old",
/**
* The top posts for this last day.
*/
@ -131,6 +139,28 @@ export enum SortType {
NewComments = "NewComments",
}
/**
* Different comment sort types used in lemmy.
*/
export enum CommentSortType {
/**
* Comments sorted by a decaying rank.
*/
Hot = "Hot",
/**
* Comments sorted by top score.
*/
Top = "Top",
/**
* Comments sorted by new.
*/
New = "New",
/**
* Comments sorted by old.
*/
Old = "Old",
}
/**
* The different listing types for post and comment fetches.
*/
@ -187,3 +217,9 @@ export class SiteMetadata {
Object.assign(this, init);
}
}
export interface CommentNode {
comment_view: CommentView | PersonMentionView | CommentReplyView;
children: CommentNode[];
depth: number;
}