Skip to content

Commit

Permalink
add isEdited flag for api key setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ski-u committed May 3, 2024
1 parent ff0a4ca commit 64eaf56
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Features/Sources/Settings/APIKey/APIKeySetting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import Models
public struct APIKeySetting {
public struct State: Equatable {
var apiKeyInput: APIKey
var initialAPIKey: APIKey

var isEdited: Bool {
apiKeyInput != initialAPIKey
}

public init(
apiKeyInput: APIKey = APIClient.apiKey ?? .init(rawValue: "")
) {
self.apiKeyInput = apiKeyInput
initialAPIKey = apiKeyInput
}
}

Expand Down
1 change: 1 addition & 0 deletions Features/Sources/Settings/APIKey/APIKeySettingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct APIKeySettingView: View {
Button(action: { viewStore.send(.updateButtonTapped) }) {
Text("Update")
}
.disabled(!viewStore.isEdited)
}
}
}
Expand Down

0 comments on commit 64eaf56

Please sign in to comment.