mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-05-02 02:22:06 -04:00
Fix VPN UI for active transient entries (#2312)
Co-authored-by: louzt <18044171+louzt@users.noreply.github.com>
This commit is contained in:
@@ -81,7 +81,46 @@ Singleton {
|
||||
property string pendingVpnUuid: ""
|
||||
property var vpnBusyStartTime: 0
|
||||
|
||||
property alias profiles: root.vpnProfiles
|
||||
property var profiles: {
|
||||
const mergedProfiles = vpnProfiles ? vpnProfiles.slice() : [];
|
||||
const seen = new Set();
|
||||
|
||||
for (const profile of mergedProfiles) {
|
||||
if (profile?.uuid)
|
||||
seen.add("uuid:" + profile.uuid);
|
||||
if (profile?.name)
|
||||
seen.add("name:" + profile.name);
|
||||
}
|
||||
|
||||
for (const active of vpnActive || []) {
|
||||
const entryUuid = active?.uuid || active?.name || "";
|
||||
const uuidKey = active?.uuid ? "uuid:" + active.uuid : "";
|
||||
const nameKey = active?.name ? "name:" + active.name : "";
|
||||
|
||||
if ((uuidKey && seen.has(uuidKey)) || (!uuidKey && nameKey && seen.has(nameKey)))
|
||||
continue;
|
||||
|
||||
mergedProfiles.unshift({
|
||||
uuid: entryUuid,
|
||||
name: active?.name || I18n.tr("Active VPN"),
|
||||
serviceType: active?.serviceType || "",
|
||||
type: active?.type || "",
|
||||
typeLabel: active?.typeLabel || active?.vpnType || "",
|
||||
state: active?.state || "",
|
||||
device: active?.device || "",
|
||||
transient: true,
|
||||
canDelete: false,
|
||||
canExpand: false
|
||||
});
|
||||
|
||||
if (uuidKey)
|
||||
seen.add(uuidKey);
|
||||
if (nameKey)
|
||||
seen.add(nameKey);
|
||||
}
|
||||
|
||||
return mergedProfiles;
|
||||
}
|
||||
property alias activeConnections: root.vpnActive
|
||||
property var activeUuids: vpnActive.map(v => v.uuid).filter(u => !!u)
|
||||
property var activeNames: vpnActive.map(v => v.name).filter(n => !!n)
|
||||
|
||||
@@ -216,6 +216,8 @@ Singleton {
|
||||
function getVpnTypeFromProfile(profile) {
|
||||
if (!profile)
|
||||
return "VPN";
|
||||
if (profile.typeLabel)
|
||||
return profile.typeLabel;
|
||||
if (profile.type === "wireguard")
|
||||
return "WireGuard";
|
||||
return getPluginName(profile.serviceType);
|
||||
|
||||
Reference in New Issue
Block a user