fix: search continuations should return a Search class

Why? To keep things consistent.
This commit is contained in:
LuanRT
2022-06-18 05:16:21 -03:00
parent 1d2c1ed69b
commit 4c7a42d8d4
9 changed files with 244 additions and 220 deletions

View File

@@ -29,8 +29,8 @@ class History {
this.feed_actions = secondary_contents?.contents || null;
this.sections = observe(contents.map((section) => ({
title: section.header.title,
items: section.contents
header: section.header,
contents: section.contents
})));
}

View File

@@ -26,9 +26,9 @@ class Library {
this.profile = { stats, user_info };
this.sections = observe(shelves.map((shelf) => ({
title: shelf.title.toString(),
items: shelf.content.items,
type: shelf.icon_type,
title: shelf.title.toString(),
contents: shelf.content.items,
getAll: () => this.#getAll(shelf)
})));
}

View File

@@ -41,11 +41,11 @@ class Search extends Feed {
header: card_list?.header || null,
/** @type {import('../contents/classes/SearchRefinementCard')} */
cards: card_list?.cards || []
};
}
}
/**
* Applies given refinement card and returns a new {@link Feed} object.
* Applies given refinement card and returns a new {@link Search} object.
*
* @param {import('../contents/classes/SearchRefinementCard') | string} card - refinement card object or query
* @returns {Promise.<Feed>}
@@ -66,13 +66,23 @@ class Search extends Feed {
}
const page = await target_card.endpoint.call(this.actions);
return new Feed(this.actions, page, true);
return new Search(this.actions, page, true);
}
/** @type {string[]} */
get refinement_card_queries() {
return this.refinement_cards.cards.map((card) => card.query);
}
/**
* Retrieves next batch of results.
*
* @returns {Promise.<Search>}
*/
async getContinuation() {
const continuation = await this.getContinuationData();
return new Search(this.actions, continuation, true);
}
}
module.exports = Search;