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

Commit

Permalink
Fix #4226: ReaderMode taking precedence over playlist (#4232)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon-T authored and iccub committed Sep 27, 2021
1 parent f16e658 commit d79cc9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1177,10 +1177,12 @@ class BrowserViewController: UIViewController {
UIAccessibility.post(notification: .screenChanged, argument: nil)

// Refresh the reading view toolbar since the article record may have changed
if let readerMode = self.tabManager.selectedTab?.getContentScript(name: ReaderMode.name()) as? ReaderMode,
if let tab = self.tabManager.selectedTab,
let readerMode = tab.getContentScript(name: ReaderMode.name()) as? ReaderMode,
readerMode.state == .active,
isReaderModeURL {
self.showReaderModeBar(animated: false)
self.updatePlaylistURLBar(tab: tab, state: tab.playlistItemState, item: tab.playlistItem)
}
})
}
Expand Down Expand Up @@ -1487,6 +1489,7 @@ class BrowserViewController: UIViewController {
}

updateInContentHomePanel(url as URL)
updatePlaylistURLBar(tab: tab, state: tab.playlistItemState, item: tab.playlistItem)
}
}

Expand Down Expand Up @@ -2227,13 +2230,16 @@ extension BrowserViewController: TabManagerDelegate {

let shouldShowPlaylistURLBarButton = selected?.url?.isPlaylistSupportedSiteURL == true

if let readerMode = selected?.getContentScript(name: ReaderMode.name()) as? ReaderMode, !shouldShowPlaylistURLBarButton {
if let selected = selected,
let readerMode = selected.getContentScript(name: ReaderMode.name()) as? ReaderMode, !shouldShowPlaylistURLBarButton {
topToolbar.updateReaderModeState(readerMode.state)
if readerMode.state == .active {
showReaderModeBar(animated: false)
} else {
hideReaderModeBar(animated: false)
}

updatePlaylistURLBar(tab: selected, state: selected.playlistItemState, item: selected.playlistItem)
} else {
topToolbar.updateReaderModeState(ReaderModeState.unavailable)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ extension BrowserViewController: PlaylistHelperDelegate {
topToolbar.menuButton.removeBadge(.playlist, animated: true)
toolbar?.menuButton.removeBadge(.playlist, animated: true)
case .newItem:
if shouldShowPlaylistURLBarButton {
topToolbar.locationView.readerModeState = .unavailable
}
playlistButton.buttonState = shouldShowPlaylistURLBarButton ? .addToPlaylist : .none
if Preferences.Playlist.enablePlaylistMenuBadge.value {
topToolbar.menuButton.addBadge(.playlist, animated: true)
Expand All @@ -97,6 +100,9 @@ extension BrowserViewController: PlaylistHelperDelegate {
toolbar?.menuButton.removeBadge(.playlist, animated: true)
}
case .existingItem:
if shouldShowPlaylistURLBarButton {
topToolbar.locationView.readerModeState = .unavailable
}
playlistButton.buttonState = shouldShowPlaylistURLBarButton ? .addedToPlaylist : .none
topToolbar.menuButton.removeBadge(.playlist, animated: true)
toolbar?.menuButton.removeBadge(.playlist, animated: true)
Expand Down

0 comments on commit d79cc9f

Please sign in to comment.