Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Revert "Fix #3033: Reload cards when Today publishers are changed (#3208
Browse files Browse the repository at this point in the history
)"

This reverts commit 4a76288.
  • Loading branch information
iccub committed Jan 26, 2021
1 parent 099c64c commit b725358
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions Client/Frontend/Brave Today/Composer/FeedDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class FeedDataSource {
case .loading:
return false
case .success:
return isFeedContentExpired || isSourcesExpired || needsReloadCards
return isFeedContentExpired || isSourcesExpired
}
}

Expand Down Expand Up @@ -371,9 +371,7 @@ class FeedDataSource {
if let cards = state.cards, cards.isEmpty && enabled {
// If we're enabling a source and we don't have any items because their source selection was
// causing an empty generation, regenerate the cards
reloadCards(from: self.items, sources: self.sources)
} else {
needsReloadCards = true
self.reloadCards(from: self.items, sources: self.sources)
}
}

Expand All @@ -388,30 +386,23 @@ class FeedDataSource {
if let cards = state.cards, cards.isEmpty && enabled {
// If we're enabling a category and we don't have any items because their source selection was
// causing an empty generation, regenerate the cards
reloadCards(from: self.items, sources: self.sources)
} else {
needsReloadCards = true
self.reloadCards(from: self.items, sources: self.sources)
}
}

/// Reset all source settings back to default
func resetSourcesToDefault() {
FeedSourceOverride.resetSourceSelection()
needsReloadCards = true
}

// MARK: - Card Generation

/// Whether or not cards need to be reloaded next time we attempt to request state data
private var needsReloadCards = false

/// Scores and generates cards from a set of items and sources
private func reloadCards(
from items: [FeedItem.Content],
sources: [FeedItem.Source],
completion: (() -> Void)? = nil
) {
needsReloadCards = false
// Only allow 1 reload at a time
// Since the scoring/generation work hops between threads a lot it would be possible for reloads to
// mess up the ending state or update the cards
Expand Down

0 comments on commit b725358

Please sign in to comment.