Skip to content

Commit

Permalink
Merge pull request #25 from Trendyol/fix/change-settings-apply
Browse files Browse the repository at this point in the history
Fix/change settings apply
  • Loading branch information
yusufozgul authored May 6, 2024
2 parents 661536a + b8eb2e7 commit 0a9fe87
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Core/Server/Sources/Server/Routes/HandleMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion Core/Server/Sources/Server/Routes/HandleScenario.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import FlyingFox
import Foundation
@preconcurrency import CommonKit
import CommonKit

public protocol ScenarioHandlerInterface {
func addScenario(scenario: ScenarioModel) async throws
Expand Down
2 changes: 1 addition & 1 deletion Core/Server/Sources/Server/Routes/HandleSearchMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions MockingStar/MockingStar/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
},
"For your privacy" : {

},
"If you change server port, please restart application." : {

},
"Menubar Actions" : {

Expand Down
18 changes: 4 additions & 14 deletions MockingStar/MockingStar/Modules/Home/AppNavigationSplitView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
}

Expand Down
3 changes: 3 additions & 0 deletions MockingStar/MockingStar/Modules/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 0a9fe87

Please sign in to comment.