Update GRDB

This commit is contained in:
Justin Mazzocchi 2022-11-07 19:32:34 -08:00
parent fceec62370
commit aa9df5356a
4 changed files with 16 additions and 14 deletions

View file

@ -14,7 +14,7 @@ let package = Package(
targets: ["DB"])
],
dependencies: [
.package(name: "GRDB", url: "https://github.com/metabolist/GRDB.swift.git", .revision("c326f8b")),
.package(name: "GRDB", url: "https://github.com/metabolist/GRDB.swift.git", .revision("a6ff285")),
.package(path: "Mastodon"),
.package(path: "Secrets")
],

View file

@ -21,7 +21,7 @@ public struct ContentDatabase {
self.id = id
if inMemory {
databaseWriter = DatabaseQueue()
databaseWriter = try DatabaseQueue()
try Self.migrator.migrate(databaseWriter)
} else {
databaseWriter = try DatabasePool.withFileCoordinator(
@ -325,7 +325,7 @@ public extension ContentDatabase {
}
func createList(_ list: List) -> AnyPublisher<Never, Error> {
databaseWriter.mutatingPublisher(updates: TimelineRecord(timeline: Timeline.list(list)).save)
databaseWriter.mutatingPublisher{ try TimelineRecord(timeline: Timeline.list(list)).save($0) }
}
func deleteList(id: List.Id) -> AnyPublisher<Never, Error> {
@ -343,7 +343,7 @@ public extension ContentDatabase {
}
func createFilter(_ filter: Filter) -> AnyPublisher<Never, Error> {
databaseWriter.mutatingPublisher(updates: filter.save)
databaseWriter.mutatingPublisher { try filter.save($0) }
}
func deleteFilter(id: Filter.Id) -> AnyPublisher<Never, Error> {
@ -351,7 +351,7 @@ public extension ContentDatabase {
}
func setLastReadId(_ id: String, timelineId: Timeline.Id) -> AnyPublisher<Never, Error> {
databaseWriter.mutatingPublisher(updates: LastReadIdRecord(timelineId: timelineId, id: id).save)
databaseWriter.mutatingPublisher { try LastReadIdRecord(timelineId: timelineId, id: id).save($0) }
}
func insert(notifications: [MastodonNotification]) -> AnyPublisher<Never, Error> {

View file

@ -16,7 +16,7 @@ public struct IdentityDatabase {
public init(inMemory: Bool, appGroup: String, keychain: Keychain.Type) throws {
if inMemory {
databaseWriter = DatabaseQueue()
databaseWriter = try DatabaseQueue()
try Self.migrator.migrate(databaseWriter)
} else {
let url = try FileManager.default.databaseDirectoryURL(
@ -32,8 +32,8 @@ public struct IdentityDatabase {
public extension IdentityDatabase {
func createIdentity(id: Identity.Id, url: URL, authenticated: Bool, pending: Bool) -> AnyPublisher<Never, Error> {
databaseWriter.mutatingPublisher(
updates: IdentityRecord(
databaseWriter.mutatingPublisher {
try IdentityRecord(
id: id,
url: url,
authenticated: authenticated,
@ -43,7 +43,8 @@ public extension IdentityDatabase {
instanceURI: nil,
lastRegisteredDeviceToken: nil,
pushSubscriptionAlerts: .initial)
.save)
.save($0)
}
}
func deleteIdentity(id: Identity.Id) -> AnyPublisher<Never, Error> {
@ -75,8 +76,8 @@ public extension IdentityDatabase {
}
func updateAccount(_ account: Account, id: Identity.Id) -> AnyPublisher<Never, Error> {
databaseWriter.mutatingPublisher(
updates: Identity.Account(
databaseWriter.mutatingPublisher {
try Identity.Account(
id: account.id,
identityId: id,
username: account.username,
@ -88,7 +89,8 @@ public extension IdentityDatabase {
headerStatic: account.headerStatic,
emojis: account.emojis,
followRequestCount: account.source?.followRequestsCount ?? 0)
.save)
.save($0)
}
}
func confirmIdentity(id: Identity.Id) -> AnyPublisher<Never, Error> {

View file

@ -41,8 +41,8 @@
"package": "GRDB",
"repositoryURL": "https://github.com/metabolist/GRDB.swift.git",
"state": {
"branch": "c326f8b",
"revision": "c326f8bf11ada58f1958e11ae151802c78142f42",
"branch": "a6ff285",
"revision": "a6ff285eb1b0f8933c610b82e8d6ca7093fd7997",
"version": null
}
},