mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-14 09:13:25 +01:00
News: fix duplicate news items from multiple SideStore release channel sources
This commit is contained in:
committed by
Spidy123222
parent
d853791ad2
commit
f2b555beae
@@ -103,6 +103,7 @@
|
|||||||
<attribute name="externalURL" optional="YES" attributeType="URI"/>
|
<attribute name="externalURL" optional="YES" attributeType="URI"/>
|
||||||
<attribute name="identifier" attributeType="String"/>
|
<attribute name="identifier" attributeType="String"/>
|
||||||
<attribute name="imageURL" optional="YES" attributeType="URI"/>
|
<attribute name="imageURL" optional="YES" attributeType="URI"/>
|
||||||
|
<attribute name="isDuplicate" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
|
||||||
<attribute name="isSilent" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES"/>
|
<attribute name="isSilent" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES"/>
|
||||||
<attribute name="sortIndex" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
<attribute name="sortIndex" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||||
<attribute name="sourceIdentifier" optional="YES" attributeType="String"/>
|
<attribute name="sourceIdentifier" optional="YES" attributeType="String"/>
|
||||||
|
|||||||
@@ -32,6 +32,15 @@ public class NewsItem: NSManagedObject, Decodable, Fetchable
|
|||||||
@NSManaged public var storeApp: StoreApp?
|
@NSManaged public var storeApp: StoreApp?
|
||||||
@NSManaged public var source: Source?
|
@NSManaged public var source: Source?
|
||||||
|
|
||||||
|
@objc public var isDuplicate: Bool {
|
||||||
|
if self.source == nil { return false }
|
||||||
|
|
||||||
|
// Hide news from sources that begin with the SideStore identifier, and aren't from the same source as the current SideStore source
|
||||||
|
if self.source!.identifier.starts(with: Bundle.Info.appbundleIdentifier) && self.source!.identifier != Source.altStoreIdentifier { return true }
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey
|
private enum CodingKeys: String, CodingKey
|
||||||
{
|
{
|
||||||
case identifier
|
case identifier
|
||||||
@@ -86,6 +95,9 @@ public extension NewsItem
|
|||||||
{
|
{
|
||||||
@nonobjc class func fetchRequest() -> NSFetchRequest<NewsItem>
|
@nonobjc class func fetchRequest() -> NSFetchRequest<NewsItem>
|
||||||
{
|
{
|
||||||
return NSFetchRequest<NewsItem>(entityName: "NewsItem")
|
let fetchRequest = NSFetchRequest<NewsItem>(entityName: "NewsItem")
|
||||||
|
fetchRequest.predicate = NSPredicate(format: "%K == NO",
|
||||||
|
#keyPath(NewsItem.isDuplicate))
|
||||||
|
return fetchRequest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user