-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First pass for swift concurrency * Update code base * Adopt concurrency * migrate to observation * Targeted concurrency * Remove comment * Restore pasteboard
- Loading branch information
Showing
63 changed files
with
501 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ | |
} | ||
} | ||
} | ||
// swiftlint:enable line_length | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Factory | ||
import Foundation | ||
import Observation | ||
import SwiftUI | ||
|
||
@Observable | ||
final class AddEntryModel { | ||
@ObservationIgnored | ||
@Injected(\.wallabagSession) private var session | ||
|
||
var url: String = "" | ||
var submitting: Bool = false | ||
var succeeded: Bool = false | ||
|
||
@MainActor | ||
func addEntry() async { | ||
defer { | ||
submitting = false | ||
succeeded = false | ||
url = "" | ||
} | ||
|
||
submitting = true | ||
do { | ||
try await session.addEntry(url: url) | ||
succeeded = true | ||
try await Task.sleep(for: .seconds(3)) | ||
} catch {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import SwiftUI | ||
|
||
struct AddEntryView: View { | ||
@State private var model = AddEntryModel() | ||
|
||
var body: some View { | ||
Form { | ||
TextField("Url", text: $model.url) | ||
#if os(iOS) | ||
.autocapitalization(.none) | ||
#endif | ||
.disableAutocorrection(true) | ||
HStack { | ||
if model.succeeded { | ||
Text("Great! Entry was added") | ||
} else { | ||
Button(model.submitting ? "Submitting..." : "Submit") { | ||
Task { | ||
await model.addEntry() | ||
} | ||
}.disabled(model.submitting) | ||
} | ||
} | ||
.disabled(model.url.isEmpty) | ||
} | ||
.animation(.easeInOut, value: model.succeeded) | ||
.animation(.easeInOut, value: model.submitting) | ||
.navigationTitle("Add entry") | ||
} | ||
} | ||
|
||
#Preview { | ||
AddEntryView() | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
import Combine | ||
import Foundation | ||
import Observation | ||
|
||
final class ErrorViewModel: ObservableObject { | ||
@Observable | ||
final class ErrorViewModel { | ||
private var resetAfter: Double | ||
private(set) var lastError: WallabagError? | ||
|
||
init(_ resetAfter: Double = 10) { | ||
self.resetAfter = resetAfter | ||
} | ||
|
||
@Published private(set) var lastError: WallabagError? | ||
|
||
func setLast(_ error: WallabagError) { | ||
lastError = error | ||
DispatchQueue.main.asyncAfter(deadline: .now() + resetAfter) { [weak self] in | ||
self?.lastError = nil | ||
Task.detached { [weak self] in | ||
guard let self else { return } | ||
try? await Task.sleep(for: .seconds(resetAfter)) | ||
lastError = nil | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
App/Features/Haptic/ButtonStyle/HapticNotificationButtonStyle.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.