mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-02 16:08:31 +00:00
Fixed: Add pagination support to the emote menu's data loader (#507)
* Fix emote menu not loading more than 100 subscription benefits * Implement @last support in .get Modify `curr_cursor` to use the new get @last modifier
This commit is contained in:
parent
db2c7918d5
commit
6518c8e7a4
2 changed files with 14 additions and 3 deletions
|
@ -1535,7 +1535,7 @@ export default class EmoteMenu extends Module {
|
|||
}
|
||||
|
||||
|
||||
async getData(sets, force) {
|
||||
async getData(sets, force, cursor = null, nodes = []) {
|
||||
if ( this._data ) {
|
||||
if ( ! force && set_equals(sets, this._data_sets) )
|
||||
return this._data;
|
||||
|
@ -1551,6 +1551,7 @@ export default class EmoteMenu extends Module {
|
|||
query: SUB_STATUS,
|
||||
variables: {
|
||||
first: 100,
|
||||
after: cursor,
|
||||
criteria: {
|
||||
filter: 'ALL'
|
||||
}
|
||||
|
@ -1564,7 +1565,15 @@ export default class EmoteMenu extends Module {
|
|||
}
|
||||
|
||||
const out = {},
|
||||
nodes = get('data.currentUser.subscriptionBenefits.edges.@each.node', data);
|
||||
curr_nodes = get('data.currentUser.subscriptionBenefits.edges.@each.node', data),
|
||||
has_next_page = get('data.currentUser.subscriptionBenefits.pageInfo.hasNextPage', data),
|
||||
curr_cursor = get('data.currentUser.subscriptionBenefits.edges.@last.cursor', data);
|
||||
|
||||
nodes = nodes.concat(curr_nodes);
|
||||
|
||||
if (has_next_page) {
|
||||
return this.getData(sets, force, curr_cursor, nodes);
|
||||
}
|
||||
|
||||
if ( nodes && nodes.length )
|
||||
for(const node of nodes) {
|
||||
|
|
|
@ -201,7 +201,9 @@ export function get(path, object) {
|
|||
|
||||
break;
|
||||
|
||||
} else
|
||||
} else if ( part === '@last' )
|
||||
object = object[object.length - 1];
|
||||
else
|
||||
object = object[path[i]];
|
||||
|
||||
if ( ! object )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue