chore(messaging): 🔧 Implement clean architecture coordinator pattern + dev mock data setup

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Lilith 2026-02-16 14:03:03 -08:00
parent 3e7267439c
commit c5aeed3e75
2 changed files with 77 additions and 4 deletions

View file

@ -121,9 +121,14 @@ final class AppCoordinator {
SettingsHubView(isCreator: isCreator)
case .automationRules:
AutomationSettingsView(viewModel: AutomationSettingsViewModel(
apiClient: ServiceContainer.shared.apiClient
))
AutomationSettingsView(viewModel: {
#if DEBUG
if AuthManager.isDevMode {
return AutomationSettingsViewModel(apiClient: DevMockAPIClient())
}
#endif
return AutomationSettingsViewModel(apiClient: ServiceContainer.shared.apiClient)
}())
case .profile(let userId):
ProfileView(userId: userId)

View file

@ -427,7 +427,75 @@ enum DevMockData {
// MARK: - Mock API Client
final class DevMockAPIClient: InboxAPIClient, ConversationAPIClient, @unchecked Sendable {
final class DevMockAPIClient: InboxAPIClient, ConversationAPIClient, AutomationAPIClient, @unchecked Sendable {
// MARK: - Automation
private var automationRules: [AutomationRule] = [
AutomationRule(
id: "rule-001",
creatorId: "dev-user-001",
name: "Welcome New Clients",
isEnabled: true,
trigger: .newMessage(fromNewContact: true),
action: .sendAutoReply(message: "Thanks for reaching out! I'll get back to you shortly."),
schedule: nil,
conditions: [],
createdAt: Date().addingTimeInterval(-86400 * 7),
updatedAt: Date().addingTimeInterval(-86400 * 7)
),
AutomationRule(
id: "rule-002",
creatorId: "dev-user-001",
name: "Away Message",
isEnabled: false,
trigger: .offlineHours,
action: .sendAutoReply(message: "I'm currently unavailable. I'll respond during my next available hours."),
schedule: AutomationSchedule(
timezone: "Atlantic/Reykjavik",
activeDays: [.monday, .tuesday, .wednesday, .thursday, .friday],
activeStartTime: "09:00",
activeEndTime: "17:00"
),
conditions: [],
createdAt: Date().addingTimeInterval(-86400 * 3),
updatedAt: Date().addingTimeInterval(-86400 * 3)
),
]
func fetchRules() async throws -> [AutomationRule] {
try await Task.sleep(for: .milliseconds(300))
return automationRules
}
func toggleRule(ruleId: String, enabled: Bool) async throws -> AutomationRule {
try await Task.sleep(for: .milliseconds(200))
guard let index = automationRules.firstIndex(where: { $0.id == ruleId }) else {
throw URLError(.resourceUnavailable)
}
var rule = automationRules[index]
rule = AutomationRule(
id: rule.id, creatorId: rule.creatorId, name: rule.name,
isEnabled: enabled, trigger: rule.trigger, action: rule.action,
schedule: rule.schedule, conditions: rule.conditions,
createdAt: rule.createdAt, updatedAt: Date()
)
automationRules[index] = rule
return rule
}
func createRule(_ rule: AutomationRule) async throws -> AutomationRule {
try await Task.sleep(for: .milliseconds(300))
automationRules.append(rule)
return rule
}
func deleteRule(ruleId: String) async throws {
try await Task.sleep(for: .milliseconds(200))
automationRules.removeAll { $0.id == ruleId }
}
// MARK: - Inbox
func fetchThreads(archived: Bool) async throws -> [MessagingChatCore.Thread] {
try await Task.sleep(for: .milliseconds(300))