mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Rebase and merge
This commit is contained in:
parent
def0fc7678
commit
0e10d5630d
6 changed files with 35 additions and 19 deletions
|
|
@ -153,8 +153,8 @@ public final class DataService: ObservableObject {
|
|||
linkedItem.originalHtml = html
|
||||
linkedItem.title = title ?? self.titleFromPdfFile(pageScrape.url)
|
||||
case .none:
|
||||
print("SAVING NONE TYPE")
|
||||
throw BasicError.message(messageText: "Attempting to save none type")
|
||||
print("SAVING URL", linkedItem.unwrappedPageURLString)
|
||||
linkedItem.contentReader = "WEB"
|
||||
}
|
||||
|
||||
do {
|
||||
|
|
|
|||
|
|
@ -3,23 +3,23 @@ import Models
|
|||
import SwiftGraphQL
|
||||
|
||||
public extension DataService {
|
||||
func savePage(pageScrapePayload: PageScrapePayload, html: String, title: String?, requestId: String) async throws {
|
||||
func savePage(item: LinkedItem) async throws {
|
||||
enum MutationResult {
|
||||
case saved(requestId: String, url: String)
|
||||
case error(errorCode: Enums.SaveErrorCode)
|
||||
}
|
||||
|
||||
let input = InputObjects.SavePageInput(
|
||||
url: pageScrapePayload.url,
|
||||
url: item.unwrappedPageURLString,
|
||||
source: "ios-page",
|
||||
clientRequestId: requestId,
|
||||
title: OptionalArgument(title),
|
||||
originalContent: html
|
||||
clientRequestId: item.unwrappedID,
|
||||
title: OptionalArgument(item.title),
|
||||
originalContent: item.originalHtml!
|
||||
)
|
||||
|
||||
let selection = Selection<MutationResult, Unions.SaveResult> {
|
||||
try $0.on(
|
||||
saveSuccess: .init { .saved(requestId: requestId, url: (try? $0.url()) ?? "") },
|
||||
saveSuccess: .init { .saved(requestId: item.unwrappedID, url: (try? $0.url()) ?? "") },
|
||||
saveError: .init {
|
||||
.error(errorCode: (try? $0.errorCodes().first) ?? .unknown)
|
||||
}
|
||||
|
|
@ -43,7 +43,6 @@ public extension DataService {
|
|||
)
|
||||
return
|
||||
}
|
||||
|
||||
switch payload.data {
|
||||
case .saved:
|
||||
continuation.resume()
|
||||
|
|
|
|||
|
|
@ -3,18 +3,20 @@ import Models
|
|||
import SwiftGraphQL
|
||||
|
||||
public extension DataService {
|
||||
func saveURL(pageScrapePayload: PageScrapePayload, requestId: String) async throws {
|
||||
func saveURL(item: LinkedItem) async throws {
|
||||
enum MutationResult {
|
||||
case saved(requestId: String, url: String)
|
||||
case error(errorCode: Enums.SaveErrorCode)
|
||||
}
|
||||
|
||||
let input = InputObjects.SaveUrlInput(
|
||||
url: pageScrapePayload.url,
|
||||
url: item.unwrappedPageURLString,
|
||||
source: "ios-url",
|
||||
clientRequestId: requestId
|
||||
clientRequestId: item.unwrappedID
|
||||
)
|
||||
|
||||
print("UPLOADING ITEM:", item.unwrappedID, item)
|
||||
let requestId = item.unwrappedID
|
||||
let selection = Selection<MutationResult, Unions.SaveResult> {
|
||||
try $0.on(
|
||||
saveSuccess: .init { .saved(requestId: requestId, url: (try? $0.url()) ?? "") },
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ public final class Networker: NSObject, URLSessionTaskDelegate {
|
|||
public func urlSession(_: URLSession, task: URLSessionTask, didCompleteWithError: Error?) {
|
||||
if let httpResponse = task.response as? HTTPURLResponse {
|
||||
print("httpRespinse status code", httpResponse.statusCode)
|
||||
print("current Request", task.currentRequest?.url)
|
||||
}
|
||||
print("finished upload of file:", task.taskIdentifier, task.currentRequest, task.response, "with error", didCompleteWithError)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,13 +40,29 @@ extension DataService {
|
|||
case "PDF":
|
||||
// SaveFile
|
||||
uploadFilePublisher(item: item)
|
||||
.receive(on: DispatchQueue.main)
|
||||
.eraseToAnyPublisher()
|
||||
.sink(receiveCompletion: { [weak self] _ in
|
||||
print("received PDF saved completion")
|
||||
}, receiveValue: { [weak self] _ in
|
||||
print("recived save PDF value", item)
|
||||
})
|
||||
.store(in: &subscriptions)
|
||||
case "WEB":
|
||||
if item.originalHtml != nil {
|
||||
// SavePage
|
||||
savePagePublisher(item: item)
|
||||
.sink(receiveCompletion: { [weak self] _ in
|
||||
print("received page saved completion")
|
||||
}, receiveValue: { [weak self] _ in
|
||||
print("recived save page value", item)
|
||||
})
|
||||
.store(in: &subscriptions)
|
||||
} else {
|
||||
// SaveURL
|
||||
saveUrlPublisher(item: item)
|
||||
.sink(receiveCompletion: { [weak self] _ in
|
||||
print("received url saved completion")
|
||||
}, receiveValue: { [weak self] _ in
|
||||
// print("recived save url value", item)
|
||||
})
|
||||
.store(in: &subscriptions)
|
||||
}
|
||||
case .none:
|
||||
print("NONE HANDLER")
|
||||
|
|
@ -61,7 +77,7 @@ extension DataService {
|
|||
|
||||
switch syncStatus {
|
||||
case .needsCreation:
|
||||
print("SYNCING LINKED ITEM", unsyncedLinkedItems)
|
||||
syncLocalCreatedLinkedItem(item: item)
|
||||
case .isNSync, .isSyncing:
|
||||
break
|
||||
case .needsDeletion:
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ export const uploadFileRequestResolver: ResolverFn<
|
|||
savedAt: new Date(),
|
||||
readingProgressPercent: 0,
|
||||
readingProgressAnchorIndex: 0,
|
||||
state: ArticleSavingRequestStatus.Processing,
|
||||
state: ArticleSavingRequestStatus.Succeeded,
|
||||
},
|
||||
ctx
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue