Move required files to settings
This commit is contained in:
@ -27,7 +27,10 @@ final class GeneralSettings: ObservableObject {
|
||||
@Published
|
||||
var urlForPushNotification: String?
|
||||
|
||||
init(url: String, linkPreviewImageWidth: Int, linkPreviewImageHeight: Int, remoteUserForUpload: String, remotePortForUpload: Int, remotePathForUpload: String, urlForPushNotification: String?) {
|
||||
@Published
|
||||
var requiredFiles: [FileResource]
|
||||
|
||||
init(url: String, linkPreviewImageWidth: Int, linkPreviewImageHeight: Int, remoteUserForUpload: String, remotePortForUpload: Int, remotePathForUpload: String, urlForPushNotification: String?, requiredFiles: [FileResource]) {
|
||||
self.url = url
|
||||
self.linkPreviewImageWidth = linkPreviewImageWidth
|
||||
self.linkPreviewImageHeight = linkPreviewImageHeight
|
||||
@ -35,12 +38,13 @@ final class GeneralSettings: ObservableObject {
|
||||
self.remotePortForUpload = remotePortForUpload
|
||||
self.remotePathForUpload = remotePathForUpload
|
||||
self.urlForPushNotification = urlForPushNotification
|
||||
self.requiredFiles = requiredFiles
|
||||
}
|
||||
}
|
||||
|
||||
extension GeneralSettings {
|
||||
|
||||
convenience init(data: Data) {
|
||||
convenience init(context: LoadingContext, data: Data) {
|
||||
self.init(
|
||||
url: data.url,
|
||||
linkPreviewImageWidth: data.linkPreviewImageWidth,
|
||||
@ -48,7 +52,8 @@ extension GeneralSettings {
|
||||
remoteUserForUpload: data.remoteUserForUpload,
|
||||
remotePortForUpload: data.remotePortForUpload,
|
||||
remotePathForUpload: data.remotePathForUpload,
|
||||
urlForPushNotification: data.urlForPushNotification)
|
||||
urlForPushNotification: data.urlForPushNotification,
|
||||
requiredFiles: data.requiredFiles?.compactMap(context.file) ?? [])
|
||||
}
|
||||
|
||||
var data: Data {
|
||||
@ -59,7 +64,8 @@ extension GeneralSettings {
|
||||
remoteUserForUpload: remoteUserForUpload,
|
||||
remotePortForUpload: remotePortForUpload,
|
||||
remotePathForUpload: remotePathForUpload,
|
||||
urlForPushNotification: urlForPushNotification)
|
||||
urlForPushNotification: urlForPushNotification,
|
||||
requiredFiles: requiredFiles.nonEmpty?.map { $0.id }.sorted())
|
||||
}
|
||||
|
||||
struct Data: Codable, Equatable {
|
||||
@ -70,5 +76,6 @@ extension GeneralSettings {
|
||||
let remotePortForUpload: Int
|
||||
let remotePathForUpload: String
|
||||
let urlForPushNotification: String?
|
||||
let requiredFiles: [String]?
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ extension Settings {
|
||||
|
||||
convenience init(context: LoadingContext, data: Settings.Data) {
|
||||
self.init(
|
||||
general: .init(data: data.general),
|
||||
general: .init(context: context, data: data.general),
|
||||
paths: .init(data: data.paths),
|
||||
navigation: .init(context: context, data: data.navigation),
|
||||
posts: .init(context: context, data: data.posts),
|
||||
@ -112,7 +112,8 @@ extension GeneralSettings {
|
||||
remoteUserForUpload: "user",
|
||||
remotePortForUpload: 22,
|
||||
remotePathForUpload: "/home/user/web",
|
||||
urlForPushNotification: nil)
|
||||
urlForPushNotification: nil,
|
||||
requiredFiles: [])
|
||||
}
|
||||
|
||||
extension AudioPlayerSettings {
|
||||
|
Reference in New Issue
Block a user