support sort layout

pull/358/head
GodD6366 2 years ago committed by Michael Shamoon
parent 672fc3716a
commit 82c69ff68d

@ -177,6 +177,21 @@ function Home({ initialSettings }) {
const servicesAndBookmarks = [...services.map(sg => sg.services).flat(), ...bookmarks.map(bg => bg.bookmarks).flat()]
// sort layout
const layouts = Object.keys(initialSettings.layout);
let sortedServices = [];
const copiedServices = services.slice();
layouts.forEach((currentServer) => {
if (initialSettings.layout[currentServer]?.sort) {
const idx = copiedServices.findIndex((service) => service.name === currentServer);
sortedServices.push(...copiedServices.splice(idx, 1));
}
});
if (copiedServices.length) {
sortedServices = sortedServices.concat(copiedServices);
}
useEffect(() => {
if (settings.language) {
i18n.changeLanguage(settings.language);
@ -263,9 +278,9 @@ function Home({ initialSettings }) {
)}
</div>
{services && (
{sortedServices && (
<div className="flex flex-wrap p-4 sm:p-8 sm:pt-4 items-start pb-2">
{services.map((group) => (
{sortedServices.map((group) => (
<ServicesGroup key={group.name} services={group} layout={initialSettings.layout?.[group.name]} />
))}
</div>

Loading…
Cancel
Save