Skip to content

Commit 7d60489

Browse files
committed
Render unable to fetch view when there is an error fetching stats
1 parent 2cbacbb commit 7d60489

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

WooCommerce/StoreWidgets/StoreInfoProvider.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import WidgetKit
22
import KeychainAccess
3+
import WooFoundation
34

45
/// Type that represents the all the possible Widget states.
56
///
@@ -98,10 +99,14 @@ final class StoreInfoProvider: TimelineProvider {
9899
completion(timeline)
99100

100101
} catch {
101-
// TODO: Dispatch network error entry.
102-
print("Error: \(error)")
103-
}
104102

103+
// WooFoundation does not expose `DDLOG` types. Should we include them?
104+
print("⛔️ Error fetching today's widget stats: \(error)")
105+
106+
let reloadDate = Date(timeIntervalSinceNow: 30 * 60) // Ask for a 15 minutes reload.
107+
let timeline = Timeline<StoreInfoEntry>(entries: [.error], policy: .after(reloadDate))
108+
completion(timeline)
109+
}
105110
}
106111
}
107112
}

WooCommerce/StoreWidgets/StoreInfoWidget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct StoreInfoWidget: Widget {
1616
case .notConnected:
1717
NotLoggedInView()
1818
case .error:
19-
EmptyView() // TODO:
19+
UnableToFetchView()
2020
case .data(let data):
2121
StoreInfoView(entry: data)
2222
}

0 commit comments

Comments
 (0)