mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
type sorting in Library implemented
This commit is contained in:
parent
85ac09ebc0
commit
51f1fd36e1
2 changed files with 17 additions and 3 deletions
|
|
@ -4,6 +4,19 @@ const CATALOG_PREVIEW_SIZE = 10;
|
|||
const CATALOG_PAGE_SIZE = 100;
|
||||
const NONE_EXTRA_VALUE = 'None';
|
||||
const SKIP_EXTRA_NAME = 'skip';
|
||||
const TYPE_PRIORITIES = {
|
||||
movie: 10,
|
||||
series: 9,
|
||||
channel: 8,
|
||||
tv: 7,
|
||||
music: 6,
|
||||
radio: 5,
|
||||
podcast: 4,
|
||||
game: 3,
|
||||
book: 2,
|
||||
adult: 1,
|
||||
other: -Infinity
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
SUBTITLES_SIZES,
|
||||
|
|
@ -11,5 +24,6 @@ module.exports = {
|
|||
CATALOG_PREVIEW_SIZE,
|
||||
CATALOG_PAGE_SIZE,
|
||||
NONE_EXTRA_VALUE,
|
||||
SKIP_EXTRA_NAME
|
||||
SKIP_EXTRA_NAME,
|
||||
TYPE_PRIORITIES
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const React = require('react');
|
||||
const { useModelState } = require('stremio/common');
|
||||
const { CONSTANTS, useModelState, comparatorWithPriorities } = require('stremio/common');
|
||||
|
||||
const initLibraryState = () => ({
|
||||
selected: null,
|
||||
|
|
@ -9,7 +9,7 @@ const initLibraryState = () => ({
|
|||
|
||||
const mapLibraryState = (library) => {
|
||||
const selected = library.selected;
|
||||
const type_names = library.type_names;
|
||||
const type_names = library.type_names.sort(comparatorWithPriorities(CONSTANTS.TYPE_PRIORITIES));
|
||||
const lib_items = library.lib_items.map((lib_item) => ({
|
||||
id: lib_item._id,
|
||||
type: lib_item.type,
|
||||
|
|
|
|||
Loading…
Reference in a new issue