diff --git a/Core/Server/Sources/Server/Routes/HandleMock.swift b/Core/Server/Sources/Server/Routes/HandleMock.swift index 4f2aab021b..14ca8c0a62 100644 --- a/Core/Server/Sources/Server/Routes/HandleMock.swift +++ b/Core/Server/Sources/Server/Routes/HandleMock.swift @@ -7,7 +7,7 @@ import FlyingFox import Foundation -@preconcurrency import CommonKit +import CommonKit public protocol ServerMockHandlerInterface { func handle(url: URL, method: String, headers: [String: String], body: Data?, rawFlags: [String: String]) async throws -> (status: Int, body: Data, headers: [String: String]) diff --git a/Core/Server/Sources/Server/Routes/HandleScenario.swift b/Core/Server/Sources/Server/Routes/HandleScenario.swift index baea763871..ec1f837c85 100644 --- a/Core/Server/Sources/Server/Routes/HandleScenario.swift +++ b/Core/Server/Sources/Server/Routes/HandleScenario.swift @@ -7,7 +7,7 @@ import FlyingFox import Foundation -@preconcurrency import CommonKit +import CommonKit public protocol ScenarioHandlerInterface { func addScenario(scenario: ScenarioModel) async throws diff --git a/Core/Server/Sources/Server/Routes/HandleSearchMock.swift b/Core/Server/Sources/Server/Routes/HandleSearchMock.swift index 38377d7848..fb7ab8fedb 100644 --- a/Core/Server/Sources/Server/Routes/HandleSearchMock.swift +++ b/Core/Server/Sources/Server/Routes/HandleSearchMock.swift @@ -7,7 +7,7 @@ import FlyingFox import Foundation -@preconcurrency import CommonKit +import CommonKit public protocol ServerMockSearchHandlerInterface { /// The `search` function makes an HTTP request with the specified parameters, using mock data or fetching data from a real server. diff --git a/MockingStar/MockingStar/Localizable.xcstrings b/MockingStar/MockingStar/Localizable.xcstrings index c36329c94e..73991447dd 100644 --- a/MockingStar/MockingStar/Localizable.xcstrings +++ b/MockingStar/MockingStar/Localizable.xcstrings @@ -33,6 +33,9 @@ }, "For your privacy" : { + }, + "If you change server port, please restart application." : { + }, "Menubar Actions" : { diff --git a/MockingStar/MockingStar/Modules/Home/AppNavigationSplitView.swift b/MockingStar/MockingStar/Modules/Home/AppNavigationSplitView.swift index 2dc1ca841e..48f1fd6900 100644 --- a/MockingStar/MockingStar/Modules/Home/AppNavigationSplitView.swift +++ b/MockingStar/MockingStar/Modules/Home/AppNavigationSplitView.swift @@ -17,18 +17,12 @@ import SwiftUI struct AppNavigationSplitView: View { @State private var initializeAppOnboardingDone: Bool = false - @State private var lastMockFolderFilePath: String = "" @Bindable private var navigationStore = NavigationStore.shared @SceneStorage("mockDomain") var mockDomain: String = "" @AppStorage("isOnboardingDone") private var isOnboardingDone: Bool = false @UserDefaultStorage("mockFolderFilePath") var mockFolderFilePath: String = "/MockServer" private let mockListViewModel = MockListViewModel() - init() { - lastMockFolderFilePath = mockFolderFilePath - listenMockFolderPathChanges() - } - var body: some View { Group { if initializeAppOnboardingDone && isOnboardingDone { @@ -68,15 +62,11 @@ struct AppNavigationSplitView: View { } } } - .task(id: lastMockFolderFilePath, priority: .userInitiated) { - initializeAppOnboardingDone = false - } .overlay { NotificationView() } - } - - func listenMockFolderPathChanges() { - _mockFolderFilePath.onChange { path in - lastMockFolderFilePath = path + .onAppear { + _mockFolderFilePath.onChange { path in + initializeAppOnboardingDone = false + } } } } diff --git a/MockingStar/MockingStar/Modules/Home/SideBarServerView/SideBarServerViewModel.swift b/MockingStar/MockingStar/Modules/Home/SideBarServerView/SideBarServerViewModel.swift index ad9d2047fd..e01e629267 100644 --- a/MockingStar/MockingStar/Modules/Home/SideBarServerView/SideBarServerViewModel.swift +++ b/MockingStar/MockingStar/Modules/Home/SideBarServerView/SideBarServerViewModel.swift @@ -5,9 +5,10 @@ // Created by Yusuf Özgül on 28.09.2023. // -import SwiftUI -import Server +import CommonKit import MockingStarCore +import Server +import SwiftUI @Observable final class SideBarServerViewModel { @@ -16,7 +17,10 @@ final class SideBarServerViewModel { private let defaultServers: [ServerInterface] private init() { - defaultServers = [Server()] + @UserDefaultStorage("httpServerPort") var httpServerPort: UInt16 = 8008 + defaultServers = [ + Server(port: httpServerPort) + ] prepareDefaultHTTPServer() } diff --git a/MockingStar/MockingStar/Modules/Settings/SettingsView.swift b/MockingStar/MockingStar/Modules/Settings/SettingsView.swift index 3b49f47fbc..6c8b7a5aa0 100644 --- a/MockingStar/MockingStar/Modules/Settings/SettingsView.swift +++ b/MockingStar/MockingStar/Modules/Settings/SettingsView.swift @@ -26,6 +26,9 @@ struct SettingsView: View { } TextField("Server Port", value: $viewModel.httpServerPort, format: .port(), prompt: Text("Server Port")) + Text("If you change server port, please restart application.") + .foregroundStyle(.secondary) + .font(.footnote) LabeledContent("Diagnostic") { DiagnosticView()