Disable sorting options that need API improvements

This commit is contained in:
Jackson Harper 2022-06-03 12:47:43 -07:00
parent 24234fac3a
commit b56c6dafa9
7 changed files with 38 additions and 29 deletions

View file

@ -43,6 +43,7 @@
<attribute name="siteName" optional="YES" attributeType="String"/>
<attribute name="slug" attributeType="String"/>
<attribute name="title" attributeType="String"/>
<attribute name="updatedAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
<relationship name="highlights" toMany="YES" deletionRule="Cascade" destinationEntity="Highlight" inverseName="linkedItem" inverseEntity="Highlight"/>
<relationship name="labels" toMany="YES" deletionRule="Nullify" destinationEntity="LinkedItemLabel" inverseName="linkedItems" inverseEntity="LinkedItemLabel"/>
<uniquenessConstraints>
@ -88,7 +89,7 @@
</entity>
<elements>
<element name="Highlight" positionX="27" positionY="225" width="128" height="224"/>
<element name="LinkedItem" positionX="-18" positionY="63" width="128" height="389"/>
<element name="LinkedItem" positionX="-18" positionY="63" width="128" height="404"/>
<element name="LinkedItemLabel" positionX="-36" positionY="18" width="128" height="134"/>
<element name="NewsletterEmail" positionX="0" positionY="180" width="128" height="74"/>
<element name="Viewer" positionX="45" positionY="234" width="128" height="89"/>

View file

@ -16,6 +16,7 @@ public struct JSONArticle: Decodable {
public let id: String
public let title: String
public let createdAt: Date
public let updatedAt: Date
public let savedAt: Date
public let image: String
public let readingProgressPercent: Double
@ -116,6 +117,7 @@ public extension LinkedItem {
}
guard context.hasChanges else { return }
self.updatedAt = Date()
do {
try context.save()

View file

@ -3,9 +3,9 @@ import Foundation
public enum LinkedItemSort: String, CaseIterable {
case newest
case oldest
case recentlyRead
// case recentlyRead
case recentlyPublished
case relevance
// case relevance
}
public extension LinkedItemSort {
@ -15,12 +15,12 @@ public extension LinkedItemSort {
return "Newest"
case .oldest:
return "Oldest"
case .recentlyRead:
return "Recently Read"
// case .recentlyRead:
// return "Recently Read"
case .recentlyPublished:
return "Recently Published"
case .relevance:
return "Relevance"
// case .relevance:
// return "Relevance"
}
}
@ -30,23 +30,23 @@ public extension LinkedItemSort {
return "sort:saved"
case .oldest:
return "sort:saved-ASC"
case .recentlyRead:
return "sort:updated"
// case .recentlyRead:
// return "sort:updated"
case .recentlyPublished:
return "sort:published"
case .relevance:
return "relevance"
// case .relevance:
// return "relevance"
}
}
var sortDescriptors: [NSSortDescriptor] {
switch self {
case .newest, .relevance:
case .newest /* , .relevance */:
return [NSSortDescriptor(keyPath: \LinkedItem.createdAt, ascending: false)]
case .oldest:
return [NSSortDescriptor(keyPath: \LinkedItem.createdAt, ascending: true)]
case .recentlyRead:
return [NSSortDescriptor(keyPath: \LinkedItem.savedAt, ascending: false)]
// case .recentlyRead:
// return [NSSortDescriptor(keyPath: \LinkedItem.updatedAt, ascending: false)]
case .recentlyPublished:
return [NSSortDescriptor(keyPath: \LinkedItem.publishDate, ascending: false)]
}

View file

@ -100,6 +100,7 @@ extension DataService {
title: try $0.title(),
createdAt: try $0.createdAt().value ?? Date(),
savedAt: try $0.savedAt().value ?? Date(),
updatedAt: try $0.updatedAt().value ?? Date(),
readingProgress: try $0.readingProgressPercent(),
readingProgressAnchor: try $0.readingProgressAnchorIndex(),
imageURLString: try $0.image(),

View file

@ -97,6 +97,7 @@ public extension DataService {
title: try $0.title(),
createdAt: try $0.createdAt().value ?? Date(),
savedAt: try $0.savedAt().value ?? Date(),
updatedAt: try $0.updatedAt().value ?? Date(),
readingProgress: try $0.readingProgressPercent(),
readingProgressAnchor: try $0.readingProgressAnchorIndex(),
imageURLString: try $0.image(),
@ -162,6 +163,7 @@ private let libraryArticleSelection = Selection.Article {
title: try $0.title(),
createdAt: try $0.createdAt().value ?? Date(),
savedAt: try $0.savedAt().value ?? Date(),
updatedAt: try $0.updatedAt().value ?? Date(),
readingProgress: try $0.readingProgressPercent(),
readingProgressAnchor: try $0.readingProgressAnchorIndex(),
imageURLString: try $0.image(),

View file

@ -7,6 +7,7 @@ struct InternalLinkedItem {
let title: String
let createdAt: Date
let savedAt: Date
let updatedAt: Date
var readingProgress: Double
var readingProgressAnchor: Int
let imageURLString: String?
@ -39,6 +40,7 @@ struct InternalLinkedItem {
linkedItem.title = title
linkedItem.createdAt = createdAt
linkedItem.savedAt = savedAt
linkedItem.updatedAt = updatedAt
linkedItem.readingProgress = readingProgress
linkedItem.readingProgressAnchor = Int64(readingProgressAnchor)
linkedItem.imageURLString = imageURLString
@ -95,6 +97,7 @@ extension JSONArticle {
title: title,
createdAt: createdAt,
savedAt: savedAt,
updatedAt: updatedAt,
readingProgress: readingProgressPercent,
readingProgressAnchor: readingProgressAnchorIndex,
imageURLString: image,

View file

@ -20,9 +20,9 @@ export const generateUploadSignedUrl = async (
contentType: string,
selectedBucket?: string
): Promise<string> => {
if (env.dev.isLocal) {
return 'http://localhost:3000/uploads/' + filePathName
}
// if (env.dev.isLocal) {
// return 'http://localhost:3000/uploads/' + filePathName
// }
// These options will allow temporary uploading of file with requested content type
const options: GetSignedUrlConfig = {
@ -59,9 +59,9 @@ export const makeStorageFilePublic = async (
id: string,
fileName: string
): Promise<string> => {
if (env.dev.isLocal) {
return 'http://localhost:3000/public/' + id + '/' + fileName
}
// if (env.dev.isLocal) {
// return 'http://localhost:3000/public/' + id + '/' + fileName
// }
// Makes the file public
const filePathName = generateUploadFilePathName(id, fileName)
@ -75,12 +75,12 @@ export const getStorageFileDetails = async (
id: string,
fileName: string
): Promise<{ md5Hash: string; fileUrl: string }> => {
if (env.dev.isLocal) {
return {
md5Hash: 'some_md5_hash',
fileUrl: 'http://localhost:3000/public/' + id + '/' + fileName,
}
}
// if (env.dev.isLocal) {
// return {
// md5Hash: 'some_md5_hash',
// fileUrl: 'http://localhost:3000/public/' + id + '/' + fileName,
// }
// }
const filePathName = generateUploadFilePathName(id, fileName)
const file = storage.bucket(bucketName).file(filePathName)
@ -103,9 +103,9 @@ export const uploadToSignedUrl = async (
data: Buffer,
contentType: string
): Promise<void> => {
if (env.dev.isLocal) {
return
}
// if (env.dev.isLocal) {
// return
// }
await axios.put(uploadUrl, data, {
headers: {