GridPresenterBase. GridPresenterBase

new GridPresenterBase() → {GridPresenterBase}

Constructor - view is set later via onInit()

Properties
NameTypeDescription
viewdynamic

Reference to the BaseGridView component

logdynamic

Reference to the log instance

apiFiltersdynamic

Cached filter options from API (invalid = not loaded, {} = load failed)

filtersLoadedFordynamic

Which library m.apiFilters holds a SUCCESSFUL load for, "" when none. This is the ' cache, and the reason one exists: the filter lists are needed only if the user opens ' the options panel, but loadFilters() is reached from configureLoadTask(), which runs ' on every query build: every sort change, filter change, view change, alpha letter ' and voice search. Without this, browsing a library refetches both filter endpoints ' repeatedly for data most sessions never look at, competing with the grid's own load ' on a contended render thread (see docs/architecture/async.md).

filtersInFlightFordynamic

The library a fetch is CURRENTLY in flight for, "" when none. Separate from the cache ' because a request that has not answered yet is neither loaded nor absent, and because ' fetchAsync keys its pending registry by requestId: two overlapping loads of the same ' library would collide on "filters-".

filtersRequestdynamic

What refreshFilters() needs to repeat the last request. Unset on a presenter with no ' dynamic filters, which is what makes refreshFilters() a no-op there.

Returns:
Type: 
GridPresenterBase

Methods

configureLoadTask(task, parentItem, viewMode, _task, _parentItem, _viewMode) → {void}

Configures the LoadItemsTask2 query for data loading

Parameters:
NameTypeDescription
taskobject

The query: an AA of LoadItemsTask2 input fields, not the node (BaseGridView runs each load on a new node; see gridQuery.build). Assign fields only.

parentItemobject

The library item being displayed

viewModestring

Current view mode (for example "Movies", "MoviesGrid")

_taskobject
_parentItemobject
_viewModestring
Returns:
Type: 
void

(protected) currentView() → {string}

The view mode the grid is currently showing, or "" when it cannot be read.

getOptions() receives the parent item but not the view, and some of its lists depend on which view is up (a Collections view sorts BoxSets, not movies), so the view is read back off the host component. BaseGridView keeps currentView in step with its own m.view (it sets it in loadInitialItems before SetUpOptions runs, and again in optionsClosed before the reload), so this is the same string the load is using.

Returns:

for example "MoviesGrid", or "" when unknown

Type: 
string

getBackdropMode() → {string}

Returns the backdrop mode for this presenter

Returns:

"presentation" | "fullscreen" | "none"

Type: 
string

getGridConfig(viewMode, _viewMode) → {object}

Returns grid layout configuration for the specified view mode

Parameters:
NameTypeDescription
viewModestring

Current view mode

  • translation: [x, y] grid position
  • itemSize: [width, height] size of each grid cell
  • rowHeights: [height] array of row heights
  • numRows: string number of visible rows
  • numColumns: string number of columns
  • imageDisplayMode: "scaleToZoom" | "scaleToFit"
_viewModestring
Returns:

Grid config with properties:

Type: 
object

getOptions(parentItem, _parentItem) → {object}

Returns the options configuration for ItemGridOptions

Parameters:
NameTypeDescription
parentItemobject

The library item being displayed

_parentItemobject
Returns:

Options object with views, sort, filter arrays

Type: 
object

loadFilters(parentItem, itemType, forceopt) → {void}

Load dynamic filter options (Genres, Years, Ratings) from the Jellyfin API. Call from configureLoadTask() in subclasses that need dynamic filters. Delegates the fetch to the host component (BaseGridView.loadFilters) via callFunc so it runs in component-m context, where fetchAsync + auto-abandon work. A presenter is a class, not a component, so the auto-abandon plugin can't inject into it (Phase-4 collapse of GetFiltersTask; see docs/dev/promises.md). Results arrive via onFiltersLoaded(). Set by refreshFilters() when the panel opens.

Parameters:
NameTypeAttributesDefaultDescription
parentItemobject

The library item to load filters for

itemTypestring

The item type to filter (for example "Movie", "Series")

forceboolean<optional>
false

refetch even when this library is already cached.

Returns:
Type: 
void

onDestroy() → {void}

Called when presenter is being destroyed Override to clean up resources, stop tasks, unobserve fields Always call super.onDestroy() at the end of overrides

Returns:
Type: 
void

onFiltersLoaded(filters, errorMsg) → {void}

Called when filters are delivered by the host component's promise (BaseGridView.loadFilters). Caches the result in m.apiFilters and shows a toast on failure.

Parameters:
NameTypeDescription
filtersobject

The filter options AA (empty {} on failure)

errorMsgstring

Non-empty on failure; triggers a toast

Returns:
Type: 
void

onInit(view) → {void}

Called after presenter is attached to BaseGridView Stores the view reference; a subclass adds its own nodes (MoviePresenter's logo task) Override in subclass but call super.onInit(view) first

Parameters:
NameTypeDescription
viewobject

Reference to BaseGridView component

Returns:
Type: 
void

onItemFocused(item, currentView, _item, _currentView) → {void}

Called when an item receives focus Override to update presentation info display

Parameters:
NameTypeDescription
itemobject

The focused ContentNode item

currentViewstring

The current view mode (for example "Movies", "MoviesGrid")

_itemobject
_currentViewstring
Returns:
Type: 
void

onOptionsClosed(options, _options) → {void}

Called when options dialog is closed Override to handle presenter-specific option changes

Parameters:
NameTypeDescription
optionsobject

The ItemGridOptions component

_optionsobject
Returns:
Type: 
void

refreshFilters() → {void}

refreshFilters: Revalidate the cached filter lists in the background.

Called when the options panel OPENS, which is the only moment the lists are actually looked at, so freshness is bought exactly where it is spent, and a session that never opens the panel pays for one load instead of one per query build.

Not rendered into the open panel, on purpose. BaseGridView.SetUpOptions() has already read m.apiFilters by the time this answers, and re-running it would reassign the panel's content and reset checkedItem: categories would appear and shift focus under a cursor already moving through the list. The refreshed lists show on the NEXT open, which is the stale-while-revalidate contract and the reason no TTL is needed.

It also retries a previous failure: a failed load never marks the cache populated, so the panel that needs those categories is what asks for them again.

Returns:
Type: 
void

(protected) serverVersion() → {string}

The connected server's version string, or "" when it cannot be read.

Presenters run on the render thread, where m.global is owned locally and free to touch (2.0 µs against 93 µs from a Task, measured 2026-08-23 on a Stick 4K; see docs/architecture/threading.md). The guards are for the unit suites, which construct a presenter against a stand-in view with no global at all, and textOrEmpty() rather than toString() because toString() falls through to Str() and FAULTS on Invalid.

Returns:

for example "12.0.0", or "" when unknown

Type: 
string

shouldShowPresentationInfo(viewMode, _viewMode) → {boolean}

Returns whether to show presentation info panel for the view mode

Parameters:
NameTypeDescription
viewModestring

Current view mode

_viewModestring
Returns:

True to show info panel

Type: 
boolean

showToast(message, toastTypeopt) → {void}

Show a toast notification via the scene-level Toast component. Safe to call from presenter classes (routes through view's scene reference).

Parameters:
NameTypeAttributesDefaultDescription
messagestring

The message to display

toastTypestring<optional>
"error"

"error", "success", or "info"

Returns:
Type: 
void

showsTVGuide(viewMode, _viewMode) → {boolean}

Returns whether the view mode is the TV Guide (EPG) instead of the item grid

Parameters:
NameTypeDescription
viewModestring

Current view mode

_viewModestring
Returns:

True to show the TV Guide

Type: 
boolean