import Foundation

final class SelectedContent: ObservableObject {

    @Published
    var language: ContentLanguage = .english

    @Published
    var tab: MainViewTab = .posts

    @Published
    var post: Post?

    @Published
    var page: Page?

    @Published
    var tag: Tag?

    @Published
    var file: FileResource?

    func remove(_ post: Post) {
        if self.post == post {
            self.post = nil
        }
    }

    func remove(_ page: Page) {
        if self.page == page {
            self.page = nil
        }
    }

    func remove(_ tag: Tag) {
        if self.tag == tag {
            self.tag = nil
        }
    }

    func remove(_ file: FileResource) {
        if self.file == file {
            self.file = nil
        }
    }
}
