- Revamp whole DB to Display flow - Filter Pipeline, arbitrary filtering and sorting - Binary tree arrays for faster lookup & manipulation - DB: introducing custom functions - DB scheme: split req into heap & cache - cache written by GlassVPN only - heap written by Main App only - Introducing DB separation: DBCore, DBCommon, DBAppOnly - Introducing DB data sources: TestDataSource, GroupedDomainDataSource, RecordingsDB, DomainFilter - Background sync: Move entries from cache to heap and notify all observers - GlassVPN: Binary tree filter lookup - GlassVPN: Reusing prepared statement
41 lines
1.4 KiB
Swift
41 lines
1.4 KiB
Swift
import UIKit
|
|
|
|
extension GroupedDomain {
|
|
/// Return new `GroupedDomain` by adding `total` and `blocked` counts. Set `lastModified` to the maximum of the two.
|
|
static func +(a: GroupedDomain, b: GroupedDomain) -> Self {
|
|
GroupedDomain(domain: a.domain, total: a.total + b.total, blocked: a.blocked + b.blocked,
|
|
lastModified: max(a.lastModified, b.lastModified), options: a.options ?? b.options )
|
|
}
|
|
/// Return new `GroupedDomain` by subtracting `total` and `blocked` counts.
|
|
static func -(a: GroupedDomain, b: GroupedDomain) -> Self {
|
|
GroupedDomain(domain: a.domain, total: a.total - b.total, blocked: a.blocked - b.blocked,
|
|
lastModified: a.lastModified, options: a.options )
|
|
}
|
|
}
|
|
|
|
extension GroupedDomain {
|
|
var detailCellText: String { get {
|
|
return blocked > 0
|
|
? "\(lastModified.asDateTime()) — \(blocked)/\(total) blocked"
|
|
: "\(lastModified.asDateTime()) — \(total)"
|
|
}
|
|
}
|
|
}
|
|
|
|
extension FilterOptions {
|
|
func tableRowImage() -> UIImage? {
|
|
let blocked = contains(.blocked)
|
|
let ignored = contains(.ignored)
|
|
if blocked { return UIImage(named: ignored ? "block_ignore" : "shield-x") }
|
|
if ignored { return UIImage(named: "quicklook-not") }
|
|
return nil
|
|
}
|
|
}
|
|
|
|
extension Recording {
|
|
var fallbackTitle: String { get { "Unnamed Recording #\(id)" } }
|
|
var duration: Timestamp? { get { stop == nil ? nil : stop! - start } }
|
|
var durationString: String? { get { stop == nil ? nil : TimeFormat.from(duration!) } }
|
|
}
|
|
|