Skip to content
This repository was archived by the owner on Jul 18, 2023. It is now read-only.

Commit 4960c4a

Browse files
Merge pull request #686 from imaperson1060/main
feat: add pagination for app version
2 parents f55f4f0 + 06873cd commit 4960c4a

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

public/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ function setAppVersion(arch, version) {
162162
/**
163163
* @param {boolean} isRooted
164164
*/
165-
function getAppVersions(isRooted) {
165+
function getAppVersions(isRooted, page = 1) {
166166
document.getElementsByTagName('header')[0].innerHTML = `
167167
<h1><i class="fa-solid fa-file-arrow-down"></i>Select the version you want to download</h1>
168168
<span>Versions marked as beta might have bugs or can be unstable, unless marked as recommended<span>
@@ -181,7 +181,9 @@ function getAppVersions(isRooted) {
181181
backButton.innerHTML = 'Back';
182182
backButton.onclick = () => history.back();
183183

184-
sendCommand({ event: 'getAppVersion', checkVer: true });
184+
if (page < 1) page = 1;
185+
186+
sendCommand({ event: 'getAppVersion', checkVer: true, page });
185187
}
186188

187189
function buildReVanced() {
@@ -370,6 +372,13 @@ ws.onmessage = (msg) => {
370372
const len = message.versionList.length;
371373

372374
const versionsElement = document.getElementById('versions');
375+
versionsElement.innerHTML = '';
376+
377+
versionsElement.innerHTML += `
378+
<li>
379+
${message.page != 1 ? `<button id="prevPage" onclick="getAppVersions(${message.isRooted}, ${message.page - 1})">Previous Page</button>` : ""}
380+
<button id="nextPage" onclick="getAppVersions(${message.isRooted}, ${message.page + 1})">Next Page</button>
381+
</li>`;
373382

374383
for (let i = 0; i < len; i++) {
375384
const version = message.versionList[i];

wsEvents/getAppVersion.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const { getAppVersion: getAppVersion_ } = require('../utils/getAppVersion.js');
99
const { downloadApp: downloadApp_ } = require('../utils/downloadApp.js');
1010
const getDeviceArch = require('../utils/getDeviceArch.js');
1111

12-
const APKMIRROR_UPLOAD_BASE = 'https://www.apkmirror.com/uploads/?appcategory=';
12+
const APKMIRROR_UPLOAD_BASE = (page) => `https://www.apkmirror.com/uploads/page/${page}/?appcategory=`;
1313

1414
/**
1515
* @param {string} ver
@@ -124,7 +124,7 @@ async function downloadApp(ws, message) {
124124
*/
125125
module.exports = async function getAppVersion(ws, message) {
126126
let versionsList = await getPage(
127-
`${APKMIRROR_UPLOAD_BASE}${global.jarNames.selectedApp.link.split('/')[3]}`
127+
`${APKMIRROR_UPLOAD_BASE(message.page || 1)}${global.jarNames.selectedApp.link.split('/')[3]}`
128128
);
129129

130130
if (global.jarNames.isRooted) {
@@ -229,11 +229,13 @@ module.exports = async function getAppVersion(ws, message) {
229229
JSON.stringify({
230230
event: 'appVersions',
231231
versionList,
232+
page: message.page || 1,
232233
selectedApp: global.jarNames.selectedApp.packageName,
233234
foundDevice:
234235
global.jarNames.devices && global.jarNames.devices[0]
235236
? true
236-
: process.platform === 'android'
237+
: process.platform === 'android',
238+
isRooted: global.jarNames.isRooted
237239
})
238240
);
239241
};

0 commit comments

Comments
 (0)