mirror of
https://github.com/wassname/talk.git
synced 2026-08-07 11:29:44 +08:00
* feat: initial serverside featuring support * Update schema.graphql * feat: add feature comment to moderation dropdown * feat: feature comments on the stream embed * fix: tests * fix: optimize loading and fix tests * feat: hide featured tab when empty * feat: introduced flattening * fix: snapshots * fix: spacing * feat: added a dark variant to popover * feat: add featured comments tooltip * fix: better tests * feat: added tag counts * chore: changed string to enum * fix: removed unused translation * fix: changed schema for String -> TAG * feat: split comments -> comments, featuredComments * fix: adapt client to new endpoints * feat: use featured comment counts * test: featured count handling * fix: snapshots and optimistically approve comment during feature * fix: remove unnecessary assertion * feat: approve featured comments * fix: make optimistic update less reliant on existing data
35 lines
1018 B
TypeScript
35 lines
1018 B
TypeScript
import { Comment, Revision } from ".";
|
|
import { VISIBLE_STATUSES } from "./constants";
|
|
|
|
/**
|
|
* hasAncestors will check to see if a given comment has any ancestors.
|
|
*
|
|
* @param comment the comment to check the ancestors on
|
|
*/
|
|
export function hasAncestors(
|
|
comment: Pick<Comment, "ancestorIDs" | "parentID">
|
|
): comment is Required<Pick<Comment, "ancestorIDs" | "parentID">> {
|
|
return Boolean(comment.ancestorIDs.length > 0);
|
|
}
|
|
|
|
/**
|
|
* hasVisibleStatus will check to see if the comment has a visibility status
|
|
* where readers could see it.
|
|
*
|
|
* @param comment the comment to check the status on
|
|
*/
|
|
export function hasVisibleStatus(comment: Pick<Comment, "status">): boolean {
|
|
return VISIBLE_STATUSES.includes(comment.status);
|
|
}
|
|
|
|
/**
|
|
* getLatestRevision will get the latest revision from a Comment.
|
|
*
|
|
* @param comment the comment that contains the revisions
|
|
*/
|
|
export function getLatestRevision(
|
|
comment: Pick<Comment, "revisions">
|
|
): Revision {
|
|
return comment.revisions[comment.revisions.length - 1];
|
|
}
|