Change to initialize Refresh when the onAppear event happens so that we quit crashing on macOS

This commit is contained in:
Maurice Parker 2020-07-05 19:49:07 -05:00
parent aca4cdf4ec
commit bcbb38c120
2 changed files with 10 additions and 5 deletions

View File

@ -29,6 +29,9 @@ struct MainApp: App {
.frame(minWidth: 600, idealWidth: 1000, maxWidth: .infinity, minHeight: 600, idealHeight: 700, maxHeight: .infinity) .frame(minWidth: 600, idealWidth: 1000, maxWidth: .infinity, minHeight: 600, idealHeight: 700, maxHeight: .infinity)
.environmentObject(sceneModel) .environmentObject(sceneModel)
.environmentObject(defaults) .environmentObject(defaults)
.onAppear {
sceneModel.startup()
}
.sheet(isPresented: $showSheet, onDismiss: { showSheet = false }) { .sheet(isPresented: $showSheet, onDismiss: { showSheet = false }) {
AddWebFeedView() AddWebFeedView()
} }
@ -155,6 +158,9 @@ struct MainApp: App {
.environmentObject(sceneModel) .environmentObject(sceneModel)
.environmentObject(defaults) .environmentObject(defaults)
.modifier(PreferredColorSchemeModifier(preferredColorScheme: defaults.userInterfaceColorPalette)) .modifier(PreferredColorSchemeModifier(preferredColorScheme: defaults.userInterfaceColorPalette))
.onAppear {
sceneModel.startup()
}
} }
.commands { .commands {
CommandGroup(after: .newItem, addition: { CommandGroup(after: .newItem, addition: {

View File

@ -17,13 +17,12 @@ final class SceneModel: ObservableObject {
var timelineModel: TimelineModel? var timelineModel: TimelineModel?
var articleModel: ArticleModel? var articleModel: ArticleModel?
private let refreshProgressModel: RefreshProgressModel private var refreshProgressModel: RefreshProgressModel? = nil
init(refreshProgressModel: RefreshProgressModel = RefreshProgressModel()) { func startup() {
self.refreshProgressModel = refreshProgressModel self.refreshProgressModel = RefreshProgressModel()
self.refreshProgressModel.$state.assign(to: self.$refreshProgressState) self.refreshProgressModel!.$state.assign(to: self.$refreshProgressState)
} }
} }
// MARK: SidebarModelDelegate // MARK: SidebarModelDelegate