Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DevLog/Domain/Entity/PushNotification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

struct PushNotification {
struct PushNotification: Hashable {
let id: String
let title: String
let body: String
Expand Down
2 changes: 1 addition & 1 deletion DevLog/Domain/Entity/SystemTodoCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

enum SystemTodoCategory: String, CaseIterable {
enum SystemTodoCategory: String, CaseIterable, Hashable {
case issue // 이슈
case feature // 신규 기능
case improvement // 개선/리팩터링
Expand Down
2 changes: 1 addition & 1 deletion DevLog/Domain/Entity/Todo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

struct Todo: Equatable {
struct Todo: Hashable {
let id: String
var isPinned: Bool // 해당 할 일이 상단에 고정되어 있는지 여부
var isCompleted: Bool // 해당 할 일의 완료 여부
Expand Down
2 changes: 1 addition & 1 deletion DevLog/Domain/Entity/TodoCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

enum TodoCategory: Equatable {
enum TodoCategory: Hashable {
case system(SystemTodoCategory)
case user(UserTodoCategory)

Expand Down
2 changes: 1 addition & 1 deletion DevLog/Domain/Entity/TodoReference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

struct TodoReference {
struct TodoReference: Hashable {
let id: String
let title: String
let category: TodoCategory
Expand Down
2 changes: 1 addition & 1 deletion DevLog/Domain/Entity/UserTodoCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

struct UserTodoCategory: Equatable {
struct UserTodoCategory: Hashable {
var id: String
var name: String
var colorHex: String
Expand Down
2 changes: 1 addition & 1 deletion DevLog/Domain/Entity/WebPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

struct WebPage {
struct WebPage: Hashable {
let title: String?
let url: URL
let displayURL: URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,4 @@ struct ProfileSelectedDayActivity: Identifiable, Hashable {
}
return showsCreated ? "생성" : "완료"
}

static func == (lhs: Self, rhs: Self) -> Bool {
lhs.todo.id == rhs.todo.id
&& lhs.showsCreated == rhs.showsCreated
&& lhs.showsCompleted == rhs.showsCompleted
}

func hash(into hasher: inout Hasher) {
hasher.combine(todo.id)
hasher.combine(showsCreated)
hasher.combine(showsCompleted)
}
}
8 changes: 0 additions & 8 deletions DevLog/Presentation/Structure/PushNotificationItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,4 @@ struct PushNotificationItem: Identifiable, Hashable {
self.todoId = notification.todoId
self.todoCategory = notification.todoCategory
}

static func == (lhs: PushNotificationItem, rhs: PushNotificationItem) -> Bool {
lhs.id == rhs.id
}

func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
}
8 changes: 0 additions & 8 deletions DevLog/Presentation/Structure/RecentTodoItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,4 @@ struct RecentTodoItem: Identifiable, Hashable {
self.tags = todo.tags
self.category = todo.category
}

static func == (lhs: RecentTodoItem, rhs: RecentTodoItem) -> Bool {
lhs.id == rhs.id
}

func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
}
8 changes: 0 additions & 8 deletions DevLog/Presentation/Structure/TodayTodoItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,4 @@ struct TodayTodoItem: Identifiable, Hashable {
self.dueDate = todo.dueDate
self.category = todo.category
}

static func == (lhs: TodayTodoItem, rhs: TodayTodoItem) -> Bool {
lhs.id == rhs.id
}

func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
}
8 changes: 0 additions & 8 deletions DevLog/Presentation/Structure/UserTodoCategoryItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,4 @@ struct UserTodoCategoryItem: Identifiable, Hashable {
var localizedName: String { userTodoCategory.name }

var color: Color { Color(hexString: userTodoCategory.colorHex) ?? .gray }

static func == (lhs: UserTodoCategoryItem, rhs: UserTodoCategoryItem) -> Bool {
lhs.id == rhs.id
}

func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
}
10 changes: 0 additions & 10 deletions DevLog/Presentation/Structure/WebPageItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,3 @@ struct WebPageItem: Identifiable, Hashable {
var displayURL: String { metadata.displayURL.absoluteString }
var imageURL: URL? { metadata.imageURL }
}

extension WebPageItem {
func hash(into hasher: inout Hasher) {
hasher.combine(metadata.url)
}

static func == (lhs: WebPageItem, rhs: WebPageItem) -> Bool {
lhs.metadata.url == rhs.metadata.url
}
}
26 changes: 17 additions & 9 deletions DevLog/Presentation/ViewModel/TodoManageViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ final class TodoManageViewModel: Store {

var placeholder: String {
guard
let categoryItem = state.category,
case .user(let userTodoCategory) = categoryItem.category
let item = state.category,
case .user(let category) = item.category
else {
return "이름"
}

return userTodoCategory.name
return category.name
}

var categoryNameCountText: String {
Expand All @@ -81,28 +81,36 @@ final class TodoManageViewModel: Store {
return false
}

let trimmedCategoryName = category.name.trimmingCharacters(in: .whitespacesAndNewlines)
if trimmedCategoryName.isEmpty {
let name = category.name.trimmingCharacters(in: .whitespacesAndNewlines)
if name.isEmpty {
return false
}

if SystemTodoCategory.allCases.contains(where: {
$0.rawValue.caseInsensitiveCompare(trimmedCategoryName) == .orderedSame
$0.rawValue.caseInsensitiveCompare(name) == .orderedSame
}) {
return false
}

if state.preferences.contains(where: { item in
guard case .user(let userTodoCategory) = item.category,
userTodoCategory.id != category.id else {
guard case .user(let userCategory) = item.category,
userCategory.id != category.id else {
return false
}

return userTodoCategory.name.caseInsensitiveCompare(trimmedCategoryName) == .orderedSame
return userCategory.name.caseInsensitiveCompare(name) == .orderedSame
}) {
return false
}

if let item = state.preferences.first(where: { $0.id == item.id }),
case .user(let originalCategory) = item.category {
let originalName = originalCategory.name.trimmingCharacters(in: .whitespacesAndNewlines)
if originalName == name && originalCategory.colorHex == category.colorHex {
return false
}
}

return true
}

Expand Down