Reference Source
import PostStreamState from 'flarum/forum/states/PostStreamState'
public class | source

PostStreamState

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public

The description to render on the scrubber.

public

The discussion to display the post stream for.

public

When the page is scrolled, goToIndex is called, or the page is loaded, various listeners result in the scrubber being updated with a new position and values.

public
public
public
public
public
public
public
public
public

Whether or not the infinite-scrolling auto-load functionality is disabled.

public

targetPost: {"number": *}

public

The number of posts that are currently visible in the viewport.

public
public

Method Summary

Public Methods
public

Get the total number of posts in the discussion.

public

Check whether or not the scrubber should be disabled, i.e.

public

Load and scroll up to the first post in the discussion.

public

goToIndex(index: number, noAnimation: Boolean): Promise

Load and scroll to a certain index within the discussion.

public

Load and scroll down to the last post in the discussion.

public

goToNumber(number: number | String, noAnimation: Boolean): Promise

Load and scroll to a post with a certain number.

public

Clear the stream and load posts near a certain index.

public

Clear the stream and load posts near a certain number.

public

loadPage(start: number, end: number, backwards: Boolean)

Load a page of posts into the stream and redraw.

public

loadRange(start: number, end: number): Promise

Load and inject the specified range of posts into the stream, without clearing it.

public

posts(): Post[]

Get the visible page of posts.

public

reset(start: number, end: number)

Reset the stream so that a specific range of posts is displayed.

public

sanitizeIndex(index: number): *

Make sure that the given index is not outside of the possible range of indexes in the discussion.

public

show(posts: Post[])

Set up the stream with the given array of posts.

public

update(): *

Update the stream so that it loads and includes the latest posts in the discussion, if the end is being viewed.

public

Are we currently viewing the end of the discussion?

Private Methods
private

Load the next page of posts.

private

Load the previous page of posts.

Public Constructors

public constructor() source

Public Members

public animateScroll: * source

public description: String source

The description to render on the scrubber.

public discussion: Discussion source

The discussion to display the post stream for.

public forceUpdateScrubber: Boolean source

When the page is scrolled, goToIndex is called, or the page is loaded, various listeners result in the scrubber being updated with a new position and values. However, if goToNumber is called, the scrubber will not be updated. Accordingly, we add logic to the scrubber's onupdate to update itself, but only when needed, as indicated by this property.

public index: number source

public loadNext: * source

public loadPageTimeouts: {} source

public loadPrevious: * source

public loadPromise: * source

public needsScroll: boolean source

public number: number source

public pagesLoading: number source

public paused: Boolean source

Whether or not the infinite-scrolling auto-load functionality is disabled.

public targetPost: {"number": *} source

public visible: Number source

The number of posts that are currently visible in the viewport.

public visibleEnd: * source

public visibleStart: * source

Public Methods

public count(): number source

Get the total number of posts in the discussion.

Return:

number

public disabled(): Boolean source

Check whether or not the scrubber should be disabled, i.e. if all of the posts are visible in the viewport.

Return:

Boolean

public goToFirst(): Promise source

Load and scroll up to the first post in the discussion.

Return:

Promise

public goToIndex(index: number, noAnimation: Boolean): Promise source

Load and scroll to a certain index within the discussion.

Params:

NameTypeAttributeDescription
index number
noAnimation Boolean

Return:

Promise

public goToLast(): Promise source

Load and scroll down to the last post in the discussion.

Return:

Promise

public goToNumber(number: number | String, noAnimation: Boolean): Promise source

Load and scroll to a post with a certain number.

Params:

NameTypeAttributeDescription
number number | String

The post number to go to. If 'reply', go to the last post and scroll the reply preview into view.

noAnimation Boolean

Return:

Promise

public loadNearIndex(index: number): Promise source

Clear the stream and load posts near a certain index. A page of posts surrounding the given index will be loaded. Returns a promise. If the given index is already loaded, the promise will be resolved immediately.

Params:

NameTypeAttributeDescription
index number

Return:

Promise

public loadNearNumber(number: number): Promise source

Clear the stream and load posts near a certain number. Returns a promise. If the post with the given number is already loaded, the promise will be resolved immediately.

Params:

NameTypeAttributeDescription
number number

Return:

Promise

public loadPage(start: number, end: number, backwards: Boolean) source

Load a page of posts into the stream and redraw.

Params:

NameTypeAttributeDescription
start number
end number
backwards Boolean

public loadRange(start: number, end: number): Promise source

Load and inject the specified range of posts into the stream, without clearing it.

Params:

NameTypeAttributeDescription
start number
end number

Return:

Promise

public posts(): Post[] source

Get the visible page of posts.

Return:

Post[]

public reset(start: number, end: number) source

Reset the stream so that a specific range of posts is displayed. If a range is not specified, the first page of posts will be displayed.

Params:

NameTypeAttributeDescription
start number
  • optional
end number
  • optional

public sanitizeIndex(index: number): * source

Make sure that the given index is not outside of the possible range of indexes in the discussion.

Params:

NameTypeAttributeDescription
index number

Return:

*

public show(posts: Post[]) source

Set up the stream with the given array of posts.

Params:

NameTypeAttributeDescription
posts Post[]

public update(): * source

Update the stream so that it loads and includes the latest posts in the discussion, if the end is being viewed.

Return:

*

public viewingEnd(): boolean source

Are we currently viewing the end of the discussion?

Return:

boolean

Private Methods

private _loadNext() source

Load the next page of posts.

private _loadPrevious() source

Load the previous page of posts.