searchOutcome

What a search ended with, and what the search screen shows for it. SearchTask reports the status; SearchResults shows the view. Pure, so the rules are unit-tested without a network seam. Also which reads a search sends (canSearchLiveTv), since a read the server refuses would make every search look partial.

A read that failed says nothing about what the server holds, so a search that got no answer must never read as one that found nothing: "failed" offers Try again, "empty" says there are no results. A search whose reads partly answered shows what arrived and says some is missing.

Members

(static, constant) SHOW_EMPTY

Default Value
  • empty

(static, constant) SHOW_FAILED

Default Value
  • failed

(static, constant) SHOW_RESULTS

Default Value
  • results

(static, constant) STATUS_FAILED

Default Value
  • failed

(static, constant) STATUS_OK

Default Value
  • ok

(static, constant) STATUS_PARTIAL

Default Value
  • partial

Methods

(static) canSearchLiveTv(policy) → {boolean}

Whether a search sends its Live TV program read. Jellyfin refuses that read to a user without Live TV access (its LiveTvAccess policy), so asking would count every one of that user's searches as partial. A policy, or a field, that is missing reads as allowed, as SessionDataTransformer defaults it.

Parameters:
NameTypeDescription
policydynamic

m.global.user.policy (JellyfinUserPolicy node or AA), or invalid

Returns:

true when the search asks for Live TV programs

Type: 
boolean

(static) statusOf(sentCount, failedCount) → {string}

How a search's reads ended: every one answered, some did, or none did. A search that sent nothing (no read could be built) failed, since nothing answered for it.

Parameters:
NameTypeDescription
sentCountinteger

the reads asked for

failedCountinteger

the reads that did not answer

Returns:

a STATUS_ constant

Type: 
string

(static) view(status, itemCount) → {object}

What the screen shows for a search that ended with status and itemCount items, the toast to raise with it, and what the screen reader announces ("" for none). A partial search that found nothing is a failure: the reads that answered say nothing about the ones that did not. A status that is none of these reads as failed, since nobody can vouch for its empty list.

Failed and empty are announced because focus stays on the keyboard, and the screen reader speaks only what has focus: without it, neither is heard. Results need no announcement (the viewer moves into them), and a partial search's toast is its notice.

Parameters:
NameTypeDescription
statusdynamic

a STATUS_ constant

itemCountinteger

the items the search found

Returns:

{ show: a SHOW_ constant, toastKey and announceKey: a translation key or "" }

Type: 
object