Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Comment

A comment that’s on a Page. Holds the comment’s data and can be used to query and be updated of changes.

Hierarchy

  • Comment

Index

Constructors

constructor

  • Creates a comment on the given page.

    Parameters

    • parent: Comment | Page

      The created comment’s parent: The page it’s on if it’s a top level comment, or the comment this comment replies to if it’s a reply.

    Returns Comment

Properties

author

author: Author = new Author(this)

Optional id

id: undefined | number

This comment’s id (assigned by the server). Will be undefined as long as no id was assigned by the server yet.

onDeleted

onDeleted: VoidAsyncEvent = new VoidAsyncEvent()

Fired when this comment was removed from the server.

onDislikesChanged

onDislikesChanged: AsyncEvent<number> = new AsyncEvent<number>()

Fired when the number of dislikes on this comment changed.

onIdAssigned

onIdAssigned: AsyncEvent<number> = new AsyncEvent<number>()

Fired when this comment receives an ID. This happens after it has been successfully transfered to the server for the first time.

onLikesChanged

onLikesChanged: AsyncEvent<number> = new AsyncEvent<number>()

Fired when the number of likes on this comment changed.

onModifiedChanged

onModifiedChanged: AsyncEvent<Date> = new AsyncEvent<Date>()

Fired when the date of the last modification of this comment changed.

onPublished

onPublished: VoidAsyncEvent = new VoidAsyncEvent()

Fired when this comment is published (= made visible to the public).

onTextChanged

onTextChanged: AsyncEvent<string> = new AsyncEvent<string>()

Fired when this comment’s text changed

page

page: Page

The page this comment is on.

replies

replies: CommentList

Comments replying to this comment. Comments in this list have this as their #parent.

Optional repliesTo

repliesTo: Comment

The comment this comment replies to if it’s a reply. undefined otherwise.

Accessors

createdOn

  • get createdOn(): Date | undefined
  • Date and time this comment was submitted to the server. It’s undefined if the comment was not submitted yet.

    Returns Date | undefined

deleted

  • get deleted(): boolean
  • Whether this comment once existed on the server but is now deleted. Deleted comments may still have (not deleted) replies.

    Returns boolean

dislikes

  • get dislikes(): number
  • The number of dislikes placed on this comment.

    Returns number

lastModifiedOn

  • get lastModifiedOn(): Date | undefined
  • Date and time at which this comment was last modified. It’s undefined if this comment was not yet modified.

    Returns Date | undefined

likes

  • get likes(): number
  • The number of likes placed on this comment.

    Returns number

published

  • get published(): boolean
  • Whether this comment is published (i.e. can be seen by anybody).

    Returns boolean

    true iff this comment exists on the server and does not await moderation.

rawText

  • get rawText(): string | undefined
  • set rawText(rawText: string | undefined): void
  • This comments’s raw text. This is the unrendered, unfiltered text as entered by the user. The raw text is only set if this comment was created or edited by the user. Comments received from the server do not have a raw text set. It’s undefined in that case.

    Returns string | undefined

  • This comments’s raw text. This is the unrendered, unfiltered text as entered by the user.

    Parameters

    • rawText: string | undefined

    Returns void

text

  • get text(): string | undefined
  • The comment’s text. If this comment is not known to the server yet, this is undefined.

    Returns string | undefined

Methods

delete

  • delete(): Promise<void>

fetch

  • Updates this comment’s data from the server.

    Returns Promise<Comment>

    A promised resolved with this when the update suceeded.

send

  • Sends this comment to the server. If this comment is not known to the server yet, this will create the comment on the server. It will be updated on the server otherwise. If this comment is updated, the action may fail because the user is not allowed to edit this comment. See https://posativ.org/isso/docs/configuration/server/#guard for details.

    Calling this method has no effect if this comment wasn’t changed since the last call to it.

    Returns Promise<Comment>

    A promise that will be fulfilled with this when this comment was submitted to the server.

sendDislike

  • sendDislike(): Promise<number>
  • Sends a dislike to the server, increasing the number of dislike on this comment by one.

    Returns Promise<number>

    A promise that will be resolved with the new number of dislikes when the server request succeeded.

sendLike

  • sendLike(): Promise<number>
  • Sends a like to the server, increasing the number of likes on this comment by one.

    Returns Promise<number>

    A promise that will be resolved with the new number of likes when the server request succeeded.

Generated using TypeDoc