Skip to content

Commit d6e1508

Browse files
committed
Rebased from latest main
1 parent 246b76e commit d6e1508

File tree

3 files changed

+5
-163
lines changed

3 files changed

+5
-163
lines changed

CodeEdit/Features/Notifications/Models/CENotification.swift

+5-72
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import SwiftUI
1111
struct CENotification: Identifiable, Equatable {
1212
let id: UUID
1313
let icon: IconType
14-
var title: String
15-
var description: String
16-
var actionButtonTitle: String
17-
var action: () -> Void
18-
var isSticky: Bool
14+
let title: String
15+
let description: String
16+
let actionButtonTitle: String
17+
let action: () -> Void
18+
let isSticky: Bool
1919
var isRead: Bool
2020
let timestamp: Date
2121
var isBeingDismissed: Bool = false
@@ -95,73 +95,6 @@ struct CENotification: Identifiable, Equatable {
9595
)
9696
}
9797

98-
private init(
99-
id: UUID,
100-
icon: IconType,
101-
title: String,
102-
description: String,
103-
actionButtonTitle: String,
104-
action: @escaping () -> Void,
105-
isSticky: Bool,
106-
isRead: Bool
107-
) {
108-
self.id = id
109-
self.icon = .symbol(name: iconSymbol, color: iconColor)
110-
self.title = title
111-
self.description = description
112-
self.actionButtonTitle = actionButtonTitle
113-
self.action = action
114-
self.isSticky = isSticky
115-
self.isRead = isRead
116-
self.timestamp = Date()
117-
}
118-
119-
init(
120-
id: UUID = UUID(),
121-
iconText: String,
122-
iconTextColor: Color? = nil,
123-
iconColor: Color? = nil,
124-
title: String,
125-
description: String,
126-
actionButtonTitle: String,
127-
action: @escaping () -> Void,
128-
isSticky: Bool = false,
129-
isRead: Bool = false
130-
) {
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-
)
141-
}
142-
143-
init(
144-
id: UUID = UUID(),
145-
iconImage: Image,
146-
title: String,
147-
description: String,
148-
actionButtonTitle: String,
149-
action: @escaping () -> Void,
150-
isSticky: Bool = false,
151-
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-
16598
private init(
16699
id: UUID,
167100
icon: IconType,

CodeEdit/Features/Notifications/NotificationManager.swift

-86
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,6 @@ final class NotificationManager: NSObject, ObservableObject {
2323

2424
private var isAppActive: Bool = true
2525

26-
/// Whether notifications were manually shown via toolbar
27-
@Published private(set) var isManuallyShown: Bool = false
28-
29-
/// Set of hidden notification IDs
30-
private var hiddenNotificationIds: Set<UUID> = []
31-
32-
/// Whether any non-sticky notifications are currently hidden
33-
private var hasHiddenNotifications: Bool {
34-
activeNotifications.contains { notification in
35-
!notification.isSticky && !isNotificationVisible(notification)
36-
}
37-
}
38-
39-
/// Whether a notification should be visible in the overlay
40-
func isNotificationVisible(_ notification: CENotification) -> Bool {
41-
if notification.isBeingDismissed {
42-
return true // Always show notifications being dismissed
43-
}
44-
if notification.isSticky {
45-
return true // Always show sticky notifications
46-
}
47-
if isManuallyShown {
48-
return true // Show all notifications when manually shown
49-
}
50-
// Otherwise, show if not hidden and has active timer
51-
return !hiddenNotificationIds.contains(notification.id) && timers[notification.id] != nil
52-
}
53-
5426
/// Number of unread notifications
5527
var unreadCount: Int {
5628
notifications.filter { !$0.isRead }.count
@@ -172,64 +144,6 @@ final class NotificationManager: NSObject, ObservableObject {
172144
}
173145
}
174146

175-
/// Updates an existing notification
176-
/// - Parameters:
177-
/// - id: UUID of notification to update
178-
/// - title: New title (optional)
179-
/// - description: New description (optional)
180-
/// - actionButtonTitle: New action button title (optional)
181-
/// - action: New action closure (optional)
182-
/// - isSticky: New sticky state (optional)
183-
func update(
184-
id: UUID,
185-
title: String? = nil,
186-
description: String? = nil,
187-
actionButtonTitle: String? = nil,
188-
action: (() -> Void)? = nil,
189-
isSticky: Bool? = nil
190-
) {
191-
if let index = notifications.firstIndex(where: { $0.id == id }) {
192-
var notification = notifications[index]
193-
194-
if let title = title {
195-
notification.title = title
196-
}
197-
if let description = description {
198-
notification.description = description
199-
}
200-
if let actionButtonTitle = actionButtonTitle {
201-
notification.actionButtonTitle = actionButtonTitle
202-
}
203-
if let action = action {
204-
notification.action = action
205-
}
206-
if let isSticky = isSticky {
207-
notification.isSticky = isSticky
208-
}
209-
210-
notifications[index] = notification
211-
}
212-
}
213-
214-
/// Deletes a notification
215-
/// - Parameter id: UUID of notification to delete
216-
func delete(id: UUID) {
217-
if let notification = notifications.first(where: { $0.id == id }) {
218-
dismissNotification(notification)
219-
}
220-
}
221-
222-
/// Deletes a notification after a delay
223-
/// - Parameters:
224-
/// - id: UUID of notification to delete
225-
/// - delay: Time to wait before deleting
226-
func delete(id: UUID, delay: TimeInterval) {
227-
Task { @MainActor in
228-
try? await Task.sleep(for: .seconds(delay))
229-
delete(id: id)
230-
}
231-
}
232-
233147
override init() {
234148
super.init()
235149
setupNotificationDelegate()

CodeEdit/Features/Notifications/Views/NotificationBannerView.swift

-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ struct NotificationBannerView: View {
1313

1414
@EnvironmentObject private var workspace: WorkspaceDocument
1515

16-
@Environment(\.colorScheme)
17-
private var colorScheme
18-
19-
@ObservedObject private var notificationManager = NotificationManager.shared
20-
2116
let notification: CENotification
2217
let onDismiss: () -> Void
2318
let onAction: () -> Void

0 commit comments

Comments
 (0)