Restore credentials for widgets (#1201)

Fixes #1201
This commit is contained in:
Nathan Mattes 2023-12-31 16:44:54 +01:00
parent 195029fc15
commit 6c4e3efbde
4 changed files with 15 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import WidgetKit
import SwiftUI
import Intents
import MastodonSDK
import MastodonCore
import MastodonLocalization
struct FollowersCountWidgetProvider: IntentTimelineProvider {
@ -70,6 +71,9 @@ struct FollowersCountWidget: Widget {
private extension FollowersCountWidgetProvider {
func loadCurrentEntry(for configuration: FollowersCountIntent, in context: Context, completion: @escaping (FollowersCountEntry) -> Void) {
Task {
AuthenticationServiceProvider.shared.restore()
guard
let authBox = WidgetExtension.appContext
.authenticationService

View File

@ -4,6 +4,7 @@ import WidgetKit
import SwiftUI
import MastodonSDK
import MastodonLocalization
import MastodonCore
struct HashtagWidgetProvider: IntentTimelineProvider {
func placeholder(in context: Context) -> HashtagWidgetTimelineEntry {
@ -24,6 +25,8 @@ struct HashtagWidgetProvider: IntentTimelineProvider {
extension HashtagWidgetProvider {
func loadMostRecentHashtag(for configuration: HashtagIntent, in context: Context, completion: @escaping (HashtagWidgetTimelineEntry) -> Void ) {
AuthenticationServiceProvider.shared.restore()
guard
let authBox = WidgetExtension.appContext
.authenticationService

View File

@ -5,6 +5,7 @@ import SwiftUI
import Intents
import MastodonSDK
import MastodonLocalization
import MastodonCore
struct LatestFollowersWidgetProvider: IntentTimelineProvider {
func placeholder(in context: Context) -> LatestFollowersEntry {
@ -77,6 +78,9 @@ struct LatestFollowersWidget: Widget {
private extension LatestFollowersWidgetProvider {
func loadCurrentEntry(for configuration: LatestFollowersIntent, in context: Context, completion: @escaping (LatestFollowersEntry) -> Void) {
Task { @MainActor in
AuthenticationServiceProvider.shared.restore()
guard
let authBox = WidgetExtension.appContext
.authenticationService

View File

@ -4,6 +4,7 @@ import WidgetKit
import SwiftUI
import Intents
import MastodonSDK
import MastodonCore
import MastodonLocalization
struct MultiFollowersCountWidgetProvider: IntentTimelineProvider {
@ -70,6 +71,9 @@ struct MultiFollowersCountWidget: Widget {
private extension MultiFollowersCountWidgetProvider {
func loadCurrentEntry(for configuration: MultiFollowersCountIntent, in context: Context, completion: @escaping (MultiFollowersCountEntry) -> Void) {
Task {
AuthenticationServiceProvider.shared.restore()
guard
let authBox = WidgetExtension.appContext
.authenticationService