mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Remove attachments from the app, since we’re not using attachments in any way. We could always add it back later.
This commit is contained in:
@@ -13,13 +13,12 @@ import RSParser
|
||||
|
||||
extension Article {
|
||||
|
||||
init(databaseArticle: DatabaseArticle, accountID: String, authors: Set<Author>?, attachments: Set<Attachment>?) {
|
||||
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<Author>?) {
|
||||
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<Article,String?>, _ 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
|
||||
}
|
||||
|
||||
@@ -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<ParsedAttachment>?) -> Set<Attachment>? {
|
||||
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 }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user