mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
layout fixes
• Ensure counts do not wrap • Reduces number of articles on large widget due to increased spacing. • Consistent vertical spacing between articles and dividers
This commit is contained in:
@@ -16,8 +16,10 @@ import Articles
|
||||
@available(iOS 14, *)
|
||||
struct WidgetDataEncoder {
|
||||
|
||||
private static var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "Application")
|
||||
|
||||
static func encodeWidgetData() {
|
||||
os_log(.debug, "Starting encoding widget data.")
|
||||
os_log(.debug, log: log, "Starting encoding widget data.")
|
||||
do {
|
||||
// Unread Articles
|
||||
let unreadArticles = try SmartFeedsController.shared.unreadFeed.fetchArticles().sorted(by: { $0.datePublished ?? .distantPast > $1.datePublished ?? .distantPast })
|
||||
@@ -70,16 +72,16 @@ struct WidgetDataEncoder {
|
||||
lastUpdateTime: Date())
|
||||
|
||||
let encodedData = try JSONEncoder().encode(latestData)
|
||||
os_log(.debug, "Finished encoding widget data.")
|
||||
os_log(.debug, log: log, "Finished encoding widget data.")
|
||||
let appGroup = Bundle.main.object(forInfoDictionaryKey: "AppGroup") as! String
|
||||
let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroup)
|
||||
let dataURL = containerURL?.appendingPathComponent("widget-data.json")
|
||||
if FileManager.default.fileExists(atPath: dataURL!.path) {
|
||||
try FileManager.default.removeItem(at: dataURL!)
|
||||
os_log(.debug, "Removed widget data from container.")
|
||||
os_log(.debug, log: log, "Removed widget data from container.")
|
||||
}
|
||||
if FileManager.default.createFile(atPath: dataURL!.path, contents: encodedData, attributes: nil) {
|
||||
os_log(.debug, "Wrote widget data to container.")
|
||||
os_log(.debug, log: log, "Wrote widget data to container.")
|
||||
WidgetCenter.shared.reloadAllTimelines()
|
||||
}
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user