mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2025-02-03 02:37:37 +01:00
Remove more users (IOS-192)
This commit is contained in:
parent
255b6ab0ef
commit
dc53fbbe7c
@ -73,20 +73,10 @@ public final class Status: NSManagedObject {
|
|||||||
|
|
||||||
// many-to-one relationship
|
// many-to-one relationship
|
||||||
// sourcery: autoGenerateRelationship
|
// sourcery: autoGenerateRelationship
|
||||||
@NSManaged public private(set) var author: MastodonUser
|
|
||||||
// sourcery: autoGenerateRelationship
|
|
||||||
@NSManaged public private(set) var reblog: Status?
|
@NSManaged public private(set) var reblog: Status?
|
||||||
// sourcery: autoUpdatableObject
|
// sourcery: autoUpdatableObject
|
||||||
@NSManaged public private(set) var replyTo: Status?
|
@NSManaged public private(set) var replyTo: Status?
|
||||||
|
|
||||||
// many-to-many relationship
|
|
||||||
@NSManaged public private(set) var favouritedBy: Set<MastodonUser>
|
|
||||||
@NSManaged public private(set) var rebloggedBy: Set<MastodonUser>
|
|
||||||
@NSManaged public private(set) var mutedBy: Set<MastodonUser>
|
|
||||||
@NSManaged public private(set) var bookmarkedBy: Set<MastodonUser>
|
|
||||||
|
|
||||||
// one-to-one relationship
|
|
||||||
@NSManaged public private(set) var pinnedBy: MastodonUser?
|
|
||||||
// sourcery: autoGenerateRelationship
|
// sourcery: autoGenerateRelationship
|
||||||
@NSManaged public private(set) var poll: Poll?
|
@NSManaged public private(set) var poll: Poll?
|
||||||
// sourcery: autoGenerateRelationship
|
// sourcery: autoGenerateRelationship
|
||||||
@ -388,20 +378,17 @@ extension Status: AutoGenerateRelationship {
|
|||||||
// DO NOT EDIT
|
// DO NOT EDIT
|
||||||
public struct Relationship {
|
public struct Relationship {
|
||||||
public let application: Application?
|
public let application: Application?
|
||||||
public let author: MastodonUser
|
|
||||||
public let reblog: Status?
|
public let reblog: Status?
|
||||||
public let poll: Poll?
|
public let poll: Poll?
|
||||||
public let card: Card?
|
public let card: Card?
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
application: Application?,
|
application: Application?,
|
||||||
author: MastodonUser,
|
|
||||||
reblog: Status?,
|
reblog: Status?,
|
||||||
poll: Poll?,
|
poll: Poll?,
|
||||||
card: Card?
|
card: Card?
|
||||||
) {
|
) {
|
||||||
self.application = application
|
self.application = application
|
||||||
self.author = author
|
|
||||||
self.reblog = reblog
|
self.reblog = reblog
|
||||||
self.poll = poll
|
self.poll = poll
|
||||||
self.card = card
|
self.card = card
|
||||||
@ -410,7 +397,6 @@ extension Status: AutoGenerateRelationship {
|
|||||||
|
|
||||||
public func configure(relationship: Relationship) {
|
public func configure(relationship: Relationship) {
|
||||||
self.application = relationship.application
|
self.application = relationship.application
|
||||||
self.author = relationship.author
|
|
||||||
self.reblog = relationship.reblog
|
self.reblog = relationship.reblog
|
||||||
self.poll = relationship.poll
|
self.poll = relationship.poll
|
||||||
self.card = relationship.card
|
self.card = relationship.card
|
||||||
@ -536,54 +522,6 @@ extension Status: AutoUpdatableObject {
|
|||||||
}
|
}
|
||||||
// sourcery:end
|
// sourcery:end
|
||||||
|
|
||||||
public func update(liked: Bool, by mastodonUser: MastodonUser) {
|
|
||||||
if liked {
|
|
||||||
if !self.favouritedBy.contains(mastodonUser) {
|
|
||||||
self.mutableSetValue(forKey: #keyPath(Status.favouritedBy)).add(mastodonUser)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if self.favouritedBy.contains(mastodonUser) {
|
|
||||||
self.mutableSetValue(forKey: #keyPath(Status.favouritedBy)).remove(mastodonUser)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public func update(reblogged: Bool, by mastodonUser: MastodonUser) {
|
|
||||||
if reblogged {
|
|
||||||
if !self.rebloggedBy.contains(mastodonUser) {
|
|
||||||
self.mutableSetValue(forKey: #keyPath(Status.rebloggedBy)).add(mastodonUser)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if self.rebloggedBy.contains(mastodonUser) {
|
|
||||||
self.mutableSetValue(forKey: #keyPath(Status.rebloggedBy)).remove(mastodonUser)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public func update(muted: Bool, by mastodonUser: MastodonUser) {
|
|
||||||
if muted {
|
|
||||||
if !self.mutedBy.contains(mastodonUser) {
|
|
||||||
self.mutableSetValue(forKey: #keyPath(Status.mutedBy)).add(mastodonUser)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if self.mutedBy.contains(mastodonUser) {
|
|
||||||
self.mutableSetValue(forKey: #keyPath(Status.mutedBy)).remove(mastodonUser)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public func update(bookmarked: Bool, by mastodonUser: MastodonUser) {
|
|
||||||
if bookmarked {
|
|
||||||
if !self.bookmarkedBy.contains(mastodonUser) {
|
|
||||||
self.mutableSetValue(forKey: #keyPath(Status.bookmarkedBy)).add(mastodonUser)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if self.bookmarkedBy.contains(mastodonUser) {
|
|
||||||
self.mutableSetValue(forKey: #keyPath(Status.bookmarkedBy)).remove(mastodonUser)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public func update(isReveal: Bool) {
|
public func update(isReveal: Bool) {
|
||||||
revealedAt = isReveal ? Date() : nil
|
revealedAt = isReveal ? Date() : nil
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,6 @@ extension Persistence.Status {
|
|||||||
|
|
||||||
let relationship = Status.Relationship(
|
let relationship = Status.Relationship(
|
||||||
application: application,
|
application: application,
|
||||||
author: author,
|
|
||||||
reblog: reblog,
|
reblog: reblog,
|
||||||
poll: poll,
|
poll: poll,
|
||||||
card: card
|
card: card
|
||||||
@ -170,7 +169,6 @@ extension Persistence.Status {
|
|||||||
property: property,
|
property: property,
|
||||||
relationship: relationship
|
relationship: relationship
|
||||||
)
|
)
|
||||||
update(status: status, context: context)
|
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +212,6 @@ extension Persistence.Status {
|
|||||||
relationship:
|
relationship:
|
||||||
Status.Relationship(
|
Status.Relationship(
|
||||||
application: status.application,
|
application: status.application,
|
||||||
author: status.author,
|
|
||||||
reblog: status.reblog,
|
reblog: status.reblog,
|
||||||
poll: result.poll,
|
poll: result.poll,
|
||||||
card: status.card
|
card: status.card
|
||||||
@ -226,7 +223,6 @@ extension Persistence.Status {
|
|||||||
relationship:
|
relationship:
|
||||||
Status.Relationship(
|
Status.Relationship(
|
||||||
application: status.application,
|
application: status.application,
|
||||||
author: status.author,
|
|
||||||
reblog: status.reblog,
|
reblog: status.reblog,
|
||||||
poll: nil,
|
poll: nil,
|
||||||
card: status.card
|
card: status.card
|
||||||
@ -239,8 +235,6 @@ extension Persistence.Status {
|
|||||||
let relationship = Card.Relationship(status: status)
|
let relationship = Card.Relationship(status: status)
|
||||||
card?.configure(relationship: relationship)
|
card?.configure(relationship: relationship)
|
||||||
}
|
}
|
||||||
|
|
||||||
update(status: status, context: context)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func createCard(
|
private static func createCard(
|
||||||
@ -259,17 +253,6 @@ extension Persistence.Status {
|
|||||||
return result.card
|
return result.card
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func update(
|
|
||||||
status: Status,
|
|
||||||
context: PersistContext
|
|
||||||
) {
|
|
||||||
// update friendships
|
|
||||||
if let user = context.me {
|
|
||||||
context.entity.reblogged.flatMap { status.update(reblogged: $0, by: user) }
|
|
||||||
context.entity.favourited.flatMap { status.update(liked: $0, by: user) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static func createApplication(
|
private static func createApplication(
|
||||||
in managedObjectContext: NSManagedObjectContext,
|
in managedObjectContext: NSManagedObjectContext,
|
||||||
context: MastodonApplication.PersistContext
|
context: MastodonApplication.PersistContext
|
||||||
|
Loading…
x
Reference in New Issue
Block a user