Add status notification type and some properties on identity instance

This commit is contained in:
Justin Mazzocchi 2021-01-28 17:57:17 -08:00
parent 41cd030734
commit 08d4e43ddb
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
8 changed files with 20 additions and 6 deletions

View file

@ -24,6 +24,8 @@ public extension Identity {
public let streamingAPI: URL public let streamingAPI: URL
public let title: String public let title: String
public let thumbnail: URL? public let thumbnail: URL?
public let version: String
public let maxTootChars: Int?
} }
struct Account: Codable, Hashable { struct Account: Codable, Hashable {

View file

@ -9,9 +9,11 @@ extension IdentityDatabase {
migrator.registerMigration("0.1.0") { db in migrator.registerMigration("0.1.0") { db in
try db.create(table: "instance", ifNotExists: true) { t in try db.create(table: "instance", ifNotExists: true) { t in
t.column("uri", .text).primaryKey(onConflict: .replace) t.column("uri", .text).primaryKey(onConflict: .replace)
t.column("streamingAPI", .text) t.column("streamingAPI", .text).notNull()
t.column("title", .text) t.column("title", .text).notNull()
t.column("thumbnail", .text) t.column("thumbnail", .text)
t.column("version", .text).notNull()
t.column("maxTootChars", .integer)
} }
try db.create(table: "identityRecord", ifNotExists: true) { t in try db.create(table: "identityRecord", ifNotExists: true) { t in

View file

@ -70,7 +70,9 @@ public extension IdentityDatabase {
uri: instance.uri, uri: instance.uri,
streamingAPI: instance.urls.streamingApi, streamingAPI: instance.urls.streamingApi,
title: instance.title, title: instance.title,
thumbnail: instance.thumbnail) thumbnail: instance.thumbnail,
version: instance.version,
maxTootChars: instance.maxTootChars)
.save($0) .save($0)
try IdentityRecord try IdentityRecord
.filter(IdentityRecord.Columns.id == id) .filter(IdentityRecord.Columns.id == id)

View file

@ -144,6 +144,7 @@
"preferences.notification-types.reblog" = "Reblog"; "preferences.notification-types.reblog" = "Reblog";
"preferences.notification-types.mention" = "Mention"; "preferences.notification-types.mention" = "Mention";
"preferences.notification-types.poll" = "Poll"; "preferences.notification-types.poll" = "Poll";
"preferences.notification-types.status" = "Status";
"preferences.muted-users" = "Muted Users"; "preferences.muted-users" = "Muted Users";
"preferences.startup-and-syncing" = "Startup and Syncing"; "preferences.startup-and-syncing" = "Startup and Syncing";
"preferences.startup-and-syncing.home-timeline" = "Home timeline"; "preferences.startup-and-syncing.home-timeline" = "Home timeline";

View file

@ -27,4 +27,5 @@ public struct Instance: Codable, Hashable {
public let stats: Stats public let stats: Stats
public let thumbnail: URL? public let thumbnail: URL?
public let contactAccount: Account? public let contactAccount: Account?
public let maxTootChars: Int?
} }

View file

@ -9,6 +9,7 @@ public struct PushSubscription: Codable {
public var reblog: Bool public var reblog: Bool
public var mention: Bool public var mention: Bool
@DecodableDefault.True public var poll: Bool @DecodableDefault.True public var poll: Bool
@DecodableDefault.True public var status: Bool
} }
public let endpoint: URL public let endpoint: URL
@ -22,5 +23,6 @@ public extension PushSubscription.Alerts {
favourite: true, favourite: true,
reblog: true, reblog: true,
mention: true, mention: true,
poll: DecodableDefault.True()) poll: DecodableDefault.True(),
status: DecodableDefault.True())
} }

View file

@ -47,7 +47,8 @@ extension PushSubscriptionEndpoint: Endpoint {
"favourite": alerts.favourite, "favourite": alerts.favourite,
"reblog": alerts.reblog, "reblog": alerts.reblog,
"mention": alerts.mention, "mention": alerts.mention,
"poll": alerts.poll "poll": alerts.poll,
"status": alerts.status
]]] ]]]
case let .update(alerts): case let .update(alerts):
return ["data": return ["data":
@ -56,7 +57,8 @@ extension PushSubscriptionEndpoint: Endpoint {
"favourite": alerts.favourite, "favourite": alerts.favourite,
"reblog": alerts.reblog, "reblog": alerts.reblog,
"mention": alerts.mention, "mention": alerts.mention,
"poll": alerts.poll]]] "poll": alerts.poll,
"status": alerts.status]]]
default: return nil default: return nil
} }
} }

View file

@ -18,6 +18,8 @@ struct NotificationTypesPreferencesView: View {
isOn: $viewModel.pushSubscriptionAlerts.mention) isOn: $viewModel.pushSubscriptionAlerts.mention)
Toggle("preferences.notification-types.poll", Toggle("preferences.notification-types.poll",
isOn: $viewModel.pushSubscriptionAlerts.poll) isOn: $viewModel.pushSubscriptionAlerts.poll)
Toggle("preferences.notification-types.status",
isOn: $viewModel.pushSubscriptionAlerts.status)
} }
.navigationTitle("preferences.notification-types") .navigationTitle("preferences.notification-types")
.alertItem($viewModel.alertItem) .alertItem($viewModel.alertItem)