- commit
- 6fce4247499b1c229b04a4a3a0154f6cf2463a68
- parent
- 5e87779a7fc04498c675a0e298cc2f066506b52b
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2023-12-21 11:42
js: actually use response.next
Diffstat
| M | plutopluto/static/plutopluto.js | 17 | +++++++++++------ |
1 files changed, 11 insertions, 6 deletions
diff --git a/plutopluto/static/plutopluto.js b/plutopluto/static/plutopluto.js
@@ -79,6 +79,7 @@ var getConfig = function() {
79 79 getConfig().then(config => {
80 80 var entries = [];
81 81 var page = 0;
-1 82 var next = config.urls;
82 83
83 84 var loadNextPageLock = false;
84 85 var loadNextPage = function() {
@@ -88,14 +89,18 @@ getConfig().then(config => {
88 89
89 90 loadNextPageLock = true;
90 91
91 -1 var promises = config.urls.map(url => {
92 -1 if (url.includes('{page}')) {
93 -1 url = url.replace('{page}', page);
94 -1 } else if (page !== 0) {
95 -1 return;
96 -1 }
-1 92 var current = next;
-1 93 next = [];
-1 94
-1 95 var promises = current.map(raw => {
-1 96 var url = raw.replace('{page}', page);
97 97
98 98 return fetchJSON('/parse?' + new URLSearchParams({url: url})).then(data => {
-1 99 if (data.next) {
-1 100 next.push(data.next);
-1 101 } else if (raw.includes('{page}')) {
-1 102 next.push(raw);
-1 103 }
99 104 entries = entries.concat(data.entries);
100 105 });
101 106 });