-
Notifications
You must be signed in to change notification settings - Fork 0
[#199] HomeView에서 TodayView와 겹치는 기능을 제거하고 새로운 기능을 추가한다 #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
214724f
feat: TodayView와 중복되는 기능 제거
opficdev 370b581
feat: 최근 수정된 Todo (최대 5개) 를 보여주도록 추가
opficdev 1cceafc
feat: lineLimit이 있을 경우, '...' 이 보이도록 추가
opficdev 8aca5f3
feat: lineLimit이 걸릴 시 태그 마지막에 '...'가 보이도록 추가
opficdev 9a7f4f6
feat: 태그와 중요 표시가 보이도록 추가하고, 업데이트 시간이 1초마다 업데이트되도록 개선
opficdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // | ||
| // RecentTodoItem.swift | ||
| // DevLog | ||
| // | ||
| // Created by Codex on 3/6/26. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| struct RecentTodoItem: Identifiable, Hashable { | ||
| let id: String | ||
| let title: String | ||
| let isPinned: Bool | ||
| let updatedAt: Date | ||
| let tags: [String] | ||
| let kind: TodoKind | ||
|
|
||
| init(from todo: Todo) { | ||
| self.id = todo.id | ||
| self.title = todo.title | ||
| self.isPinned = todo.isPinned | ||
| self.updatedAt = todo.updatedAt | ||
| self.tags = todo.tags | ||
| self.kind = todo.kind | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ import Foundation | |
| final class HomeViewModel: Store { | ||
| struct State: Equatable { | ||
| var todoKindPreferences = TodoKind.allCases.map { TodoKindPreference(kind: $0, isVisible: true) } | ||
| var pinnedTodos: [PinnedTodoItem] = [] | ||
| var recentTodos: [RecentTodoItem] = [] | ||
| var webPages: [WebPageItem] = [] | ||
| var showContentPicker: Bool = false | ||
| var showTodoEditor: Bool = false | ||
|
|
@@ -21,7 +21,7 @@ final class HomeViewModel: Store { | |
| var searchText: String = "" | ||
| var isSearching: Bool = false | ||
| var reorderTodo: Bool = false | ||
| var isPinnedLoading: Bool = false | ||
| var isRecentTodosLoading: Bool = false | ||
| var isWebPageLoading: Bool = false | ||
| var isWebPageInputLoading: Bool = false | ||
| var showAlert: Bool = false | ||
|
|
@@ -51,9 +51,9 @@ final class HomeViewModel: Store { | |
| case undoDeleteWebPage | ||
| case confirmDeleteWebPage | ||
| case setToast(isPresented: Bool, type: ToastType? = nil) | ||
| case fetchPinnedTodos([PinnedTodoItem]) | ||
| case fetchRecentTodos([RecentTodoItem]) | ||
| case fetchWebPages([WebPageItem]) | ||
| case setPinnedLoading(Bool) | ||
| case setRecentTodosLoading(Bool) | ||
| case setWebPageLoading(Bool) | ||
| case setWebPageInputLoading(Bool) | ||
| } | ||
|
|
@@ -62,7 +62,7 @@ final class HomeViewModel: Store { | |
| case upsertTodo(Todo) | ||
| case addWebPage(String) | ||
| case deleteWebPage(String) | ||
| case fetchPinnedTodos | ||
| case fetchRecentTodos | ||
| case fetchWebPages | ||
| case showModalAfterDelay(ModalType) | ||
| } | ||
|
|
@@ -119,7 +119,7 @@ final class HomeViewModel: Store { | |
| .addWebPage, .confirmDeleteWebPage: | ||
| effects = reduceByView(action, state: &state) | ||
|
|
||
| case .fetchPinnedTodos, .fetchWebPages, .setPinnedLoading, | ||
| case .fetchRecentTodos, .fetchWebPages, .setRecentTodosLoading, | ||
| .setWebPageLoading, .setWebPageInputLoading: | ||
| effects = reduceByRun(action, state: &state) | ||
| } | ||
|
|
@@ -134,6 +134,27 @@ final class HomeViewModel: Store { | |
| Task { | ||
| do { | ||
| try await upsertTodoUseCase.execute(todo) | ||
| let page = try await fetchRecentTodos() | ||
| let items = page.items | ||
| .filter { $0.createdAt != $0.updatedAt } | ||
| .prefix(5) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| .map { RecentTodoItem(from: $0) } | ||
| send(.fetchRecentTodos(items)) | ||
| } catch { | ||
| send(.setAlert(isPresented: true, type: .error)) | ||
| } | ||
| } | ||
| case .fetchRecentTodos: | ||
| Task { | ||
| do { | ||
| defer { send(.setRecentTodosLoading(false)) } | ||
| send(.setRecentTodosLoading(true)) | ||
| let page = try await fetchRecentTodos() | ||
| let items = page.items | ||
| .filter { $0.createdAt != $0.updatedAt } | ||
| .prefix(5) | ||
| .map { RecentTodoItem(from: $0) } | ||
| send(.fetchRecentTodos(items)) | ||
|
Comment on lines
+152
to
+157
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } catch { | ||
| send(.setAlert(isPresented: true, type: .error)) | ||
| } | ||
|
|
@@ -164,18 +185,6 @@ final class HomeViewModel: Store { | |
| send(.setAlert(isPresented: true, type: .error)) | ||
| } | ||
| } | ||
| case .fetchPinnedTodos: | ||
| Task { | ||
| do { | ||
| defer { send(.setPinnedLoading(false)) } | ||
| send(.setPinnedLoading(true)) | ||
| let page = try await fetchTodosUseCase.execute(TodoQuery(isPinned: true), cursor: nil) | ||
| let todos = page.items | ||
| send(.fetchPinnedTodos(todos.map { PinnedTodoItem(from: $0) })) | ||
| } catch { | ||
| send(.setAlert(isPresented: true, type: .error)) | ||
| } | ||
| } | ||
| case .fetchWebPages: | ||
| Task { | ||
| do { | ||
|
|
@@ -249,7 +258,7 @@ private extension HomeViewModel { | |
| func reduceByView(_ action: Action, state: inout State) -> [SideEffect] { | ||
| switch action { | ||
| case .onAppear: | ||
| return [.fetchPinnedTodos, .fetchWebPages] | ||
| return [.fetchRecentTodos, .fetchWebPages] | ||
| case .updateSearching(let isSearching): | ||
| state.isSearching = isSearching | ||
| case .updateSearchText(let text): | ||
|
|
@@ -275,8 +284,8 @@ private extension HomeViewModel { | |
|
|
||
| func reduceByRun(_ action: Action, state: inout State) -> [SideEffect] { | ||
| switch action { | ||
| case .fetchPinnedTodos(let todos): | ||
| state.pinnedTodos = todos | ||
| case .fetchRecentTodos(let todos): | ||
| state.recentTodos = todos | ||
| case .fetchWebPages(let pages): | ||
| let filteredPages: [WebPageItem] | ||
| if let (pendingPage, _) = pendingTask { | ||
|
|
@@ -285,8 +294,8 @@ private extension HomeViewModel { | |
| filteredPages = pages | ||
| } | ||
| state.webPages = filteredPages | ||
| case .setPinnedLoading(let isLoading): | ||
| state.isPinnedLoading = isLoading | ||
| case .setRecentTodosLoading(let isLoading): | ||
| state.isRecentTodosLoading = isLoading | ||
| case .setWebPageLoading(let isLoading): | ||
| state.isWebPageLoading = isLoading | ||
| case .setWebPageInputLoading(let isLoading): | ||
|
|
@@ -350,4 +359,15 @@ private extension HomeViewModel { | |
| } | ||
| return "https://" + trimmed | ||
| } | ||
|
|
||
| func fetchRecentTodos() async throws -> TodoPage { | ||
| try await fetchTodosUseCase.execute( | ||
| TodoQuery( | ||
| sortTarget: .updatedAt, | ||
| sortOrder: .latest, | ||
| pageSize: 100 | ||
| ), | ||
| cursor: nil | ||
| ) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 필터 조건
($0.createdAt != $0.updatedAt)때문에 새로 생성된 Todo 항목이 '최근 수정' 목록에 표시되지 않을 수 있습니다.upsertTodo가 새 항목 생성에도 사용되므로, 생성 직후 목록에 나타나지 않는 것은 사용자에게 혼란을 줄 수 있습니다. '최근 수정'이라는 이름에 맞게, 생성된 항목을 제외하는 것이 의도된 동작일 수 있으나,upsert후 목록을 갱신하는 현재 로직과는 맞지 않아 보입니다. 이 필터 조건을 제거하여 생성된 항목도 목록에 포함시키는 것을 고려해 보세요.