add createdByMe field to Highlight model

This commit is contained in:
Satindar Dhillon 2022-03-22 11:51:45 -07:00
parent 1b6fb7ba93
commit 6bb8f76f40
5 changed files with 38 additions and 32 deletions

View file

@ -57,7 +57,8 @@ public final class PDFViewerViewModel: ObservableObject {
prefix: nil,
suffix: nil,
patch: patch,
annotation: nil
annotation: nil,
createdByMe: true
)
)
@ -94,7 +95,8 @@ public final class PDFViewerViewModel: ObservableObject {
prefix: nil,
suffix: nil,
patch: patch,
annotation: nil
annotation: nil,
createdByMe: true
)
)

View file

@ -36,36 +36,35 @@ struct WebReaderContent {
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no' />
</head>
<body>
<div id="root">
<script type="text/javascript">
window.omnivoreEnv = {
"NEXT_PUBLIC_APP_ENV": "\(appEnv.rawValue)",
"NEXT_PUBLIC_\(appEnv.rawValue.uppercased())_BASE_URL": "\(appEnv.webAppBaseURL.absoluteString)",
"NEXT_PUBLIC_\(appEnv.rawValue.uppercased())_SERVER_BASE_URL": "\(appEnv.serverBaseURL.absoluteString)",
"NEXT_PUBLIC_\(appEnv.rawValue.uppercased())_HIGHLIGHTS_BASE_URL": "\(appEnv.highlightsServerBaseURL.absoluteString)"
}
<div id="root" />
<script type="text/javascript">
window.omnivoreEnv = {
"NEXT_PUBLIC_APP_ENV": "\(appEnv.rawValue)",
"NEXT_PUBLIC_\(appEnv.rawValue.uppercased())_BASE_URL": "\(appEnv.webAppBaseURL.absoluteString)",
"NEXT_PUBLIC_\(appEnv.rawValue.uppercased())_SERVER_BASE_URL": "\(appEnv.serverBaseURL.absoluteString)",
"NEXT_PUBLIC_\(appEnv.rawValue.uppercased())_HIGHLIGHTS_BASE_URL": "\(appEnv.highlightsServerBaseURL.absoluteString)"
}
window.omnivoreArticle = {
id: "test",
linkId: "test",
slug: "test-slug",
createdAt: new Date().toISOString(),
savedAt: new Date().toISOString(),
url: "https://example.com",
title: `\(item.title)`,
content: `\(articleContent.htmlContent)`,
originalArticleUrl: "https://example.com",
contentReader: "WEB",
readingProgressPercent: \(item.readingProgress),
readingProgressAnchorIndex: \(item.readingProgressAnchor),
highlights: \(articleContent.highlightsJSONString),
}
window.omnivoreArticle = {
id: "test",
linkId: "test",
slug: "test-slug",
createdAt: new Date().toISOString(),
savedAt: new Date().toISOString(),
url: "https://example.com",
title: `\(item.title)`,
content: `\(articleContent.htmlContent)`,
originalArticleUrl: "https://example.com",
contentReader: "WEB",
readingProgressPercent: \(item.readingProgress),
readingProgressAnchorIndex: \(item.readingProgressAnchor),
highlights: \(articleContent.highlightsJSONString),
}
window.fontSize = \(textFontSize)
window.localStorage.setItem("authToken", "\(authToken)")
window.localStorage.setItem("theme", "\(themeKey)")
</script>
</div>
window.fontSize = \(textFontSize)
window.localStorage.setItem("authToken", "\(authToken)")
window.localStorage.setItem("theme", "\(themeKey)")
</script>
<script src="bundle.js"></script>
</body>
</html>

View file

@ -10,6 +10,7 @@ public struct Highlight: Identifiable, Hashable, Codable {
public let annotation: String?
public let createdAt: Date?
public let updatedAt: Date?
public let createdByMe: Bool
public init(
id: String,
@ -19,6 +20,7 @@ public struct Highlight: Identifiable, Hashable, Codable {
suffix: String?,
patch: String,
annotation: String?,
createdByMe: Bool,
createdAt: Date? = nil,
updatedAt: Date? = nil
) {
@ -31,5 +33,6 @@ public struct Highlight: Identifiable, Hashable, Codable {
self.annotation = annotation
self.createdAt = createdAt
self.updatedAt = updatedAt
self.createdByMe = createdByMe
}
}

View file

@ -18,7 +18,8 @@ public extension DataService {
prefix: try $0.prefix(),
suffix: try $0.suffix(),
patch: try $0.patch(),
annotation: try $0.annotation()
annotation: try $0.annotation(),
createdByMe: try $0.createdByMe()
)
}

View file

@ -18,7 +18,8 @@ public extension DataService {
prefix: try $0.prefix(),
suffix: try $0.suffix(),
patch: try $0.patch(),
annotation: try $0.annotation()
annotation: try $0.annotation(),
createdByMe: try $0.createdByMe()
)
}