From f2b555beae5cb1b4d96dd4e98f3e98fd81bcbed5 Mon Sep 17 00:00:00 2001
From: naturecodevoid <44983869+naturecodevoid@users.noreply.github.com>
Date: Thu, 2 Feb 2023 07:35:24 -0800
Subject: [PATCH] News: fix duplicate news items from multiple SideStore
release channel sources
---
.../AltStore 11.xcdatamodel/contents | 1 +
AltStoreCore/Model/NewsItem.swift | 14 +++++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 11.xcdatamodel/contents b/AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 11.xcdatamodel/contents
index cceed50f..94c3b425 100644
--- a/AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 11.xcdatamodel/contents
+++ b/AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 11.xcdatamodel/contents
@@ -103,6 +103,7 @@
+
diff --git a/AltStoreCore/Model/NewsItem.swift b/AltStoreCore/Model/NewsItem.swift
index 22e86eb8..62fdb9db 100644
--- a/AltStoreCore/Model/NewsItem.swift
+++ b/AltStoreCore/Model/NewsItem.swift
@@ -32,6 +32,15 @@ public class NewsItem: NSManagedObject, Decodable, Fetchable
@NSManaged public var storeApp: StoreApp?
@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
{
case identifier
@@ -86,6 +95,9 @@ public extension NewsItem
{
@nonobjc class func fetchRequest() -> NSFetchRequest
{
- return NSFetchRequest(entityName: "NewsItem")
+ let fetchRequest = NSFetchRequest(entityName: "NewsItem")
+ fetchRequest.predicate = NSPredicate(format: "%K == NO",
+ #keyPath(NewsItem.isDuplicate))
+ return fetchRequest
}
}