Skip to content

Commit 766d862

Browse files
committed
refactor: isPinned 플래그에서 옵셔널 제거
1 parent 5b29054 commit 766d862

5 files changed

Lines changed: 10 additions & 15 deletions

File tree

Application/DevLogCore/Sources/TodoQuery.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public struct TodoQuery: Equatable, Sendable {
3535

3636
public var categoryId: String?
3737
public var keyword: String?
38-
public var isPinned: Bool?
38+
public var isPinned: Bool
3939
public var completionFilter: CompletionFilter
4040
public var dueDateFilter: DueDateFilter
4141
public var sortDateFrom: Date?
@@ -49,7 +49,7 @@ public struct TodoQuery: Equatable, Sendable {
4949
public init(
5050
categoryId: String? = nil,
5151
keyword: String? = nil,
52-
isPinned: Bool? = nil,
52+
isPinned: Bool = false,
5353
completionFilter: CompletionFilter = .all,
5454
dueDateFilter: DueDateFilter = .all,
5555
sortDateFrom: Date? = nil,

Application/DevLogInfra/Sources/Service/TodoServiceImpl.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class TodoServiceImpl: TodoService {
3535
"sortOrder=\(query.sortOrder == .latest ? "latest" : "oldest")",
3636
query.keyword != nil ? "keywordLength=\(trimmedKeyword.count)" : nil,
3737
query.categoryId != nil ? "category=\(query.categoryId!)" : nil,
38-
query.isPinned != nil ? "pinned=\(query.isPinned!)" : nil,
38+
query.isPinned ? "pinned=true" : nil,
3939
query.completionFilter.isCompletedValue != nil
4040
? "completed=\(query.completionFilter.isCompletedValue!)"
4141
: nil,
@@ -58,8 +58,8 @@ final class TodoServiceImpl: TodoService {
5858
)
5959
}
6060

61-
if let isPinned = query.isPinned {
62-
firestoreQuery = firestoreQuery.whereField("isPinned", isEqualTo: isPinned)
61+
if query.isPinned {
62+
firestoreQuery = firestoreQuery.whereField("isPinned", isEqualTo: true)
6363
}
6464

6565
if let isCompleted = query.completionFilter.isCompletedValue {

Application/DevLogPresentation/Sources/Home/List/TodoListFeature.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,11 @@ struct TodoListFeature {
4343
var count = 0
4444
if query.sortTarget != .createdAt { count += 1 }
4545
if query.sortOrder != .latest { count += 1 }
46-
if query.isPinned != nil { count += 1 }
46+
if query.isPinned { count += 1 }
4747
if query.completionFilter != .all { count += 1 }
4848
return count
4949
}
5050

51-
var isPinnedOnly: Bool {
52-
get { query.isPinned == true }
53-
set { query.isPinned = newValue ? true : nil }
54-
}
55-
5651
static func == (lhs: Self, rhs: Self) -> Bool {
5752
lhs.category == rhs.category &&
5853
lhs.todos == rhs.todos &&
@@ -202,7 +197,7 @@ private extension TodoListFeature {
202197
state.searchResults = []
203198
state.showAllSearchResults = false
204199
return cancelSearchEffect()
205-
case .binding(\.query.sortTarget), .binding(\.query.sortOrder), .binding(\.isPinnedOnly),
200+
case .binding(\.query.sortTarget), .binding(\.query.sortOrder), .binding(\.query.isPinned),
206201
.binding(\.query.completionFilter):
207202
state.nextCursor = nil
208203
return fetchEffect(query: state.query, cursor: nil)

Application/DevLogPresentation/Sources/Home/List/TodoListView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ struct TodoListView: View {
379379

380380
private var filterMenu: some View {
381381
Menu {
382-
Toggle(isOn: $store.isPinnedOnly) {
382+
Toggle(isOn: $store.query.isPinned) {
383383
Text(String(localized: "todo_pinned"))
384384
}
385385

@@ -391,7 +391,7 @@ struct TodoListView: View {
391391
Text(String(localized: "todo_list_completion_status"))
392392
}
393393
} label: {
394-
let condition = store.state.query.isPinned == true || store.state.query.completionFilter != .all
394+
let condition = store.state.query.isPinned || store.state.query.completionFilter != .all
395395
HStack {
396396
Text(String(localized: "todo_list_filter_options"))
397397
Image(systemName: "chevron.down")

Application/DevLogPresentation/Tests/Home/TodoListFeatureTestDoubles.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ final class TodoListStoreTestAdapter {
7474
}
7575

7676
func togglePinnedOnly() async {
77-
await store.send(.binding(.set(\.isPinnedOnly, !store.state.isPinnedOnly)))
77+
await store.send(.binding(.set(\.query.isPinned, !store.state.query.isPinned)))
7878
await drainReceivedActions()
7979
}
8080

0 commit comments

Comments
 (0)