Fix remotely deleted feeds not being removed

This commit is contained in:
Shadowfacts 2022-01-19 18:30:49 -05:00
parent c89df7604b
commit ed0a2f1ba3
2 changed files with 4 additions and 1 deletions

View File

@ -91,6 +91,9 @@ class PersistentContainer: NSPersistentContainer {
mo.updateFromServer(feed) mo.updateFromServer(feed)
} }
} }
for removed in existingFeeds where !serverFeeds.contains(where: { $0.id == removed.id }) {
self.backgroundContext.delete(removed)
}
if self.backgroundContext.hasChanges { if self.backgroundContext.hasChanges {
try self.backgroundContext.save() try self.backgroundContext.save()

View File

@ -6,7 +6,7 @@
<attribute name="title" attributeType="String"/> <attribute name="title" attributeType="String"/>
<attribute name="url" optional="YES" attributeType="URI"/> <attribute name="url" optional="YES" attributeType="URI"/>
<relationship name="groups" toMany="YES" deletionRule="Nullify" destinationEntity="Group" inverseName="feeds" inverseEntity="Group"/> <relationship name="groups" toMany="YES" deletionRule="Nullify" destinationEntity="Group" inverseName="feeds" inverseEntity="Group"/>
<relationship name="items" toMany="YES" deletionRule="Nullify" destinationEntity="Item" inverseName="feed" inverseEntity="Item"/> <relationship name="items" toMany="YES" deletionRule="Cascade" destinationEntity="Item" inverseName="feed" inverseEntity="Item"/>
</entity> </entity>
<entity name="Group" representedClassName="Group" syncable="YES"> <entity name="Group" representedClassName="Group" syncable="YES">
<attribute name="id" attributeType="String"/> <attribute name="id" attributeType="String"/>