Auto-close the tab where session is done

This commit is contained in:
PaperCube
2024-02-16 12:38:14 +00:00
parent c360dd7f84
commit b34b504bf3
3 changed files with 13 additions and 2 deletions

View File

@@ -206,7 +206,7 @@ class _ServerPageState extends State<ServerPage>
late final List<Widget> children; late final List<Widget> children;
if (srv.state == ServerState.finished) { if (srv.state == ServerState.finished) {
if (cardStatus.value.flip) { if (cardStatus.value.flip) {
children = [title, ..._buildFlipedCard(srv)]; children = [title, ..._buildFlippedCard(srv)];
} else { } else {
children = [title, ..._buildNormalCard(srv.status, srv.spi)]; children = [title, ..._buildNormalCard(srv.status, srv.spi)];
} }
@@ -228,7 +228,7 @@ class _ServerPageState extends State<ServerPage>
); );
} }
List<Widget> _buildFlipedCard(Server srv) { List<Widget> _buildFlippedCard(Server srv) {
return [ return [
UIs.height13, UIs.height13,
Row( Row(

View File

@@ -33,11 +33,14 @@ class SSHPage extends StatefulWidget {
final ServerPrivateInfo spi; final ServerPrivateInfo spi;
final String? initCmd; final String? initCmd;
final bool pop; final bool pop;
final Function()? onSessionEnd;
const SSHPage({ const SSHPage({
super.key, super.key,
required this.spi, required this.spi,
this.initCmd, this.initCmd,
this.pop = true, this.pop = true,
this.onSessionEnd,
}); });
@override @override
@@ -381,6 +384,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
if (mounted && widget.pop) { if (mounted && widget.pop) {
context.pop(); context.pop();
} }
widget.onSessionEnd?.call();
} }
void _listen(Stream<Uint8List>? stream) { void _listen(Stream<Uint8List>? stream) {

View File

@@ -71,6 +71,7 @@ class _SSHTabPageState extends State<SSHTabPage>
if (confirm != true) { if (confirm != true) {
return; return;
} }
// debugPrint("Removing a tab whose tabId = $e");
_tabIds.remove(e); _tabIds.remove(e);
_refreshTabs(); _refreshTabs();
}, },
@@ -104,6 +105,12 @@ class _SSHTabPageState extends State<SSHTabPage>
key: key, key: key,
spi: spi, spi: spi,
pop: false, pop: false,
onSessionEnd: () {
// debugPrint("Session done received on page whose tabId = $name");
// debugPrint("key = $key");
_tabIds.remove(name);
_refreshTabs();
},
); );
_refreshTabs(); _refreshTabs();
_tabController.animateTo(_tabIds.length - 1); _tabController.animateTo(_tabIds.length - 1);