mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
share extension starts with a .processing status
This commit is contained in:
parent
071b9f6036
commit
2d4ec9d45d
3 changed files with 12 additions and 40 deletions
|
|
@ -22,7 +22,7 @@ public extension PlatformViewController {
|
|||
|
||||
final class ShareExtensionViewModel: ObservableObject {
|
||||
@Published var title: String?
|
||||
@Published var status = ShareExtensionStatus.successfullySaved
|
||||
@Published var status = ShareExtensionStatus.processing
|
||||
@Published var debugText: String?
|
||||
|
||||
var subscriptions = Set<AnyCancellable>()
|
||||
|
|
@ -75,7 +75,7 @@ final class ShareExtensionViewModel: ObservableObject {
|
|||
self?.debugText = "saveArticleError: \(error)"
|
||||
self?.status = .failed(error: error)
|
||||
} receiveValue: { [weak self] _ in
|
||||
self?.status = .successfullySaved
|
||||
self?.status = .success
|
||||
}
|
||||
.store(in: &subscriptions)
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ public enum LocalText {
|
|||
static let networkError = localText(key: "error.network")
|
||||
static let genericError = localText(key: "error.generic")
|
||||
static let invalidCredsLoginError = localText(key: "loginError.invalidCreds")
|
||||
static let saveArticleSavingState = localText(key: "saveArticleSavingState")
|
||||
static let saveArticleSavedState = localText(key: "saveArticleSavedState")
|
||||
static let saveArticleProcessingState = localText(key: "saveArticleProcessingState")
|
||||
static let extensionAppUnauthorized = localText(key: "extensionAppUnauthorized")
|
||||
|
|
|
|||
|
|
@ -3,16 +3,13 @@ import SwiftUI
|
|||
import Utils
|
||||
|
||||
public enum ShareExtensionStatus {
|
||||
case saving
|
||||
case processing
|
||||
case successfullySaved
|
||||
case success
|
||||
case failed(error: SaveArticleError)
|
||||
|
||||
var displayMessage: String {
|
||||
switch self {
|
||||
case .saving:
|
||||
return LocalText.saveArticleSavingState
|
||||
case .successfullySaved:
|
||||
case .success:
|
||||
return LocalText.saveArticleSavedState
|
||||
case let .failed(error: error):
|
||||
return error.displayMessage
|
||||
|
|
@ -111,22 +108,6 @@ public struct ShareExtensionChildView: View {
|
|||
|
||||
@State var reminderTime: ReminderTime?
|
||||
@State var hideUntilReminded = false
|
||||
@State var readNowPending = false
|
||||
|
||||
private func waitForReadNow() {
|
||||
readNowPending = true
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(300)) {
|
||||
switch status {
|
||||
case .successfullySaved:
|
||||
readNowButtonAction()
|
||||
case .failed(error: _):
|
||||
readNowPending = false
|
||||
case .saving, .processing:
|
||||
waitForReadNow()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func handleReminderTimeSelection(_ selectedTime: ReminderTime) {
|
||||
if selectedTime == reminderTime {
|
||||
|
|
@ -156,7 +137,7 @@ public struct ShareExtensionChildView: View {
|
|||
|
||||
Spacer()
|
||||
|
||||
if case ShareExtensionStatus.successfullySaved = status {
|
||||
if case ShareExtensionStatus.success = status {
|
||||
HStack(spacing: 4) {
|
||||
Text("Saved to Omnivore")
|
||||
.font(.appTitleThree)
|
||||
|
|
@ -222,25 +203,17 @@ public struct ShareExtensionChildView: View {
|
|||
.padding(.horizontal)
|
||||
|
||||
HStack {
|
||||
if case ShareExtensionStatus.successfullySaved = status {
|
||||
if case ShareExtensionStatus.success = status {
|
||||
Button(
|
||||
action: {
|
||||
if case ShareExtensionStatus.successfullySaved = status {
|
||||
readNowButtonAction()
|
||||
} else {
|
||||
waitForReadNow()
|
||||
}
|
||||
},
|
||||
label: {
|
||||
if readNowPending {
|
||||
ProgressView().frame(maxWidth: .infinity)
|
||||
} else {
|
||||
Text("Read Now").frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
action: { readNowButtonAction() },
|
||||
label: { Text("Read Now").frame(maxWidth: .infinity) }
|
||||
)
|
||||
.buttonStyle(RoundedRectButtonStyle())
|
||||
}
|
||||
if case ShareExtensionStatus.processing = status {
|
||||
Button(action: {}, label: { ProgressView().frame(maxWidth: .infinity) })
|
||||
.buttonStyle(RoundedRectButtonStyle())
|
||||
}
|
||||
Button(
|
||||
action: {
|
||||
dismissButtonTappedAction(reminderTime, hideUntilReminded)
|
||||
|
|
|
|||
Loading…
Reference in a new issue