mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #325 from omnivore-app/fix/appreader-dates
Pass createdAt, savedAt, and publishedAt into the appreader
This commit is contained in:
commit
9c14049236
3 changed files with 19 additions and 4 deletions
|
|
@ -22,7 +22,11 @@ struct WebReaderContent {
|
|||
|
||||
// swiftlint:disable line_length
|
||||
var styledContent: String {
|
||||
"""
|
||||
let savedAt = "new Date(\(item.savedAt.timeIntervalSince1970 * 1000)).toISOString()"
|
||||
let createdAt = "new Date(\(item.createdAt.timeIntervalSince1970 * 1000)).toISOString()"
|
||||
let publishedAt = item.publishDate != nil ? "new Date(\(item.publishDate!.timeIntervalSince1970 * 1000)).toISOString()" : "undefined"
|
||||
|
||||
return """
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
|
@ -52,8 +56,9 @@ struct WebReaderContent {
|
|||
id: "\(item.id)",
|
||||
linkId: "\(item.id)",
|
||||
slug: "\(item.slug)",
|
||||
createdAt: new Date().toISOString(),
|
||||
savedAt: new Date().toISOString(),
|
||||
createdAt: \(createdAt),
|
||||
savedAt: \(savedAt),
|
||||
publishedAt: \(publishedAt),
|
||||
url: `\(item.pageURLString)`,
|
||||
title: document.getElementById('_omnivore-title').innerHTML,
|
||||
content: document.getElementById('_omnivore-htmlContent').innerHTML,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ public struct FeedItem: Identifiable, Hashable, Decodable {
|
|||
public let id: String
|
||||
public let renderID = UUID()
|
||||
public let title: String
|
||||
public let createdAt: Date
|
||||
public let savedAt: Date
|
||||
public var readingProgress: Double
|
||||
public var readingProgressAnchor: Int
|
||||
public let imageURLString: String?
|
||||
|
|
@ -31,6 +33,8 @@ public struct FeedItem: Identifiable, Hashable, Decodable {
|
|||
public init(
|
||||
id: String,
|
||||
title: String,
|
||||
createdAt: Date,
|
||||
savedAt: Date,
|
||||
readingProgress: Double,
|
||||
readingProgressAnchor: Int,
|
||||
imageURLString: String?,
|
||||
|
|
@ -47,6 +51,8 @@ public struct FeedItem: Identifiable, Hashable, Decodable {
|
|||
) {
|
||||
self.id = id
|
||||
self.title = title
|
||||
self.createdAt = createdAt
|
||||
self.savedAt = savedAt
|
||||
self.readingProgress = readingProgress
|
||||
self.readingProgressAnchor = readingProgressAnchor
|
||||
self.imageURLString = imageURLString
|
||||
|
|
@ -63,13 +69,15 @@ public struct FeedItem: Identifiable, Hashable, Decodable {
|
|||
}
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id, title, image, isArchived, readingProgressPercent, readingProgressAnchorIndex, slug, contentReader, url
|
||||
case id, title, createdAt, savedAt, image, isArchived, readingProgressPercent, readingProgressAnchorIndex, slug, contentReader, url
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
id = try container.decode(String.self, forKey: .id)
|
||||
title = try container.decode(String.self, forKey: .title)
|
||||
createdAt = try container.decode(Date.self, forKey: .createdAt)
|
||||
savedAt = try container.decode(Date.self, forKey: .savedAt)
|
||||
description = try container.decode(String?.self, forKey: .title)
|
||||
imageURLString = try container.decode(String?.self, forKey: .image)
|
||||
readingProgress = try container.decode(Double.self, forKey: .readingProgressPercent)
|
||||
|
|
|
|||
|
|
@ -129,6 +129,8 @@ let homeFeedItemSelection = Selection.Article {
|
|||
FeedItem(
|
||||
id: try $0.id(),
|
||||
title: try $0.title(),
|
||||
createdAt: try $0.createdAt().value ?? Date(),
|
||||
savedAt: try $0.savedAt().value ?? Date(),
|
||||
readingProgress: try $0.readingProgressPercent(),
|
||||
readingProgressAnchor: try $0.readingProgressAnchorIndex(),
|
||||
imageURLString: try $0.image(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue