Skip to content

Commit 7c3199c

Browse files
committed
refactor: TCA helper 스타일 통일
1 parent 29d4edd commit 7c3199c

7 files changed

Lines changed: 71 additions & 71 deletions

File tree

Application/DevLogPresentation/Sources/Home/Category/CategoryManageFeature.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ struct CategoryManageFeature {
163163
}
164164
case .tapDeleteUserCategory(let item):
165165
if item.isUserCategory {
166-
state.alert = deleteAlertState(for: item)
166+
state.alert = Self.deleteAlertState(for: item)
167167
}
168168
case .tapDoneButton:
169169
break
@@ -204,7 +204,7 @@ private struct CategoryManageSheetFeature: Reducer {
204204
}
205205

206206
private extension CategoryManageFeature {
207-
func deleteAlertState(for item: TodoCategoryItem) -> AlertState<Action.Alert> {
207+
static func deleteAlertState(for item: TodoCategoryItem) -> AlertState<Action.Alert> {
208208
AlertState {
209209
TextState(String(localized: "todo_manage_delete_category_title"))
210210
} actions: {

Application/DevLogPresentation/Sources/Home/Detail/TodoDetailFeature.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ struct TodoDetailFeature {
108108
case .onAppear:
109109
return fetchTodoEffect(todoId: state.todoId)
110110
case .fetchFailed:
111-
state.alert = alertState()
111+
state.alert = Self.alertState()
112112
case .setSheet(let sheet):
113113
state.sheet = sheet
114114
case .setFullScreenCover(let cover):
@@ -209,7 +209,7 @@ private extension TodoDetailFeature {
209209
}
210210
}
211211

212-
func alertState() -> AlertState<Never> {
212+
static func alertState() -> AlertState<Never> {
213213
AlertState {
214214
TextState(String(localized: "common_error_title"))
215215
} actions: {

Application/DevLogPresentation/Sources/Login/LoginFeature.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct LoginFeature {
4646
case .tapSignInButton(let provider):
4747
return signInEffect(provider)
4848
case .signInFailed(let alertType):
49-
state.alert = alertState(for: alertType)
49+
state.alert = Self.alertState(for: alertType)
5050
case .loading:
5151
break
5252
}
@@ -87,7 +87,7 @@ private extension LoginFeature {
8787
}
8888
}
8989

90-
func alertState(for alertType: AlertType) -> AlertState<Never> {
90+
static func alertState(for alertType: AlertType) -> AlertState<Never> {
9191
let title: String
9292
let message: String
9393

Application/DevLogPresentation/Sources/Search/SearchFeature.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct SearchFeature {
9898
break
9999
case .binding(\.isSearching):
100100
if !state.isSearching {
101-
return cancelSearchEffect(isLoading: state.isLoading)
101+
return Self.cancelSearchEffect(isLoading: state.isLoading)
102102
}
103103
case .binding(\.searchQuery):
104104
state.showAllTodos = false
@@ -107,10 +107,10 @@ struct SearchFeature {
107107
if trimmed.isEmpty {
108108
state.webPages = []
109109
state.todos = []
110-
return cancelSearchEffect(isLoading: state.isLoading)
110+
return Self.cancelSearchEffect(isLoading: state.isLoading)
111111
} else {
112112
return .concatenate(
113-
cancelSearchEffect(isLoading: state.isLoading),
113+
Self.cancelSearchEffect(isLoading: state.isLoading),
114114
debounceFetchEffect(trimmed)
115115
)
116116
}
@@ -140,12 +140,12 @@ struct SearchFeature {
140140
if trimmed.isEmpty {
141141
state.webPages = []
142142
state.todos = []
143-
return cancelSearchEffect(isLoading: state.isLoading)
143+
return Self.cancelSearchEffect(isLoading: state.isLoading)
144144
} else {
145145
return fetchEffect(trimmed, isLoading: state.isLoading)
146146
}
147147
case .setAlert(let isPresented):
148-
state.alert = isPresented ? alertState() : nil
148+
state.alert = isPresented ? Self.alertState() : nil
149149
case .setShowAllTodos(let shouldShowAll):
150150
state.showAllTodos = shouldShowAll
151151
case .setShowAllWebPages(let shouldShowAll):
@@ -208,11 +208,11 @@ private enum SearchUpdateRecentQueriesUseCaseKey: DependencyKey {
208208
}
209209

210210
private extension SearchFeature {
211-
func cancelSearchEffect(isLoading: Bool) -> Effect<Action> {
211+
static func cancelSearchEffect(isLoading: Bool) -> Effect<Action> {
212212
.merge(
213213
.cancel(id: CancelID.debounce),
214214
.cancel(id: CancelID.request),
215-
endLoadingEffect(isLoading: isLoading)
215+
Self.endLoadingEffect(isLoading: isLoading)
216216
)
217217
}
218218

@@ -228,12 +228,12 @@ private extension SearchFeature {
228228
}
229229

230230
func fetchEffect(_ query: String, isLoading: Bool) -> Effect<Action> {
231-
let searchesTodoOnly = searchesTodoOnly(query)
231+
let searchesTodoOnly = Self.searchesTodoOnly(query)
232232

233233
return .run { [fetchTodosUseCase, fetchWebPagesUseCase] send in
234234
do {
235235
async let todos = fetchTodosUseCase.execute(TodoQuery(keyword: query), cursor: nil)
236-
async let webPageItems = fetchWebPageItems(
236+
async let webPageItems = Self.fetchWebPageItems(
237237
query: query,
238238
searchesTodoOnly: searchesTodoOnly,
239239
fetchWebPagesUseCase: fetchWebPagesUseCase
@@ -257,7 +257,7 @@ private extension SearchFeature {
257257
.cancellable(id: CancelID.request, cancelInFlight: true)
258258
}
259259

260-
func endLoadingEffect(isLoading: Bool) -> Effect<Action> {
260+
static func endLoadingEffect(isLoading: Bool) -> Effect<Action> {
261261
guard isLoading else { return .none }
262262
return .send(.loading(.end(target: .default, mode: .immediate)))
263263
}
@@ -269,11 +269,11 @@ private extension SearchFeature {
269269
}
270270
}
271271

272-
func searchesTodoOnly(_ query: String) -> Bool {
272+
static func searchesTodoOnly(_ query: String) -> Bool {
273273
query.trimmingCharacters(in: .whitespacesAndNewlines).hasPrefix("#")
274274
}
275275

276-
func fetchWebPageItems(
276+
static func fetchWebPageItems(
277277
query: String,
278278
searchesTodoOnly: Bool,
279279
fetchWebPagesUseCase: FetchWebPagesUseCase
@@ -286,7 +286,7 @@ private extension SearchFeature {
286286
return webPages.map { WebPageItem(from: $0) }
287287
}
288288

289-
func alertState() -> AlertState<Never> {
289+
static func alertState() -> AlertState<Never> {
290290
AlertState {
291291
TextState(String(localized: "common_error_title"))
292292
} actions: {

Application/DevLogPresentation/Sources/Settings/AccountFeature.swift

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct AccountFeature {
6060
case .unlinkFromProvider(let provider):
6161
return unlinkProviderEffect(provider)
6262
case .setAlert(let type):
63-
state.alert = alertState(for: type)
63+
state.alert = Self.alertState(for: type)
6464
case .setProviders(let currentProvider, let allProviders):
6565
state.currentProvider = currentProvider
6666
state.connectedProviders = allProviders.filter { $0 != currentProvider }
@@ -154,7 +154,7 @@ private extension AccountFeature {
154154

155155
if error.isSocialLoginCancelled { return }
156156

157-
await send(.setAlert(linkAlertType(for: error)))
157+
await send(.setAlert(Self.linkAlertType(for: error)))
158158
}
159159
}
160160
}
@@ -177,51 +177,51 @@ private extension AccountFeature {
177177
}
178178
}
179179
}
180-
}
181180

182-
private func linkAlertType(for error: Error) -> AccountFeature.AlertType {
183-
guard let authError = error as? AuthError else {
184-
return .error
185-
}
181+
static func linkAlertType(for error: Error) -> AlertType {
182+
guard let authError = error as? AuthError else {
183+
return .error
184+
}
186185

187-
switch authError {
188-
case .linkEmailNotFound:
189-
return .linkEmailNotFound
190-
case .linkEmailMismatch:
191-
return .linkEmailMismatch
192-
case .linkCredentialAlreadyInUse:
193-
return .linkCredentialAlreadyInUse
194-
case .notAuthenticated, .failedToUnlinkLastProvider, .emailNotFound, .unsupportedProvider:
195-
return .error
186+
switch authError {
187+
case .linkEmailNotFound:
188+
return .linkEmailNotFound
189+
case .linkEmailMismatch:
190+
return .linkEmailMismatch
191+
case .linkCredentialAlreadyInUse:
192+
return .linkCredentialAlreadyInUse
193+
case .notAuthenticated, .failedToUnlinkLastProvider, .emailNotFound, .unsupportedProvider:
194+
return .error
195+
}
196196
}
197-
}
198197

199-
private func alertState(for type: AccountFeature.AlertType) -> AlertState<Never> {
200-
let title: String
201-
let message: String
202-
203-
switch type {
204-
case .linkEmailNotFound:
205-
title = String(localized: "account_alert_email_unavailable_title")
206-
message = String(localized: "account_alert_email_unavailable_message")
207-
case .linkEmailMismatch:
208-
title = String(localized: "account_alert_cannot_link_title")
209-
message = String(localized: "account_alert_cannot_link_message")
210-
case .linkCredentialAlreadyInUse:
211-
title = String(localized: "account_alert_already_linked_title")
212-
message = String(localized: "account_alert_already_linked_message")
213-
case .error:
214-
title = String(localized: "common_error_title")
215-
message = String(localized: "common_error_message")
216-
}
217-
218-
return AlertState {
219-
TextState(title)
220-
} actions: {
221-
ButtonState(role: .cancel) {
222-
TextState(String(localized: "common_close"))
198+
static func alertState(for type: AlertType) -> AlertState<Never> {
199+
let title: String
200+
let message: String
201+
202+
switch type {
203+
case .linkEmailNotFound:
204+
title = String(localized: "account_alert_email_unavailable_title")
205+
message = String(localized: "account_alert_email_unavailable_message")
206+
case .linkEmailMismatch:
207+
title = String(localized: "account_alert_cannot_link_title")
208+
message = String(localized: "account_alert_cannot_link_message")
209+
case .linkCredentialAlreadyInUse:
210+
title = String(localized: "account_alert_already_linked_title")
211+
message = String(localized: "account_alert_already_linked_message")
212+
case .error:
213+
title = String(localized: "common_error_title")
214+
message = String(localized: "common_error_message")
215+
}
216+
217+
return AlertState {
218+
TextState(title)
219+
} actions: {
220+
ButtonState(role: .cancel) {
221+
TextState(String(localized: "common_close"))
222+
}
223+
} message: {
224+
TextState(message)
223225
}
224-
} message: {
225-
TextState(message)
226226
}
227227
}

Application/DevLogPresentation/Sources/Settings/PushNotificationSettingsFeature.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct PushNotificationSettingsFeature {
6767
case .alert:
6868
break
6969
case .binding(\.pushNotificationEnable):
70-
return updatePushNotificationSettingsEffect(settings: settings(from: state))
70+
return updatePushNotificationSettingsEffect(settings: Self.settings(from: state))
7171
case .binding(\.viewPushNotificationTime):
7272
let time = state.viewPushNotificationTime
7373
state.timePicker?.time = time
@@ -81,19 +81,19 @@ struct PushNotificationSettingsFeature {
8181
guard let time = state.timePicker?.time else { break }
8282
state.timePicker = nil
8383
state.viewPushNotificationTime = time
84-
return updatePushNotificationSettingsEffect(settings: settings(from: state))
84+
return updatePushNotificationSettingsEffect(settings: Self.settings(from: state))
8585
case .timePicker:
8686
break
8787
case .fetchSettings:
8888
return fetchPushNotificationSettingsEffect()
8989
case .setAlert:
90-
state.alert = alertState()
90+
state.alert = Self.alertState()
9191
case .tapCustomTime:
9292
state.timePicker = TimePickerState(time: state.viewPushNotificationTime)
9393
case .selectPresetTime(let date):
9494
state.viewPushNotificationTime = date
9595
state.timePicker?.time = date
96-
return updatePushNotificationSettingsEffect(settings: settings(from: state))
96+
return updatePushNotificationSettingsEffect(settings: Self.settings(from: state))
9797
case .loading:
9898
break
9999
}
@@ -182,7 +182,7 @@ private extension PushNotificationSettingsFeature {
182182
}
183183
}
184184

185-
func settings(from state: State) -> PushNotificationSettings {
185+
static func settings(from state: State) -> PushNotificationSettings {
186186
let date = state.timePicker?.time ?? state.viewPushNotificationTime
187187
let dateComponents = Calendar.current.dateComponents([.hour, .minute], from: date)
188188
return PushNotificationSettings(
@@ -191,7 +191,7 @@ private extension PushNotificationSettingsFeature {
191191
)
192192
}
193193

194-
func alertState() -> AlertState<Never> {
194+
static func alertState() -> AlertState<Never> {
195195
AlertState {
196196
TextState(String(localized: "common_error_title"))
197197
} actions: {

Application/DevLogPresentation/Sources/Settings/SettingsFeature.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ struct SettingsFeature {
104104
case .networkStatusChanged(let isConnected):
105105
state.isNetworkConnected = isConnected
106106
case .setAlert(let type):
107-
state.alert = alertState(for: type)
107+
state.alert = Self.alertState(for: type)
108108
state.alertType = type
109109
case .setDirSize(let value):
110110
state.dirSize = value
111111
case .updateDirSize:
112112
return fetchWebPageImageDirSizeEffect()
113113
case .tapRemoveCacheButton:
114-
state.alert = alertState(for: .removeCache)
114+
state.alert = Self.alertState(for: .removeCache)
115115
state.alertType = .removeCache
116116
case .loading:
117117
break
@@ -301,7 +301,7 @@ private extension SettingsFeature {
301301
}
302302
}
303303

304-
func alertState(for type: Action.AlertType) -> AlertState<Action.Alert> {
304+
static func alertState(for type: Action.AlertType) -> AlertState<Action.Alert> {
305305
switch type {
306306
case .signOut:
307307
return AlertState {

0 commit comments

Comments
 (0)