From 9ce3e733161b090ad2388f0807f5f624a2ad3b6a Mon Sep 17 00:00:00 2001 From: Nate Weaver Date: Tue, 3 Dec 2019 13:16:30 -0600 Subject: [PATCH 1/2] Update RSCore (IPv6 fix.) --- submodules/RSCore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/RSCore b/submodules/RSCore index d70c24feb..07ee91394 160000 --- a/submodules/RSCore +++ b/submodules/RSCore @@ -1 +1 @@ -Subproject commit d70c24feb4bdad8fdbe7e0beb6edd12d3383c7dc +Subproject commit 07ee91394d442ba3a2c4cc5b155a0839809b58b7 From 3ead2c63bc8e06090fb94d5dad461efbddd144b3 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 3 Dec 2019 23:03:15 -0800 Subject: [PATCH 2/2] =?UTF-8?q?Remove=20attachments=20from=20the=20app,=20?= =?UTF-8?q?since=20we=E2=80=99re=20not=20using=20attachments=20in=20any=20?= =?UTF-8?q?way.=20We=20could=20always=20add=20it=20back=20later.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frameworks/Articles/Article.swift | 4 +- .../Articles.xcodeproj/project.pbxproj | 4 - Frameworks/Articles/Attachment.swift | 54 ----------- .../ArticlesDatabase/ArticlesDatabase.swift | 5 +- .../project.pbxproj | 8 -- .../ArticlesDatabase/ArticlesTable.swift | 15 +--- .../ArticlesDatabase/AttachmentsTable.swift | 32 ------- Frameworks/ArticlesDatabase/Constants.swift | 10 --- .../DatabaseObject+Database.swift | 5 -- .../Extensions/Article+Database.swift | 9 +- .../Extensions/Attachment+Database.swift | 90 ------------------- .../RelatedObjectsMap+Database.swift | 7 -- .../Timeline/ArticlePasteboardWriter.swift | 29 ------ .../Timeline/TimelineViewController.swift | 2 +- .../MasterTimelineViewController.swift | 2 +- 15 files changed, 10 insertions(+), 266 deletions(-) delete mode 100644 Frameworks/Articles/Attachment.swift delete mode 100644 Frameworks/ArticlesDatabase/AttachmentsTable.swift delete mode 100644 Frameworks/ArticlesDatabase/Extensions/Attachment+Database.swift diff --git a/Frameworks/Articles/Article.swift b/Frameworks/Articles/Article.swift index cd40d5cb6..1ecabe1cc 100644 --- a/Frameworks/Articles/Article.swift +++ b/Frameworks/Articles/Article.swift @@ -27,10 +27,9 @@ public struct Article: Hashable { public let datePublished: Date? public let dateModified: Date? public let authors: Set? - public let attachments: Set? public let status: ArticleStatus - public init(accountID: String, articleID: String?, feedID: String, uniqueID: String, title: String?, contentHTML: String?, contentText: String?, url: String?, externalURL: String?, summary: String?, imageURL: String?, bannerImageURL: String?, datePublished: Date?, dateModified: Date?, authors: Set?, attachments: Set?, status: ArticleStatus) { + public init(accountID: String, articleID: String?, feedID: String, uniqueID: String, title: String?, contentHTML: String?, contentText: String?, url: String?, externalURL: String?, summary: String?, imageURL: String?, bannerImageURL: String?, datePublished: Date?, dateModified: Date?, authors: Set?, status: ArticleStatus) { self.accountID = accountID self.feedID = feedID @@ -46,7 +45,6 @@ public struct Article: Hashable { self.datePublished = datePublished self.dateModified = dateModified self.authors = authors - self.attachments = attachments self.status = status if let articleID = articleID { diff --git a/Frameworks/Articles/Articles.xcodeproj/project.pbxproj b/Frameworks/Articles/Articles.xcodeproj/project.pbxproj index 8d3c4dfb9..0946acc48 100644 --- a/Frameworks/Articles/Articles.xcodeproj/project.pbxproj +++ b/Frameworks/Articles/Articles.xcodeproj/project.pbxproj @@ -12,7 +12,6 @@ 844BEE6A1F0AB3C9004AB7CD /* DataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE691F0AB3C9004AB7CD /* DataTests.swift */; }; 844BEE7F1F0AB4CA004AB7CD /* Article.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE7E1F0AB4CA004AB7CD /* Article.swift */; }; 844BEE811F0AB4D0004AB7CD /* Author.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE801F0AB4D0004AB7CD /* Author.swift */; }; - 844BEE831F0AB4D6004AB7CD /* Attachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE821F0AB4D6004AB7CD /* Attachment.swift */; }; 844BEE851F0AB4DB004AB7CD /* ArticleStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844BEE841F0AB4DB004AB7CD /* ArticleStatus.swift */; }; 848E3EB420FBCFAE0004B7ED /* RSCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 848E3EB320FBCFAE0004B7ED /* RSCore.framework */; }; /* End PBXBuildFile section */ @@ -57,7 +56,6 @@ 844BEE761F0AB444004AB7CD /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 844BEE7E1F0AB4CA004AB7CD /* Article.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Article.swift; sourceTree = ""; }; 844BEE801F0AB4D0004AB7CD /* Author.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Author.swift; sourceTree = ""; }; - 844BEE821F0AB4D6004AB7CD /* Attachment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Attachment.swift; sourceTree = ""; }; 844BEE841F0AB4DB004AB7CD /* ArticleStatus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArticleStatus.swift; sourceTree = ""; }; 844BEE9C1F0AB512004AB7CD /* RSCore.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSCore.xcodeproj; path = ../RSCore/RSCore.xcodeproj; sourceTree = ""; }; 848E3EB320FBCFAE0004B7ED /* RSCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = RSCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -94,7 +92,6 @@ children = ( 844BEE7E1F0AB4CA004AB7CD /* Article.swift */, 844BEE801F0AB4D0004AB7CD /* Author.swift */, - 844BEE821F0AB4D6004AB7CD /* Attachment.swift */, 844BEE841F0AB4DB004AB7CD /* ArticleStatus.swift */, 840405C91F1A8E4300DF0296 /* DatabaseID.swift */, 844BEE761F0AB444004AB7CD /* Info.plist */, @@ -300,7 +297,6 @@ buildActionMask = 2147483647; files = ( 844BEE7F1F0AB4CA004AB7CD /* Article.swift in Sources */, - 844BEE831F0AB4D6004AB7CD /* Attachment.swift in Sources */, 844BEE811F0AB4D0004AB7CD /* Author.swift in Sources */, 840405CA1F1A8E4300DF0296 /* DatabaseID.swift in Sources */, 844BEE851F0AB4DB004AB7CD /* ArticleStatus.swift in Sources */, diff --git a/Frameworks/Articles/Attachment.swift b/Frameworks/Articles/Attachment.swift deleted file mode 100644 index 8fab1b317..000000000 --- a/Frameworks/Articles/Attachment.swift +++ /dev/null @@ -1,54 +0,0 @@ -// -// Attachment.swift -// NetNewsWire -// -// Created by Brent Simmons on 7/1/17. -// Copyright © 2017 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -public struct Attachment: Hashable { - - public let attachmentID: String // Calculated - public let url: String - public let mimeType: String? - public let title: String? - public let sizeInBytes: Int? - public let durationInSeconds: Int? - - public init(attachmentID: String?, url: String, mimeType: String?, title: String?, sizeInBytes: Int?, durationInSeconds: Int?) { - - self.url = url - self.mimeType = mimeType - self.title = title - if let sizeInBytes = sizeInBytes, sizeInBytes > 0 { - self.sizeInBytes = sizeInBytes - } - else { - self.sizeInBytes = nil - } - if let durationInSeconds = durationInSeconds, durationInSeconds > 0 { - self.durationInSeconds = durationInSeconds - } - else { - self.durationInSeconds = nil - } - - if let attachmentID = attachmentID { - self.attachmentID = attachmentID - } - else { - var s = url - s += mimeType ?? "" - s += title ?? "" - if let sizeInBytes = sizeInBytes { - s += "\(sizeInBytes)" - } - if let durationInSeconds = durationInSeconds { - s += "\(durationInSeconds)" - } - self.attachmentID = databaseIDWithString(s) - } - } -} diff --git a/Frameworks/ArticlesDatabase/ArticlesDatabase.swift b/Frameworks/ArticlesDatabase/ArticlesDatabase.swift index 262d76ec2..d49d89e82 100644 --- a/Frameworks/ArticlesDatabase/ArticlesDatabase.swift +++ b/Frameworks/ArticlesDatabase/ArticlesDatabase.swift @@ -41,7 +41,7 @@ public final class ArticlesDatabase { database.executeStatements("ALTER TABLE articles add column searchRowID INTEGER;") } database.executeStatements("CREATE INDEX if not EXISTS articles_searchRowID on articles(searchRowID);") - database.executeStatements("DROP TABLE if EXISTS tags;DROP INDEX if EXISTS tags_tagName_index;DROP INDEX if EXISTS articles_feedID_index;DROP INDEX if EXISTS statuses_read_index;") + database.executeStatements("DROP TABLE if EXISTS tags;DROP INDEX if EXISTS tags_tagName_index;DROP INDEX if EXISTS articles_feedID_index;DROP INDEX if EXISTS statuses_read_index;DROP TABLE if EXISTS attachments;DROP TABLE if EXISTS attachmentsLookup;") } queue.vacuumIfNeeded(daysBetweenVacuums: 9) @@ -196,9 +196,6 @@ private extension ArticlesDatabase { CREATE TABLE if not EXISTS authors (authorID TEXT NOT NULL PRIMARY KEY, name TEXT, url TEXT, avatarURL TEXT, emailAddress TEXT); CREATE TABLE if not EXISTS authorsLookup (authorID TEXT NOT NULL, articleID TEXT NOT NULL, PRIMARY KEY(authorID, articleID)); - CREATE TABLE if not EXISTS attachments(attachmentID TEXT NOT NULL PRIMARY KEY, url TEXT NOT NULL, mimeType TEXT, title TEXT, sizeInBytes INTEGER, durationInSeconds INTEGER); - CREATE TABLE if not EXISTS attachmentsLookup(attachmentID TEXT NOT NULL, articleID TEXT NOT NULL, PRIMARY KEY(attachmentID, articleID)); - CREATE INDEX if not EXISTS articles_feedID_datePublished_articleID on articles (feedID, datePublished, articleID); CREATE INDEX if not EXISTS statuses_starred_index on statuses (starred); diff --git a/Frameworks/ArticlesDatabase/ArticlesDatabase.xcodeproj/project.pbxproj b/Frameworks/ArticlesDatabase/ArticlesDatabase.xcodeproj/project.pbxproj index aeb7db758..d19d892fe 100644 --- a/Frameworks/ArticlesDatabase/ArticlesDatabase.xcodeproj/project.pbxproj +++ b/Frameworks/ArticlesDatabase/ArticlesDatabase.xcodeproj/project.pbxproj @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ 51C451FF2264CF2100C03939 /* RSParser.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51C451FE2264CF2100C03939 /* RSParser.framework */; }; - 840405CF1F1A963700DF0296 /* AttachmentsTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840405CE1F1A963700DF0296 /* AttachmentsTable.swift */; }; 841D4D742106B59F00DD04E6 /* Articles.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 841D4D732106B59F00DD04E6 /* Articles.framework */; }; 84288A001F6A3C4400395871 /* DatabaseObject+Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842889FF1F6A3C4400395871 /* DatabaseObject+Database.swift */; }; 84288A021F6A3D8000395871 /* RelatedObjectsMap+Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84288A011F6A3D8000395871 /* RelatedObjectsMap+Database.swift */; }; @@ -21,7 +20,6 @@ 845580671F0AEBCD003CCFA1 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845580661F0AEBCD003CCFA1 /* Constants.swift */; }; 845580761F0AF670003CCFA1 /* Article+Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845580751F0AF670003CCFA1 /* Article+Database.swift */; }; 8455807A1F0AF67D003CCFA1 /* ArticleStatus+Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845580791F0AF67D003CCFA1 /* ArticleStatus+Database.swift */; }; - 8455807C1F0C0DBD003CCFA1 /* Attachment+Database.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8455807B1F0C0DBD003CCFA1 /* Attachment+Database.swift */; }; 8477ACBC2221E76F00DF7F37 /* SearchTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8477ACBB2221E76F00DF7F37 /* SearchTable.swift */; }; 848E3EB920FBCFD20004B7ED /* RSCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 848E3EB820FBCFD20004B7ED /* RSCore.framework */; }; 848E3EBD20FBCFDE0004B7ED /* RSDatabase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 848E3EBC20FBCFDE0004B7ED /* RSDatabase.framework */; }; @@ -113,7 +111,6 @@ /* Begin PBXFileReference section */ 51C451FE2264CF2100C03939 /* RSParser.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = RSParser.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 840405CE1F1A963700DF0296 /* AttachmentsTable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttachmentsTable.swift; sourceTree = ""; }; 841D4D732106B59F00DD04E6 /* Articles.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Articles.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 842889FF1F6A3C4400395871 /* DatabaseObject+Database.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DatabaseObject+Database.swift"; sourceTree = ""; }; 84288A011F6A3D8000395871 /* RelatedObjectsMap+Database.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RelatedObjectsMap+Database.swift"; sourceTree = ""; }; @@ -127,7 +124,6 @@ 845580661F0AEBCD003CCFA1 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; 845580751F0AF670003CCFA1 /* Article+Database.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Article+Database.swift"; path = "Extensions/Article+Database.swift"; sourceTree = ""; }; 845580791F0AF67D003CCFA1 /* ArticleStatus+Database.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "ArticleStatus+Database.swift"; path = "Extensions/ArticleStatus+Database.swift"; sourceTree = ""; }; - 8455807B1F0C0DBD003CCFA1 /* Attachment+Database.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Attachment+Database.swift"; path = "Extensions/Attachment+Database.swift"; sourceTree = ""; }; 8461461E1F0ABC7300870CB3 /* RSParser.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSParser.xcodeproj; path = ../RSParser/RSParser.xcodeproj; sourceTree = ""; }; 8477ACBB2221E76F00DF7F37 /* SearchTable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchTable.swift; sourceTree = ""; }; 848E3EB820FBCFD20004B7ED /* RSCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = RSCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -182,7 +178,6 @@ 843577151F744FC800F460AE /* DatabaseArticle.swift */, 84E156ED1F0AB81400F8CC05 /* StatusesTable.swift */, 84F20F8E1F180D8700D8E682 /* AuthorsTable.swift */, - 840405CE1F1A963700DF0296 /* AttachmentsTable.swift */, 8461462A1F0AC44100870CB3 /* Extensions */, 84E156E81F0AB75600F8CC05 /* Info.plist */, 844BEE441F0AB3AB004AB7CD /* DatabaseTests */, @@ -228,7 +223,6 @@ 843702C21F70D15D00B18807 /* ParsedArticle+Database.swift */, 845580791F0AF67D003CCFA1 /* ArticleStatus+Database.swift */, 84F20F901F1810DD00D8E682 /* Author+Database.swift */, - 8455807B1F0C0DBD003CCFA1 /* Attachment+Database.swift */, 842889FF1F6A3C4400395871 /* DatabaseObject+Database.swift */, 84288A011F6A3D8000395871 /* RelatedObjectsMap+Database.swift */, ); @@ -500,9 +494,7 @@ 843CB9961F34174100EE6581 /* Author+Database.swift in Sources */, 845580761F0AF670003CCFA1 /* Article+Database.swift in Sources */, 8455807A1F0AF67D003CCFA1 /* ArticleStatus+Database.swift in Sources */, - 8455807C1F0C0DBD003CCFA1 /* Attachment+Database.swift in Sources */, 84288A021F6A3D8000395871 /* RelatedObjectsMap+Database.swift in Sources */, - 840405CF1F1A963700DF0296 /* AttachmentsTable.swift in Sources */, 84F20F8F1F180D8700D8E682 /* AuthorsTable.swift in Sources */, 84288A001F6A3C4400395871 /* DatabaseObject+Database.swift in Sources */, 8477ACBC2221E76F00DF7F37 /* SearchTable.swift in Sources */, diff --git a/Frameworks/ArticlesDatabase/ArticlesTable.swift b/Frameworks/ArticlesDatabase/ArticlesTable.swift index ccb912ffa..0afc9bb74 100644 --- a/Frameworks/ArticlesDatabase/ArticlesTable.swift +++ b/Frameworks/ArticlesDatabase/ArticlesTable.swift @@ -19,7 +19,6 @@ final class ArticlesTable: DatabaseTable { private let queue: DatabaseQueue private let statusesTable: StatusesTable private let authorsLookupTable: DatabaseLookupTable - private let attachmentsLookupTable: DatabaseLookupTable private var databaseArticlesCache = [String: DatabaseArticle]() private lazy var searchTable: SearchTable = { @@ -41,9 +40,6 @@ final class ArticlesTable: DatabaseTable { let authorsTable = AuthorsTable(name: DatabaseTableName.authors) self.authorsLookupTable = DatabaseLookupTable(name: DatabaseTableName.authorsLookup, objectIDKey: DatabaseKey.articleID, relatedObjectIDKey: DatabaseKey.authorID, relatedTable: authorsTable, relationshipName: RelationshipName.authors) - - let attachmentsTable = AttachmentsTable(name: DatabaseTableName.attachments) - self.attachmentsLookupTable = DatabaseLookupTable(name: DatabaseTableName.attachmentsLookup, objectIDKey: DatabaseKey.articleID, relatedObjectIDKey: DatabaseKey.attachmentID, relatedTable: attachmentsTable, relationshipName: RelationshipName.attachments) } // MARK: - Fetching Articles for Feed @@ -490,24 +486,22 @@ private extension ArticlesTable { // 2. Fetch related objects. let authorsMap = authorsLookupTable.fetchRelatedObjects(for: articleIDs, in: database) - let attachmentsMap = attachmentsLookupTable.fetchRelatedObjects(for: articleIDs, in: database) // 3. Create articles with related objects. let articles = databaseArticles.map { (databaseArticle) -> Article in - return articleWithDatabaseArticle(databaseArticle, authorsMap, attachmentsMap) + return articleWithDatabaseArticle(databaseArticle, authorsMap) } return Set(articles) } - func articleWithDatabaseArticle(_ databaseArticle: DatabaseArticle, _ authorsMap: RelatedObjectsMap?, _ attachmentsMap: RelatedObjectsMap?) -> Article { + func articleWithDatabaseArticle(_ databaseArticle: DatabaseArticle, _ authorsMap: RelatedObjectsMap?) -> Article { let articleID = databaseArticle.articleID let authors = authorsMap?.authors(for: articleID) - let attachments = attachmentsMap?.attachments(for: articleID) - return Article(databaseArticle: databaseArticle, accountID: accountID, authors: authors, attachments: attachments) + return Article(databaseArticle: databaseArticle, accountID: accountID, authors: authors) } func makeDatabaseArticles(with resultSet: FMResultSet) -> Set { @@ -656,9 +650,7 @@ private extension ArticlesTable { func saveRelatedObjectsForNewArticles(_ articles: Set
, _ database: FMDatabase) { let databaseObjects = articles.databaseObjects() - authorsLookupTable.saveRelatedObjects(for: databaseObjects, in: database) - attachmentsLookupTable.saveRelatedObjects(for: databaseObjects, in: database) } // MARK: - Updating Existing Articles @@ -682,7 +674,6 @@ private extension ArticlesTable { func saveUpdatedRelatedObjects(_ updatedArticles: Set
, _ fetchedArticles: [String: Article], _ database: FMDatabase) { updateRelatedObjects(\Article.authors, updatedArticles, fetchedArticles, authorsLookupTable, database) - updateRelatedObjects(\Article.attachments, updatedArticles, fetchedArticles, attachmentsLookupTable, database) } func findUpdatedArticles(_ incomingArticles: Set
, _ fetchedArticlesDictionary: [String: Article]) -> Set
? { diff --git a/Frameworks/ArticlesDatabase/AttachmentsTable.swift b/Frameworks/ArticlesDatabase/AttachmentsTable.swift deleted file mode 100644 index 0a6067503..000000000 --- a/Frameworks/ArticlesDatabase/AttachmentsTable.swift +++ /dev/null @@ -1,32 +0,0 @@ -// -// AttachmentsTable.swift -// NetNewsWire -// -// Created by Brent Simmons on 7/15/17. -// Copyright © 2017 Ranchero Software. All rights reserved. -// - -import Foundation -import RSDatabase -import Articles - -final class AttachmentsTable: DatabaseRelatedObjectsTable { - - let name: String - let databaseIDKey = DatabaseKey.attachmentID - var cache = DatabaseObjectCache() - - init(name: String) { - self.name = name - } - - // MARK: - DatabaseRelatedObjectsTable - - func objectWithRow(_ row: FMResultSet) -> DatabaseObject? { - if let attachment = Attachment(row: row) { - return attachment as DatabaseObject - } - return nil - } -} - diff --git a/Frameworks/ArticlesDatabase/Constants.swift b/Frameworks/ArticlesDatabase/Constants.swift index e7b13b08e..44e19ef00 100644 --- a/Frameworks/ArticlesDatabase/Constants.swift +++ b/Frameworks/ArticlesDatabase/Constants.swift @@ -16,8 +16,6 @@ struct DatabaseTableName { static let authors = "authors" static let authorsLookup = "authorsLookup" static let statuses = "statuses" - static let attachments = "attachments" - static let attachmentsLookup = "attachmentsLookup" } struct DatabaseKey { @@ -39,7 +37,6 @@ struct DatabaseKey { static let datePublished = "datePublished" static let dateModified = "dateModified" static let authors = "authors" - static let attachments = "attachments" static let searchRowID = "searchRowID" // ArticleStatus @@ -48,12 +45,6 @@ struct DatabaseKey { static let userDeleted = "userDeleted" static let dateArrived = "dateArrived" - // Attachment - static let attachmentID = "attachmentID" - static let mimeType = "mimeType" - static let sizeInBytes = "sizeInBytes" - static let durationInSeconds = "durationInSeconds" - // Tag static let tagName = "tagName" @@ -71,5 +62,4 @@ struct DatabaseKey { struct RelationshipName { static let authors = "authors" - static let attachments = "attachments" } diff --git a/Frameworks/ArticlesDatabase/DatabaseObject+Database.swift b/Frameworks/ArticlesDatabase/DatabaseObject+Database.swift index edc02e7de..af25c013a 100644 --- a/Frameworks/ArticlesDatabase/DatabaseObject+Database.swift +++ b/Frameworks/ArticlesDatabase/DatabaseObject+Database.swift @@ -16,9 +16,4 @@ extension Array where Element == DatabaseObject { let authors = Set(self.map { $0 as! Author }) return authors.isEmpty ? nil : authors } - - func asAttachments() -> Set? { - let attachments = Set(self.map { $0 as! Attachment }) - return attachments.isEmpty ? nil : attachments - } } diff --git a/Frameworks/ArticlesDatabase/Extensions/Article+Database.swift b/Frameworks/ArticlesDatabase/Extensions/Article+Database.swift index 2fd0d48c8..3b9b43898 100644 --- a/Frameworks/ArticlesDatabase/Extensions/Article+Database.swift +++ b/Frameworks/ArticlesDatabase/Extensions/Article+Database.swift @@ -13,13 +13,12 @@ import RSParser extension Article { - init(databaseArticle: DatabaseArticle, accountID: String, authors: Set?, attachments: Set?) { - self.init(accountID: accountID, articleID: databaseArticle.articleID, feedID: databaseArticle.feedID, uniqueID: databaseArticle.uniqueID, title: databaseArticle.title, contentHTML: databaseArticle.contentHTML, contentText: databaseArticle.contentText, url: databaseArticle.url, externalURL: databaseArticle.externalURL, summary: databaseArticle.summary, imageURL: databaseArticle.imageURL, bannerImageURL: databaseArticle.bannerImageURL, datePublished: databaseArticle.datePublished, dateModified: databaseArticle.dateModified, authors: authors, attachments: attachments, status: databaseArticle.status) + init(databaseArticle: DatabaseArticle, accountID: String, authors: Set?) { + self.init(accountID: accountID, articleID: databaseArticle.articleID, feedID: databaseArticle.feedID, uniqueID: databaseArticle.uniqueID, title: databaseArticle.title, contentHTML: databaseArticle.contentHTML, contentText: databaseArticle.contentText, url: databaseArticle.url, externalURL: databaseArticle.externalURL, summary: databaseArticle.summary, imageURL: databaseArticle.imageURL, bannerImageURL: databaseArticle.bannerImageURL, datePublished: databaseArticle.datePublished, dateModified: databaseArticle.dateModified, authors: authors, status: databaseArticle.status) } init(parsedItem: ParsedItem, maximumDateAllowed: Date, accountID: String, feedID: String, status: ArticleStatus) { let authors = Author.authorsWithParsedAuthors(parsedItem.authors) - let attachments = Attachment.attachmentsWithParsedAttachments(parsedItem.attachments) // Deal with future datePublished and dateModified dates. var datePublished = parsedItem.datePublished @@ -35,7 +34,7 @@ extension Article { dateModified = nil } - self.init(accountID: accountID, articleID: parsedItem.syncServiceID, feedID: feedID, uniqueID: parsedItem.uniqueID, title: parsedItem.title, contentHTML: parsedItem.contentHTML, contentText: parsedItem.contentText, url: parsedItem.url, externalURL: parsedItem.externalURL, summary: parsedItem.summary, imageURL: parsedItem.imageURL, bannerImageURL: parsedItem.bannerImageURL, datePublished: datePublished, dateModified: dateModified, authors: authors, attachments: attachments, status: status) + self.init(accountID: accountID, articleID: parsedItem.syncServiceID, feedID: feedID, uniqueID: parsedItem.uniqueID, title: parsedItem.title, contentHTML: parsedItem.contentHTML, contentText: parsedItem.contentText, url: parsedItem.url, externalURL: parsedItem.externalURL, summary: parsedItem.summary, imageURL: parsedItem.imageURL, bannerImageURL: parsedItem.bannerImageURL, datePublished: datePublished, dateModified: dateModified, authors: authors, status: status) } private func addPossibleStringChangeWithKeyPath(_ comparisonKeyPath: KeyPath, _ otherArticle: Article, _ key: String, _ dictionary: inout DatabaseDictionary) { @@ -145,8 +144,6 @@ extension Article: DatabaseObject { switch name { case RelationshipName.authors: return databaseObjectArray(with: authors) - case RelationshipName.attachments: - return databaseObjectArray(with: attachments) default: return nil } diff --git a/Frameworks/ArticlesDatabase/Extensions/Attachment+Database.swift b/Frameworks/ArticlesDatabase/Extensions/Attachment+Database.swift deleted file mode 100644 index dc30e5bee..000000000 --- a/Frameworks/ArticlesDatabase/Extensions/Attachment+Database.swift +++ /dev/null @@ -1,90 +0,0 @@ -// -// Attachment+Database.swift -// NetNewsWire -// -// Created by Brent Simmons on 7/4/17. -// Copyright © 2017 Ranchero Software. All rights reserved. -// - -import Foundation -import Articles -import RSDatabase -import RSParser - -extension Attachment { - - init?(row: FMResultSet) { - guard let url = row.string(forColumn: DatabaseKey.url) else { - return nil - } - - let attachmentID = row.string(forColumn: DatabaseKey.attachmentID) - let mimeType = row.string(forColumn: DatabaseKey.mimeType) - let title = row.string(forColumn: DatabaseKey.title) - let sizeInBytes = row.optionalIntForColumn(DatabaseKey.sizeInBytes) - let durationInSeconds = row.optionalIntForColumn(DatabaseKey.durationInSeconds) - - self.init(attachmentID: attachmentID, url: url, mimeType: mimeType, title: title, sizeInBytes: sizeInBytes, durationInSeconds: durationInSeconds) - } - - init?(parsedAttachment: ParsedAttachment) { - self.init(attachmentID: nil, url: parsedAttachment.url, mimeType: parsedAttachment.mimeType, title: parsedAttachment.title, sizeInBytes: parsedAttachment.sizeInBytes, durationInSeconds: parsedAttachment.durationInSeconds) - } - - static func attachmentsWithParsedAttachments(_ parsedAttachments: Set?) -> Set? { - guard let parsedAttachments = parsedAttachments else { - return nil - } - - let attachments = parsedAttachments.compactMap{ Attachment(parsedAttachment: $0) } - return attachments.isEmpty ? nil : Set(attachments) - } -} - - -extension Attachment: DatabaseObject { - - public var databaseID: String { - return attachmentID - } - - public func databaseDictionary() -> DatabaseDictionary? { - var d: DatabaseDictionary = [DatabaseKey.attachmentID: attachmentID, DatabaseKey.url: url] - if let mimeType = mimeType { - d[DatabaseKey.mimeType] = mimeType - } - if let title = title { - d[DatabaseKey.title] = title - } - if let sizeInBytes = sizeInBytes { - d[DatabaseKey.sizeInBytes] = NSNumber(value: sizeInBytes) - } - if let durationInSeconds = durationInSeconds { - d[DatabaseKey.durationInSeconds] = NSNumber(value: durationInSeconds) - } - return d - } - -} - -private extension FMResultSet { - - func optionalIntForColumn(_ columnName: String) -> Int? { - let intValue = long(forColumn: columnName) - if intValue < 1 { - return nil - } - return intValue - } -} - -extension Set where Element == Attachment { - - func databaseDictionaries() -> [DatabaseDictionary] { - return self.compactMap { $0.databaseDictionary() } - } - - func databaseObjects() -> [DatabaseObject] { - return self.compactMap { $0 as DatabaseObject } - } -} diff --git a/Frameworks/ArticlesDatabase/RelatedObjectsMap+Database.swift b/Frameworks/ArticlesDatabase/RelatedObjectsMap+Database.swift index 80c1f0692..00a42d41d 100644 --- a/Frameworks/ArticlesDatabase/RelatedObjectsMap+Database.swift +++ b/Frameworks/ArticlesDatabase/RelatedObjectsMap+Database.swift @@ -12,13 +12,6 @@ import Articles extension RelatedObjectsMap { - func attachments(for articleID: String) -> Set? { - if let objects = self[articleID] { - return objects.asAttachments() - } - return nil - } - func authors(for articleID: String) -> Set? { if let objects = self[articleID] { return objects.asAuthors() diff --git a/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift b/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift index 4f55cd110..b6fbe97f1 100644 --- a/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift +++ b/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift @@ -121,7 +121,6 @@ private extension ArticlePasteboardWriter { static let starred = "starred" static let userDeleted = "userDeleted" static let authors = "authors" - static let attachments = "attachments" // Author static let authorName = "name" @@ -129,13 +128,6 @@ private extension ArticlePasteboardWriter { static let authorAvatarURL = "avatarURL" static let authorEmailAddress = "emailAddress" - // Attachment - static let attachmentURL = "url" - static let attachmentMimeType = "mimeType" - static let attachmentTitle = "title" - static let attachmentSizeInBytes = "sizeInBytes" - static let attachmentDurationInSeconds = "durationInSeconds" - // Internal static let accountID = "accountID" } @@ -163,7 +155,6 @@ private extension ArticlePasteboardWriter { d[Key.dateModified] = article.dateModified ?? nil d[Key.dateArrived] = article.status.dateArrived d[Key.authors] = authorDictionaries() ?? nil - d[Key.attachments] = attachmentDictionaries() ?? nil return d } @@ -182,19 +173,6 @@ private extension ArticlePasteboardWriter { d[Key.authorAvatarURL] = author.avatarURL ?? nil d[Key.authorEmailAddress] = author.emailAddress ?? nil - return d - - } - - func attachmentDictionary(_ attachment: Attachment) -> [String: Any] { - var d = [String: Any]() - - d[Key.attachmentURL] = attachment.url - d[Key.attachmentMimeType] = attachment.mimeType ?? nil - d[Key.attachmentTitle] = attachment.title ?? nil - d[Key.attachmentSizeInBytes] = attachment.sizeInBytes ?? nil - d[Key.attachmentDurationInSeconds] = attachment.durationInSeconds ?? nil - return d } @@ -204,12 +182,5 @@ private extension ArticlePasteboardWriter { } return authors.map{ authorDictionary($0) } } - - func attachmentDictionaries() -> [[String: Any]]? { - guard let attachments = article.attachments, !attachments.isEmpty else { - return nil - } - return attachments.map { attachmentDictionary($0) } - } } diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index ffa01d921..6f4dccc34 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -549,7 +549,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr let longTitle = "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?" let prototypeID = "prototype" let status = ArticleStatus(articleID: prototypeID, read: false, starred: false, userDeleted: false, dateArrived: Date()) - let prototypeArticle = Article(accountID: prototypeID, articleID: prototypeID, feedID: prototypeID, uniqueID: prototypeID, title: longTitle, contentHTML: nil, contentText: nil, url: nil, externalURL: nil, summary: nil, imageURL: nil, bannerImageURL: nil, datePublished: nil, dateModified: nil, authors: nil, attachments: nil, status: status) + let prototypeArticle = Article(accountID: prototypeID, articleID: prototypeID, feedID: prototypeID, uniqueID: prototypeID, title: longTitle, contentHTML: nil, contentText: nil, url: nil, externalURL: nil, summary: nil, imageURL: nil, bannerImageURL: nil, datePublished: nil, dateModified: nil, authors: nil, status: status) let prototypeCellData = TimelineCellData(article: prototypeArticle, showFeedName: showingFeedNames, feedName: "Prototype Feed Name", avatar: nil, showAvatar: false, featuredImage: nil) let height = TimelineCellLayout.height(for: 100, cellData: prototypeCellData, appearance: cellAppearance) diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index fb2383812..7e445e536 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -330,7 +330,7 @@ class MasterTimelineViewController: ProgressTableViewController, UndoableCommand let prototypeID = "prototype" let status = ArticleStatus(articleID: prototypeID, read: false, starred: false, userDeleted: false, dateArrived: Date()) - let prototypeArticle = Article(accountID: prototypeID, articleID: prototypeID, feedID: prototypeID, uniqueID: prototypeID, title: longTitle, contentHTML: nil, contentText: nil, url: nil, externalURL: nil, summary: nil, imageURL: nil, bannerImageURL: nil, datePublished: nil, dateModified: nil, authors: nil, attachments: nil, status: status) + let prototypeArticle = Article(accountID: prototypeID, articleID: prototypeID, feedID: prototypeID, uniqueID: prototypeID, title: longTitle, contentHTML: nil, contentText: nil, url: nil, externalURL: nil, summary: nil, imageURL: nil, bannerImageURL: nil, datePublished: nil, dateModified: nil, authors: nil, status: status) let prototypeCellData = MasterTimelineCellData(article: prototypeArticle, showFeedName: true, feedName: "Prototype Feed Name", avatar: nil, showAvatar: false, featuredImage: nil, numberOfLines: numberOfTextLines)