addon first result in streamscreen

This commit is contained in:
tapframe 2025-12-27 19:15:10 +05:30
parent aed4fed56f
commit 7a5ecd3009
2 changed files with 22 additions and 5 deletions

1
mpvKt Submodule

@ -0,0 +1 @@
Subproject commit 01a93062dd73f642cbb0511f6a05f1fd344b36a9

View file

@ -799,12 +799,28 @@ export const useStreamsScreen = () => {
return addonId === selectedProvider;
});
// Sort entries: installed addons first (in their installation order), then plugins
const sortedEntries = filteredEntries.sort(([addonIdA], [addonIdB]) => {
const indexA = addonResponseOrder.indexOf(addonIdA);
const indexB = addonResponseOrder.indexOf(addonIdB);
if (indexA !== -1 && indexB !== -1) return indexA - indexB;
if (indexA !== -1) return -1;
if (indexB !== -1) return 1;
const isAddonA = installedAddons.some(addon => addon.id === addonIdA);
const isAddonB = installedAddons.some(addon => addon.id === addonIdB);
// Addons always come before plugins
if (isAddonA && !isAddonB) return -1;
if (!isAddonA && isAddonB) return 1;
// Both are addons - sort by installation order
if (isAddonA && isAddonB) {
const indexA = installedAddons.findIndex(addon => addon.id === addonIdA);
const indexB = installedAddons.findIndex(addon => addon.id === addonIdB);
return indexA - indexB;
}
// Both are plugins - sort by response order
const responseIndexA = addonResponseOrder.indexOf(addonIdA);
const responseIndexB = addonResponseOrder.indexOf(addonIdB);
if (responseIndexA !== -1 && responseIndexB !== -1) return responseIndexA - responseIndexB;
if (responseIndexA !== -1) return -1;
if (responseIndexB !== -1) return 1;
return 0;
});