MFavoritesAndBlockedList

MFavoritesAndBlockedList ⇐ Trait

This mixin add the favorite API to your service, so you will be able to manage favorites list and a blocked list. The service MUST define the BLOCKED_LIST_ID and ALL_LIST_ID properties.

Kind: global mixin
Extends: Trait
Properties

NameTypeDescription
BLOCKED_LIST_IDstring

The id of the list of blocked channels; to be refined by the container

ALL_LIST_IDstring

The id of the list of all channels; to be refined by the container

readonlyChannelGroupsArray.<Object>

List of predefined channel groups (in general this list is provided by operator). Those favorites are not editable.

readonlyChannelsBlockedArray.<string>

List of predefined blocked channels ids (in general this list is provided by operator). Those blocked channels are not editable.

Example

Class.declare("AbstractChannelService",  {
  traits: [$MFavoritesAndBlockedList],

  properties {
      BLOCKED_LIST_ID : "BLOCKED_CHANNEL_LIST_ID";
      ALL_LIST_ID : "ALL_CHANNEL_LIST_ID";
  }
});

addFavorite(model, favoriteListId, options) ⇒ Promise.<BusinessModel, Error>

Add a model to the list of favorite models.

Kind: instance method of MFavoritesAndBlockedList
Returns: Promise.<BusinessModel, Error> - A Promise resolved with the model added, rejected in case of error

ParamTypeDescription
modelBusinessModel

The model object

favoriteListIdstring

The id of the favorite list

optionsObject

options

removeFavorite(model, favoriteListId, options) ⇒ Promise.<BusinessModel, Error>

Remove a model from the list of favorite models.

Kind: instance method of MFavoritesAndBlockedList
Returns: Promise.<BusinessModel, Error> - A Promise resolved with the model removed, rejected in case of error

ParamTypeDescription
modelBusinessModel

The model object

favoriteListIdstring

The id of the favorite list

optionsObject

options

createFavoriteList(name, [options]) ⇒ string

Create a favorite list Please note that some vendors do not offer the possibility to create list (they have an unalterable number of favorite lists) If a favorite list with the name already exists, return it’s id.

Kind: instance method of MFavoritesAndBlockedList
Returns: string - The id of the created list

ParamTypeDescription
namestring

The name of the favorite list

[options]Object

Additional options that may be needed by the middleware

deleteFavoriteList(favoriteListId, [options]) ⇒ string

Delete a favorite list Please note that some vendors do not offer the possibility to delete a list (they have a unalterable number of favorite lists)

Kind: instance method of MFavoritesAndBlockedList
Returns: string - The id of the deleted list

ParamTypeDescription
favoriteListIdstring

The id of the favorite list

[options]Object

Additional options that may be needed by the middleware

getAvailableFavoriteLists() ⇒ Array.<Favorite>

Return the list of the favorite lists available on the device. On some vendors, there is a bank of favorite lists (for example 8 predefined favorite lists) On other, you need to create the favorite list before being able to use it.

Kind: instance method of MFavoritesAndBlockedList
Returns: Array.<Favorite> - An array of object containing information on the list (e.g. [ {id:"favoriteId", name:"favorite name', readonly: true}, ...])

addBlocked(model, options) ⇒ Promise.<BusinessModel>

Add a model to a list of blocked models.

Kind: instance method of MFavoritesAndBlockedList
Returns: Promise.<BusinessModel> - A Promise resolved when the model has been added.

ParamTypeDefaultDescription
modelBusinessModel

A model object.

optionsObject

Additional options

[options.force]booleanfalse

If true, don't use the cache

removeBlocked(model, options) ⇒ Promise.<BusinessModel>

Remove a model from a list of blocked models.

Kind: instance method of MFavoritesAndBlockedList
Returns: Promise.<BusinessModel> - A Promise resolved when the model has been removed.

ParamTypeDefaultDescription
modelBusinessModel

A model object.

optionsObject

Additional options

[options.force]Booleanfalse

If true, don't use the cache

_getReadonlyFavoriteList(favoriteListId) ⇒ Promise.<Array.<string>, Error>

Get the ids list of favorite list for a readonly list

Kind: instance method of MFavoritesAndBlockedList
Returns: Promise.<Array.<string>, Error> - A promise resolved with an array of channel ids or rejected in case of problem
Access: protected

ParamType
favoriteListIdstring

_getReadonlyBlockedChannelMap() ⇒ Object.<string, AbstractChannel>

Returns read only blocked channels map

Kind: instance method of MFavoritesAndBlockedList
Returns: Object.<string, AbstractChannel> - Map of read only blocked channels
Access: protected

_onModelBlock(model) ⇒ Promise

Triggered when a model has been blocked isUserBlocked should be set to true

Kind: instance method of MFavoritesAndBlockedList
Emits: modelBlock
Access: protected

ParamTypeDescription
modelBusinessModel

A model object.

_onModelUnblock(model) ⇒ Promise

Triggered when a model has been unblocked isUserBlocked should be set to false

Kind: instance method of MFavoritesAndBlockedList
Emits: MFavoritesAndBlockedList~event:modelUnblock
Access: protected

ParamTypeDescription
modelBusinessModel

A model object.

“modelBlock”

Kind: event emitted by MFavoritesAndBlockedList
Properties

NameType
modelBusinessModel

“modelUnblock”

Kind: event emitted by MFavoritesAndBlockedList
Properties

NameType
modelBusinessModel