Impressia/Vernissage/Models/RelationshipModel.swift

125 lines
4.2 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
// Licensed under the Apache License 2.0.
//
import SwiftUI
import Foundation
import PixelfedKit
public class RelationshipModel: ObservableObject {
/// The account ID.
@Published public var id: EntityId
/// Are you followed by this user?
@Published public var followedBy: Bool
/// Is this user blocking you?
@Published public var blockedBy: Bool
/// Are you muting notifications from this user?
@Published public var mutingNotifications: Bool
/// Do you have a pending follow request for this user?
@Published public var requested: Bool
/// Are you receiving this users boosts in your home timeline?
@Published public var showingReblogs: Bool
/// Have you enabled notifications for this user?
@Published public var notifying: Bool
/// Are you blocking this users domain?
@Published public var domainBlocking: Bool
/// Are you featuring this user on your profile?
@Published public var endorsed: Bool
/// Which languages are you following from this user? Array of String (ISO 639-1 language two-letter code).
@Published public var languages: [String]?
/// This users profile bio.
@Published public var note: String?
/// Are you following this user?
@Published public var following: Bool
/// Are you blocking this user?
@Published public var blocking: Bool
/// Are you muting this user?
@Published public var muting: Bool
public init() {
self.id = ""
self.following = false
self.followedBy = false
self.blocking = false
self.blockedBy = false
self.muting = false
self.mutingNotifications = false
self.requested = false
self.showingReblogs = false
self.notifying = false
self.domainBlocking = false
self.endorsed = false
self.note = nil
self.languages = []
}
public init(relationship: Relationship) {
self.id = relationship.id
self.following = relationship.following
self.followedBy = relationship.followedBy
self.blocking = relationship.blocking
self.blockedBy = relationship.blockedBy
self.muting = relationship.muting
self.mutingNotifications = relationship.mutingNotifications
self.requested = relationship.requested
self.showingReblogs = relationship.showingReblogs
self.notifying = relationship.notifying
self.domainBlocking = relationship.domainBlocking
self.endorsed = relationship.endorsed
self.languages = relationship.languages
self.note = relationship.note
}
}
extension RelationshipModel {
public func update(relationship: Relationship) {
self.id = relationship.id
self.following = relationship.following
self.followedBy = relationship.followedBy
self.blocking = relationship.blocking
self.blockedBy = relationship.blockedBy
self.muting = relationship.muting
self.mutingNotifications = relationship.mutingNotifications
self.requested = relationship.requested
self.showingReblogs = relationship.showingReblogs
self.notifying = relationship.notifying
self.domainBlocking = relationship.domainBlocking
self.endorsed = relationship.endorsed
self.languages = relationship.languages
self.note = relationship.note
}
public func update(relationship: RelationshipModel) {
self.id = relationship.id
self.following = relationship.following
self.followedBy = relationship.followedBy
self.blocking = relationship.blocking
self.blockedBy = relationship.blockedBy
self.muting = relationship.muting
self.mutingNotifications = relationship.mutingNotifications
self.requested = relationship.requested
self.showingReblogs = relationship.showingReblogs
self.notifying = relationship.notifying
self.domainBlocking = relationship.domainBlocking
self.endorsed = relationship.endorsed
self.languages = relationship.languages
self.note = relationship.note
}
}