Skip to content

Commit e010276

Browse files
committed
Refactored CENotification to use delegated inits.
1 parent 9c8063f commit e010276

1 file changed

Lines changed: 33 additions & 10 deletions

File tree

CodeEdit/Features/Notifications/Models/CENotification.swift

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,16 @@ struct CENotification: Identifiable, Equatable {
128128
isSticky: Bool = false,
129129
isRead: Bool = false
130130
) {
131-
self.id = id
132-
self.icon = .text(iconText, backgroundColor: iconColor, textColor: iconTextColor)
133-
self.title = title
134-
self.description = description
135-
self.actionButtonTitle = actionButtonTitle
136-
self.action = action
137-
self.isSticky = isSticky
138-
self.isRead = isRead
139-
self.timestamp = Date()
131+
self.init(
132+
id: id,
133+
icon: .text(iconText, backgroundColor: iconColor, textColor: iconTextColor),
134+
title: title,
135+
description: description,
136+
actionButtonTitle: actionButtonTitle,
137+
action: action,
138+
isSticky: isSticky,
139+
isRead: isRead
140+
)
140141
}
141142

142143
init(
@@ -148,9 +149,31 @@ struct CENotification: Identifiable, Equatable {
148149
action: @escaping () -> Void,
149150
isSticky: Bool = false,
150151
isRead: Bool = false
152+
) {
153+
self.init(
154+
id: id,
155+
icon: .image(iconImage),
156+
title: title,
157+
description: description,
158+
actionButtonTitle: actionButtonTitle,
159+
action: action,
160+
isSticky: isSticky,
161+
isRead: isRead
162+
)
163+
}
164+
165+
private init(
166+
id: UUID,
167+
icon: IconType,
168+
title: String,
169+
description: String,
170+
actionButtonTitle: String,
171+
action: @escaping () -> Void,
172+
isSticky: Bool,
173+
isRead: Bool
151174
) {
152175
self.id = id
153-
self.icon = .image(iconImage)
176+
self.icon = icon
154177
self.title = title
155178
self.description = description
156179
self.actionButtonTitle = actionButtonTitle

0 commit comments

Comments
 (0)