mirror of
https://github.com/home-assistant/iOS.git
synced 2026-02-21 13:24:03 -06:00
This is somewhat in prep of being able to make the project file generated, but also just organizes things into more concrete directory structures.
This pulls out _all_ of the build settings from the root level, and most from the target level, into xcconfigs.
The new directory structure looks like:
- Sources
- App
- (everything from HomeAssistant/)
- WatchApp
- Shared
- MacBridge
- Extensions
- Intents
- NotificationContent
- NotificationService
- Share
- Today
- Watch
- Widgets
- Tests
- App
- UI
- Shared
Somewhat intentionally, the file structure under these is not yet standardized/organized.
The project targets are now:
- App
- WatchApp
- Shared-iOS
- Shared-watchOS
- MacBridge
- Tests-App
- Tests-UI
- Tests-Shared
- Extension-Intents
- Extension-NotificationContent
- Extension-NotificationService
- Extension-Share
- Extension-Today
- Extension-Widget
- WatchExtension-Watch
This does not yet clean up resources vs. sources, nor does it handle some of the "it's in Sources/App but it's part of Shared" crossover directory issues.
48 lines
1.4 KiB
Swift
48 lines
1.4 KiB
Swift
//
|
|
// ClientEventStore.swift
|
|
// HomeAssistant
|
|
//
|
|
// Created by Stephan Vanterpool on 6/18/18.
|
|
// Copyright © 2018 Robbie Trencheny. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import RealmSwift
|
|
|
|
public struct ClientEventStore {
|
|
public var addEvent: (ClientEvent) -> Void = { event in
|
|
let realm = Current.realm()
|
|
do {
|
|
try realm.reentrantWrite {
|
|
realm.add(event)
|
|
}
|
|
} catch {
|
|
Current.Log.error("Error writing client event: \(error)")
|
|
}
|
|
|
|
Current.Log.info("\(event.type): \(event.text) \(event.jsonPayload ?? [:])")
|
|
}
|
|
|
|
public func getEvents(filter: String? = nil) -> AnyRealmCollection<ClientEvent> {
|
|
let realm = Current.realm()
|
|
let objects = realm.objects(ClientEvent.self).sorted(byKeyPath: "date", ascending: false)
|
|
if let filter = filter, filter.isEmpty == false {
|
|
return AnyRealmCollection(objects.filter(NSPredicate(format: "text contains[c] %@", filter)))
|
|
} else {
|
|
return AnyRealmCollection(objects)
|
|
}
|
|
}
|
|
|
|
public var clearAllEvents: () -> Void = {
|
|
let realm = Current.realm()
|
|
|
|
do {
|
|
try realm.reentrantWrite {
|
|
realm.delete(realm.objects(ClientEvent.self))
|
|
}
|
|
} catch {
|
|
Current.Log.error("Error writing client event: \(error)")
|
|
}
|
|
}
|
|
}
|