mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-06 22:30:57 +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 ( this._data ) {
|
||||||
if ( ! force && set_equals(sets, this._data_sets) )
|
if ( ! force && set_equals(sets, this._data_sets) )
|
||||||
return this._data;
|
return this._data;
|
||||||
|
@ -1551,6 +1551,7 @@ export default class EmoteMenu extends Module {
|
||||||
query: SUB_STATUS,
|
query: SUB_STATUS,
|
||||||
variables: {
|
variables: {
|
||||||
first: 100,
|
first: 100,
|
||||||
|
after: cursor,
|
||||||
criteria: {
|
criteria: {
|
||||||
filter: 'ALL'
|
filter: 'ALL'
|
||||||
}
|
}
|
||||||
|
@ -1564,7 +1565,15 @@ export default class EmoteMenu extends Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
const out = {},
|
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 )
|
if ( nodes && nodes.length )
|
||||||
for(const node of nodes) {
|
for(const node of nodes) {
|
||||||
|
|
|
@ -201,7 +201,9 @@ export function get(path, object) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} else
|
} else if ( part === '@last' )
|
||||||
|
object = object[object.length - 1];
|
||||||
|
else
|
||||||
object = object[path[i]];
|
object = object[path[i]];
|
||||||
|
|
||||||
if ( ! object )
|
if ( ! object )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue