Skip to content

Commit

Permalink
Fix brave/brave-ios#7213: Block Playlist from showing up on Brave-Talk (
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon-T authored Apr 6, 2023
1 parent 0f95196 commit 331185a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ class PlaylistScriptHandler: NSObject, TabContentScript {
return
}

// If this URL is blocked from Playlist support, do nothing
if url?.isPlaylistBlockedSiteURL == true {
return
}

if ReadyState.from(message: message) != nil {
return
}
Expand Down Expand Up @@ -216,6 +221,12 @@ extension PlaylistScriptHandler: UIGestureRecognizerDelegate {
if gestureRecognizer.state == .began,
let webView = tab?.webView,
Preferences.Playlist.enableLongPressAddToPlaylist.value {

// If this URL is blocked from Playlist support, do nothing
if url?.isPlaylistBlockedSiteURL == true {
return
}

let touchPoint = gestureRecognizer.location(in: webView)

webView.evaluateSafeJavaScript(functionName: "window.__firefox__.\(PlaylistScriptHandler.playlistLongPressed)",
Expand Down
5 changes: 5 additions & 0 deletions Sources/Shared/Extensions/URLExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,11 @@ extension URL {

return siteList.contains(where: urlHost.contains)
}

public var isPlaylistBlockedSiteURL: Bool {
let urlHost = self.host ?? self.hostSLD
return urlHost == "talk.brave.com"
}

public func uniquePathForFilename(_ filename: String) throws -> URL {
let basePath = self.appendingPathComponent(filename)
Expand Down

0 comments on commit 331185a

Please sign in to comment.