Rework supportsSession

This commit is contained in:
crschnick
2025-10-20 04:57:09 +00:00
parent 3a844ecc38
commit adac987b2a
4 changed files with 17 additions and 18 deletions

View File

@@ -8,10 +8,6 @@ public interface SingletonSessionStore<T extends Session>
stopSessionIfNeeded();
}
default boolean supportsSession() {
return true;
}
default boolean isSessionRunning() {
return getCache("sessionRunning", Boolean.class, false);
}

View File

@@ -33,7 +33,7 @@ public interface SingletonSessionStoreProvider extends DataStoreProvider {
return new SystemStateComp(Bindings.createObjectBinding(
() -> {
SingletonSessionStore<?> s = w.getEntry().getStore().asNeeded();
if (!s.supportsSession()) {
if (!supportsSession(s)) {
return SystemStateComp.State.SUCCESS;
}
@@ -80,7 +80,7 @@ public interface SingletonSessionStoreProvider extends DataStoreProvider {
t.setCustomVisibility(Bindings.createBooleanBinding(
() -> {
SingletonSessionStore<?> s = sec.getWrapper().getEntry().getStore().asNeeded();
return s.supportsSession() && (showToggleWhenInactive(sec.getWrapper().getStore().getValue()) || s.isSessionEnabled());
return supportsSession(s) && (showToggleWhenInactive(s) || s.isSessionEnabled());
},
sec.getWrapper().getCache()));
@@ -88,7 +88,11 @@ public interface SingletonSessionStoreProvider extends DataStoreProvider {
return t;
}
default boolean showToggleWhenInactive(DataStore store) {
default boolean showToggleWhenInactive(SingletonSessionStore<?> store) {
return true;
}
default boolean supportsSession(SingletonSessionStore<?> store) {
return true;
}
}

View File

@@ -31,12 +31,6 @@ public abstract class AbstractServiceStore implements SingletonSessionStore<Netw
return true;
}
@Override
public boolean supportsSession() {
return getHost() == null
|| !getHost().getStore().requiresTunnel()
|| !getHost().getStore().isLocallyTunnelable();
}
@Override
public void checkComplete() throws Throwable {

View File

@@ -2,10 +2,7 @@ package io.xpipe.ext.base.service;
import io.xpipe.app.comp.Comp;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.ext.DataStore;
import io.xpipe.app.ext.DataStoreProvider;
import io.xpipe.app.ext.DataStoreUsageCategory;
import io.xpipe.app.ext.SingletonSessionStoreProvider;
import io.xpipe.app.ext.*;
import io.xpipe.app.hub.comp.*;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntry;
@@ -30,6 +27,14 @@ public abstract class AbstractServiceStoreProvider implements SingletonSessionSt
return DocumentationLink.SERVICES;
}
@Override
public boolean supportsSession(SingletonSessionStore<?> s) {
var abs = (AbstractServiceStore) s;
return abs.getHost() == null
|| !abs.getHost().getStore().requiresTunnel()
|| !abs.getHost().getStore().isLocallyTunnelable();
}
@Override
public FailableRunnable<Exception> launch(DataStoreEntry store) {
return () -> {
@@ -96,7 +101,7 @@ public abstract class AbstractServiceStoreProvider implements SingletonSessionSt
}
@Override
public boolean showToggleWhenInactive(DataStore store) {
public boolean showToggleWhenInactive(SingletonSessionStore<?> store) {
return false;
}