fix: match the web's dev-server filtering on the phone
The web's "running dev servers" list shows ports that belong to a known project (the current one included) or arrive without a directory; ports started outside every project sit behind "show hidden ports". 0.7.2 listed every port that answered with a page, which showed more servers on the phone than in the web. The phone now applies the same known-project filter, so the telegram server on 8080 and the directory-less 9090 both appear. Version 0.7.3+703.
This commit is contained in:
1 parent
b372bce63f
commit
4bd9256ef8
4 files changed
+33
-7
No files matched your search
@@ -181,13 +181,30 @@ class _BrowserPanelState extends State<BrowserPanel> {
|
||||
try {
|
||||
final list = await cl.devServers(directory: widget.directory);
|
||||
if (!mounted) return;
|
||||
// The web client's "running dev servers" list is machine-wide, not
|
||||
// scoped to the open project, so show the same set here. Only ports
|
||||
// that answered with a page (the web client hides the rest behind
|
||||
// "show hidden ports") are listed.
|
||||
// Match the web client's "running dev servers": a port that answered
|
||||
// with a page is listed when it belongs to a known project (or carries
|
||||
// no directory, which is how announced servers arrive). Ports started
|
||||
// outside every project stay behind the web client's "show hidden
|
||||
// ports" too.
|
||||
final known = <String>[
|
||||
if (widget.directory.isNotEmpty) widget.directory,
|
||||
for (final project in widget.app.projects)
|
||||
if (project.canonical.isNotEmpty) project.canonical,
|
||||
];
|
||||
bool knownDirectory(String directory) {
|
||||
if (directory.isEmpty || known.isEmpty) return true;
|
||||
for (final root in known) {
|
||||
if (samePath(root, directory) || isUnderDirectory(directory, root)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
final filtered = [
|
||||
for (final server in list)
|
||||
if (server.title.isNotEmpty) server,
|
||||
if (server.title.isNotEmpty && knownDirectory(server.directory))
|
||||
server,
|
||||
]..sort((a, b) => a.port.compareTo(b.port));
|
||||
setState(() {
|
||||
_servers = filtered;
|
||||
|
||||
Reference in new issue
Block a user