//
//  Preferences.swift
//  Pachyderm
//
//  Created by Shadowfacts on 10/26/23.
//

import Foundation

public struct Preferences: Codable, Sendable {
    public let postingDefaultVisibility: Visibility
    public let postingDefaultSensitive: Bool
    public let postingDefaultLanguage: String
    // Whether posts federate or not (local-only) on Hometown
    public let postingDefaultFederation: Bool?
    public let readingExpandMedia: ExpandMedia
    public let readingExpandSpoilers: Bool
    public let readingAutoplayGifs: Bool
    
    enum CodingKeys: String, CodingKey {
        case postingDefaultVisibility = "posting:default:visibility"
        case postingDefaultSensitive = "posting:default:sensitive"
        case postingDefaultLanguage = "posting:default:language"
        case postingDefaultFederation = "posting:default:federation"
        case readingExpandMedia = "reading:expand:media"
        case readingExpandSpoilers = "reading:expand:spoilers"
        case readingAutoplayGifs = "reading:autoplay:gifs"
    }
}

extension Preferences {
    public enum ExpandMedia: String, Codable, Sendable {
        case `default`
        case always = "show_all"
        case never = "hide_all"
    }
}
