Skip to content

Commit

Permalink
Hide connections page by default since unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Sep 13, 2024
1 parent ef2bae5 commit ae0f6bc
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public struct ConnectionListView: View {
@State private var isLoading = true
@StateObject private var commandClient = CommandClient(.connections)
@State private var connections: [Connection] = []
@State private var selection: ConnectionListPage = .active
@State private var searchText = ""
@State private var alert: Alert?

Expand Down
4 changes: 2 additions & 2 deletions ApplicationLibrary/Views/Connections/ConnectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public struct ConnectionView: View {
Spacer()
VStack(alignment: .trailing) {
Text(connection.inboundType + "/" + connection.inbound)
Text(connection.chain.reversed().joined(separator: "/"))
Text(connection.chain[0])
}
}
}
Expand Down Expand Up @@ -111,7 +111,7 @@ public struct ConnectionView: View {

private nonisolated func closeConnection() async {
do {
try LibboxNewStandaloneCommandClient()!.closeConnection(connection.id)
try await LibboxNewStandaloneCommandClient()!.closeConnection(connection.id)
} catch {
await MainActor.run {
alert = Alert(error)
Expand Down
4 changes: 2 additions & 2 deletions ApplicationLibrary/Views/Dashboard/ActiveDashboardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public struct ActiveDashboardView: View {
#if os(iOS) || os(tvOS)
if ApplicationLibrary.inPreview || profile.status.isConnectedStrict {
Picker("Page", selection: $selection) {
ForEach(DashboardPage.allCases) { page in
ForEach(DashboardPage.enabledCases()) { page in
page.label
}
}
Expand All @@ -61,7 +61,7 @@ public struct ActiveDashboardView: View {
.navigationBarTitleDisplayMode(.inline)
#endif
TabView(selection: $selection) {
ForEach(DashboardPage.enabledCases) { page in
ForEach(DashboardPage.enabledCases()) { page in
page.contentView($profileList, $selectedProfileID, $systemProxyAvailable, $systemProxyEnabled)
.tag(page)
}
Expand Down
18 changes: 9 additions & 9 deletions ApplicationLibrary/Views/Dashboard/DashboardPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ public enum DashboardPage: Int, CaseIterable, Identifiable {
}

public extension DashboardPage {
#if !tvOS
static var enabledCases: [DashboardPage] = [
static func enabledCases() -> [DashboardPage] {
var cases: [DashboardPage] = [
.overview,
.groups,
.connections,
]
#else
static var enabledCases: [DashboardPage] = [
.overview,
.groups,
]
#endif
#if !tvOS
if Variant.isBeta {
cases.append(.connections)
}
#endif
return cases
}
}

public extension DashboardPage {
Expand Down
5 changes: 2 additions & 3 deletions ApplicationLibrary/Views/Profile/ImportProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@
private func reset() {
selected = false
profiles = nil
if let connection = connection {
if let connection {
connection.cancel()
self.connection = nil

}
}

Expand All @@ -87,7 +86,7 @@
self.connection = NWSocket(connection)
connection.stateUpdateHandler = { state in
switch state {
case .failed(let error):
case let .failed(error):
DispatchQueue.main.async { [self] in
reset()
alert = Alert(error)
Expand Down
2 changes: 1 addition & 1 deletion Library/Network/CommandClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class CommandClient: ObservableObject {
@Published public var clashModeList: [String]
@Published public var clashMode: String

@Published public var connectionStateFilter = ConnectionStateFilter.all
@Published public var connectionStateFilter = ConnectionStateFilter.active
@Published public var connectionSort = ConnectionSort.byDate
@Published public var connections: [LibboxConnection]?
public var rawConnections: LibboxConnections?
Expand Down
3 changes: 3 additions & 0 deletions Library/Shared/Variant.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import Libbox

public enum Variant {
#if os(macOS)
Expand All @@ -14,4 +15,6 @@ public enum Variant {
#elseif os(tvOS)
public static let applicationName = "SFT"
#endif

public static var isBeta = LibboxVersion().contains("-")
}
4 changes: 3 additions & 1 deletion MacLibrary/SidebarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public struct SidebarView: View {
.tint(.textColor)
.tag(NavigationPage.dashboard)
NavigationPage.groups.label.tag(NavigationPage.groups)
NavigationPage.connections.label.tag(NavigationPage.connections)
if Variant.isBeta {
NavigationPage.connections.label.tag(NavigationPage.connections)
}
}
Divider()
ForEach(NavigationPage.macosDefaultPages, id: \.self) { it in
Expand Down
2 changes: 1 addition & 1 deletion SFM.System/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI

@main
struct Application: App {
@NSApplicationDelegateAdaptor private var appDelegate: IndependentApplicationDelegate
@NSApplicationDelegateAdaptor private var appDelegate: StandaloneApplicationDelegate

var body: some Scene {
MacApplication()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import Foundation
import Library
import MacLibrary

class IndependentApplicationDelegate: ApplicationDelegate {
class StandaloneApplicationDelegate: ApplicationDelegate {
public func applicationWillFinishLaunching(_: Notification) {
Variant.useSystemExtension = true
Variant.isBeta = false
Task {
await setupSystemExtension()
}
Expand Down
8 changes: 4 additions & 4 deletions sing-box.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
3A251C122A52D09700651082 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3AAB5E7A2A4C1446009757F1 /* Assets.xcassets */; };
3A27D9002A89BE230031EBCC /* CommandClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A27D8FF2A89BE230031EBCC /* CommandClient.swift */; };
3A27D9022A89C6870031EBCC /* ExtensionEnvironments.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A27D9012A89C6870031EBCC /* ExtensionEnvironments.swift */; };
3A2EAEED2A6F4CBB00D00DE3 /* IndependentApplicationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A2EAEEC2A6F4CBB00D00DE3 /* IndependentApplicationDelegate.swift */; };
3A2EAEED2A6F4CBB00D00DE3 /* StandaloneApplicationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A2EAEEC2A6F4CBB00D00DE3 /* StandaloneApplicationDelegate.swift */; };
3A334ED02C0F621E00E9C577 /* ConnectionDetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A334ECF2C0F621E00E9C577 /* ConnectionDetailsView.swift */; };
3A3AA7FC2A4EFDAE002F78AB /* Library.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AEC211D2A459B4700A63465 /* Library.framework */; };
3A3AA7FF2A4EFDB3002F78AB /* Library.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AEC211D2A459B4700A63465 /* Library.framework */; };
Expand Down Expand Up @@ -480,7 +480,7 @@
3A2223592A6E212A00C50B23 /* SystemExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemExtension.swift; sourceTree = "<group>"; };
3A27D8FF2A89BE230031EBCC /* CommandClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommandClient.swift; sourceTree = "<group>"; };
3A27D9012A89C6870031EBCC /* ExtensionEnvironments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionEnvironments.swift; sourceTree = "<group>"; };
3A2EAEEC2A6F4CBB00D00DE3 /* IndependentApplicationDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IndependentApplicationDelegate.swift; sourceTree = "<group>"; };
3A2EAEEC2A6F4CBB00D00DE3 /* StandaloneApplicationDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandaloneApplicationDelegate.swift; sourceTree = "<group>"; };
3A334ECF2C0F621E00E9C577 /* ConnectionDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionDetailsView.swift; sourceTree = "<group>"; };
3A3AB2A62B70C146001815AE /* CoreView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreView.swift; sourceTree = "<group>"; };
3A3AB2A82B70C5F1001815AE /* RequestReviewButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestReviewButton.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1048,7 +1048,7 @@
3AEECC062A6DF9CA006A0E0C /* Application.swift */,
3AEECC502A6E0074006A0E0C /* SFM.entitlements */,
3A2223532A6E1B6700C50B23 /* Info.plist */,
3A2EAEEC2A6F4CBB00D00DE3 /* IndependentApplicationDelegate.swift */,
3A2EAEEC2A6F4CBB00D00DE3 /* StandaloneApplicationDelegate.swift */,
3AABFD462A9CCC58005A24A4 /* Upload.plist */,
);
path = SFM.System;
Expand Down Expand Up @@ -1732,7 +1732,7 @@
buildActionMask = 2147483647;
files = (
3AEECC072A6DF9CA006A0E0C /* Application.swift in Sources */,
3A2EAEED2A6F4CBB00D00DE3 /* IndependentApplicationDelegate.swift in Sources */,
3A2EAEED2A6F4CBB00D00DE3 /* StandaloneApplicationDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

0 comments on commit ae0f6bc

Please sign in to comment.