minetest-world / mtlauncher

GNU Lesser General Public License v2.1
5 stars 3 forks source link

more comprehensive server filtering (by game, mods, etc) #3

Open recluse4615 opened 1 year ago

recluse4615 commented 1 year ago

i would like to decouple some of the ServerListTable.svelte logic in to something less behemoth-y, which would serve a few benefits on paper:

would be a fun mini-project, but also requires some indexing of available games/mods from contentdb and i don't want the servers page to load unnecessary things if i can avoid it

Miniontoby commented 1 year ago

Also by address:port would be nice. And just to be able to put in an address:port, cause some server won't want or can't announce to server list

recluse4615 commented 1 year ago

being able to search by address:port is easy enough, we can just throw it in to one of svelte-headless-table's columns like:

plugins: {
    filter: {
        getFilterValue: (i) => `${i.name} ${i.fullAddress}`
    }
}

however needs some bigger refactoring of the server tables still

recluse4615 commented 1 year ago

tl;dr - $lib/api/servers.js should expose 2 (or more...) stores: a writable filters store (potentially) a derived favourites store (since those are stored under $lib/preferences.js) a writable servers store, and a derived servers store $lib/api/servers.js:getServers(force = false) should now return the derived servers store, instead filters can then potentially be added like so:

import { getServers, setServerFilters } from '$lib/api/servers';

setServerFilters([
    i => i.gameid === 'minetest_game'
]); // example

and then src/routes/servers/+page.svelte should always reset the server filters on mount

we will probably also want a separate getServerList function that just returns the writable servers store

the difference between the writable servers store and the derived servers store is that the writable one is the "base" or "source of truth", whereas the derived one is the result of performing all the filters