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)
.environmentObject(sceneModel)
.environmentObject(defaults)
.onAppear {
sceneModel.startup()
}
.sheet(isPresented: $showSheet, onDismiss: { showSheet = false }) {
AddWebFeedView()
}
@ -155,6 +158,9 @@ struct MainApp: App {
.environmentObject(sceneModel)
.environmentObject(defaults)
.modifier(PreferredColorSchemeModifier(preferredColorScheme: defaults.userInterfaceColorPalette))
.onAppear {
sceneModel.startup()
}
}
.commands {
CommandGroup(after: .newItem, addition: {

View File

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