Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions src/pages/plugins/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,12 @@ export default function PluginsInclude(updates) {

$page.onclick = handleClick;

$list.all.addEventListener('scroll', (e) => {
$list.all.addEventListener('scroll', async (e) => {
if (isLoading || !hasMore) return;

const { scrollTop, scrollHeight, clientHeight } = $currList;
const { scrollTop, scrollHeight, clientHeight } = e.target;
if (scrollTop + clientHeight >= scrollHeight - 100) {
if (currSection === "all") {
currentPage++;
getAllPlugins();
}
await getAllPlugins();
}
})

Expand Down Expand Up @@ -225,8 +222,13 @@ export default function PluginsInclude(updates) {
$section.scrollTop = $section._scroll || 0;
$currList = $section;
currSection = section;
currentPage = 1;
hasMore = true;
if (section === "all") {
currentPage = 1;
hasMore = true;
isLoading = false;
$list.all.replaceChildren();
getAllPlugins();
}
$page.get(".options .active").classList.remove("active");
$page.get(`#${section}_plugins`).classList.add("active");
}
Expand Down Expand Up @@ -284,35 +286,30 @@ export default function PluginsInclude(updates) {

try {
isLoading = true;
if (currentPage === 1) {
plugins.all = [];
$list.all.replaceChildren();
}

$list.all.setAttribute("empty-msg", strings["loading..."]);

const installed = await fsOperation(PLUGIN_DIR).lsDir();
const response = await fetch(`${constants.API_BASE}/plugins?page=${currentPage}&limit=${LIMIT}`);
const newPlugins = await response.json();

if (newPlugins.length < LIMIT) {
hasMore = false;
}

plugins.all = [...plugins.all, ...newPlugins];

const installed = await fsOperation(PLUGIN_DIR).lsDir();
installed.forEach(({ url }) => {
const plugin = plugins.all.find(({ id }) => id === Url.basename(url));
const plugin = newPlugins.find(({ id }) => id === Url.basename(url));
if (plugin) {
plugin.installed = true;
plugin.localPlugin = getLocalRes(plugin.id, "plugin.json");
}
});

plugins.all.forEach((plugin) => {
newPlugins.forEach((plugin) => {
$list.all.append(<Item {...plugin} />);
});

currentPage++;
$list.all.setAttribute("empty-msg", strings["no plugins found"]);
} catch (error) {
window.log("error", error);
Expand Down
10 changes: 5 additions & 5 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@

<title>Acode</title>
<!--styles-->
<link rel="stylesheet" href="./css/build/100.css">
<link rel="stylesheet" href="./css/build/138.css">
<link rel="stylesheet" href="./css/build/543.css">
<link rel="stylesheet" href="./css/build/879.css">
<link rel="stylesheet" href="./css/build/922.css">
<link rel="stylesheet" href="./css/build/218.css">
<link rel="stylesheet" href="./css/build/32.css">
<link rel="stylesheet" href="./css/build/383.css">
<link rel="stylesheet" href="./css/build/53.css">
<link rel="stylesheet" href="./css/build/609.css">
<link rel="stylesheet" href="./css/build/about.css">
<link rel="stylesheet" href="./css/build/customTheme.css">
<link rel="stylesheet" href="./css/build/donate.css">
Expand Down