Fix performance issue on launch — ignore structure changes while loading from OPML until after loading.
This commit is contained in:
parent
7fe5f94262
commit
9317874478
@ -331,7 +331,11 @@ public enum FetchType {
|
||||
|
||||
metadataFile.load()
|
||||
feedMetadataFile.load()
|
||||
opmlFile.load()
|
||||
BatchUpdate.shared.perform {
|
||||
if let opmlItems = opmlFile.opmlItems() {
|
||||
loadOPMLItems(opmlItems)
|
||||
}
|
||||
}
|
||||
|
||||
Task { @MainActor in
|
||||
try? await self.database.cleanupDatabaseAtStartup(subscribedToFeedIDs: self.flattenedFeeds().feedIDs())
|
||||
@ -752,6 +756,10 @@ public enum FetchType {
|
||||
// Feeds were added or deleted. Or folders added or deleted.
|
||||
// Or feeds inside folders were added or deleted.
|
||||
|
||||
guard !BatchUpdate.shared.isPerforming else {
|
||||
return
|
||||
}
|
||||
|
||||
logger.info("structureDidChange in account \(self.accountID)")
|
||||
|
||||
Task { @MainActor in
|
||||
@ -911,8 +919,10 @@ public enum FetchType {
|
||||
public func addFeed(_ feed: Feed) {
|
||||
topLevelFeeds.insert(feed)
|
||||
structureDidChange()
|
||||
if !BatchUpdate.shared.isPerforming {
|
||||
postChildrenDidChangeNotification()
|
||||
}
|
||||
}
|
||||
|
||||
func addFeedIfNotInAnyFolder(_ feed: Feed) {
|
||||
if !flattenedFeeds().contains(feed) {
|
||||
@ -972,6 +982,10 @@ public enum FetchType {
|
||||
}
|
||||
|
||||
@MainActor @objc func childrenDidChange(_ note: Notification) {
|
||||
|
||||
guard !BatchUpdate.shared.isPerforming else {
|
||||
return
|
||||
}
|
||||
guard let object = note.object else {
|
||||
return
|
||||
}
|
||||
|
@ -35,14 +35,12 @@ import Core
|
||||
dataFile.markAsDirty()
|
||||
}
|
||||
|
||||
func load() {
|
||||
guard let fileData = opmlFileData(), let opmlItems = parsedOPMLItems(fileData: fileData) else {
|
||||
return
|
||||
func opmlItems() -> [RSOPMLItem]? {
|
||||
guard let fileData = opmlFileData() else {
|
||||
return nil
|
||||
}
|
||||
|
||||
BatchUpdate.shared.perform {
|
||||
account.loadOPMLItems(opmlItems)
|
||||
}
|
||||
return parsedOPMLItems(fileData: fileData)
|
||||
}
|
||||
|
||||
func save() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user