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

Commit

Permalink
No Bug: Move Playlist backend into its own target (#8192)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehickinson authored Oct 5, 2023
1 parent ad6e168 commit dcd7547
Show file tree
Hide file tree
Showing 66 changed files with 656 additions and 570 deletions.
14 changes: 14 additions & 0 deletions App/Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
27466BB1288EDB9C00584C90 /* RuntimeWarnings in Frameworks */ = {isa = PBXBuildFile; productRef = 27466BB0288EDB9C00584C90 /* RuntimeWarnings */; };
2759468D29CCB62F0094BDDE /* GRDWireGuardKit in Frameworks */ = {isa = PBXBuildFile; productRef = 2759468C29CCB62F0094BDDE /* GRDWireGuardKit */; };
2759468F29CCB6350094BDDE /* GRDWireGuardKit in Frameworks */ = {isa = PBXBuildFile; productRef = 2759468E29CCB6350094BDDE /* GRDWireGuardKit */; };
278852E42ACDC26B005395CF /* Playlist in Frameworks */ = {isa = PBXBuildFile; productRef = 278852E32ACDC26B005395CF /* Playlist */; };
278852E62ACDE795005395CF /* UserAgent in Frameworks */ = {isa = PBXBuildFile; productRef = 278852E52ACDE795005395CF /* UserAgent */; };
278BB9FF297B0A1E00690BE3 /* TopNewsListWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 278BB9FE297B0A1E00690BE3 /* TopNewsListWidget.swift */; };
279A828E28FEF01E00F55A5E /* BraveWidgets.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = CA0391E5271E1382000EB13C /* BraveWidgets.intentdefinition */; settings = {ATTRIBUTES = (no_codegen, ); }; };
279A829228FEF0BF00F55A5E /* BraveShared in Frameworks */ = {isa = PBXBuildFile; productRef = 279A829128FEF0BF00F55A5E /* BraveShared */; };
Expand Down Expand Up @@ -356,7 +358,9 @@
27D7FF5329BA69330096DD93 /* BraveShields in Frameworks */,
27FA217F2837FB0100FA2C45 /* BraveShared in Frameworks */,
27D7FF7329BB816E0096DD93 /* PrivateCDN in Frameworks */,
278852E62ACDE795005395CF /* UserAgent in Frameworks */,
27FA21812837FB0100FA2C45 /* BraveWallet in Frameworks */,
278852E42ACDC26B005395CF /* Playlist in Frameworks */,
0A1DF486244A2ECB00541FE4 /* NetworkExtension.framework in Frameworks */,
27466BB1288EDB9C00584C90 /* RuntimeWarnings in Frameworks */,
);
Expand Down Expand Up @@ -798,6 +802,8 @@
27C1C5EC29B6AA8800739BE5 /* Preferences */,
27D7FF5229BA69330096DD93 /* BraveShields */,
27D7FF7229BB816E0096DD93 /* PrivateCDN */,
278852E32ACDC26B005395CF /* Playlist */,
278852E52ACDE795005395CF /* UserAgent */,
);
productName = Client;
productReference = F84B21BE1A090F8100AAB793 /* Client.app */;
Expand Down Expand Up @@ -3130,6 +3136,14 @@
isa = XCSwiftPackageProductDependency;
productName = GRDWireGuardKit;
};
278852E32ACDC26B005395CF /* Playlist */ = {
isa = XCSwiftPackageProductDependency;
productName = Playlist;
};
278852E52ACDE795005395CF /* UserAgent */ = {
isa = XCSwiftPackageProductDependency;
productName = UserAgent;
};
279A829128FEF0BF00F55A5E /* BraveShared */ = {
isa = XCSwiftPackageProductDependency;
productName = BraveShared;
Expand Down
2 changes: 2 additions & 0 deletions App/iOS/Delegates/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import BraveWallet
import Preferences
import BraveShields
import PrivateCDN
import Playlist
import UserAgent

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand Down
1 change: 1 addition & 0 deletions App/iOS/Delegates/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Preferences
import Storage
import BraveNews
import os.log
import UserAgent

private let adsRewardsLog = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "ads-rewards")

Expand Down
11 changes: 11 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ var package = Package(
.library(name: "Preferences", targets: ["Preferences"]),
.library(name: "PrivateCDN", targets: ["PrivateCDN"]),
.library(name: "CertificateUtilities", targets: ["CertificateUtilities"]),
.library(name: "Playlist", targets: ["Playlist"]),
.library(name: "UserAgent", targets: ["UserAgent"]),
.executable(name: "LeoAssetCatalogGenerator", targets: ["LeoAssetCatalogGenerator"]),
.plugin(name: "IntentBuilderPlugin", targets: ["IntentBuilderPlugin"]),
.plugin(name: "LoggerPlugin", targets: ["LoggerPlugin"]),
Expand Down Expand Up @@ -280,6 +282,8 @@ var package = Package(
],
plugins: ["LoggerPlugin"]
),
.target(name: "UserAgent", dependencies: ["Preferences"]),
.testTarget(name: "UserAgentTests", dependencies: ["UserAgent", "Brave"]),
.testTarget(name: "SharedTests", dependencies: ["Shared"]),
.testTarget(
name: "BraveSharedTests",
Expand Down Expand Up @@ -321,6 +325,11 @@ var package = Package(
.target(name: "Strings"),
.target(name: "RuntimeWarnings"),
.target(name: "PrivateCDN", dependencies: ["SDWebImage"]),
.target(
name: "Playlist",
dependencies: ["Data", "BraveShared", "Shared", "Storage", "Preferences", "Strings", "CodableHelpers", "UserAgent", "Then"],
plugins: ["LoggerPlugin"]
),
.testTarget(name: "PrivateCDNTests", dependencies: ["PrivateCDN"]),
.testTarget(name: "GrowthTests", dependencies: ["Growth", "Shared", "BraveShared", "BraveVPN"]),
.plugin(name: "IntentBuilderPlugin", capability: .buildTool()),
Expand Down Expand Up @@ -359,6 +368,8 @@ var braveTarget: PackageDescription.Target = .target(
"Preferences",
"Favicon",
"CertificateUtilities",
"Playlist",
"UserAgent",
.product(name: "Lottie", package: "lottie-ios"),
.product(name: "Collections", package: "swift-collections"),
],
Expand Down
1 change: 1 addition & 0 deletions Sources/Brave/Frontend/Browser/BraveWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Foundation
import WebKit
import Shared
import BraveShared
import UserAgent

class BraveWebView: WKWebView {
lazy var findInPageDelegate: WKWebViewFindStringFindDelegate? = {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Brave/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ public class BrowserViewController: UIViewController {
// Observe some user preferences
Preferences.Privacy.privateBrowsingOnly.observe(from: self)
Preferences.General.tabBarVisibility.observe(from: self)
Preferences.General.alwaysRequestDesktopSite.observe(from: self)
Preferences.UserAgent.alwaysRequestDesktopSite.observe(from: self)
Preferences.General.enablePullToRefresh.observe(from: self)
Preferences.General.mediaAutoBackgrounding.observe(from: self)
Preferences.General.youtubeHighQuality.observe(from: self)
Expand Down Expand Up @@ -3099,7 +3099,7 @@ extension BrowserViewController: PreferencesObserver {
setupTabs()
updateTabsBarVisibility()
updateApplicationShortcuts()
case Preferences.General.alwaysRequestDesktopSite.key:
case Preferences.UserAgent.alwaysRequestDesktopSite.key:
tabManager.reset()
tabManager.reloadSelectedTab()
case Preferences.General.enablePullToRefresh.key:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import BraveWallet
import Preferences
import CertificateUtilities
import AVFoundation
import Playlist

// MARK: - TopToolbarDelegate

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Favicon
import Growth
import SafariServices
import LocalAuthentication
import BraveShared

extension WKNavigationAction {
/// Allow local requests only if the request is privileged.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import UIKit
import Growth
import os.log
import Onboarding
import Playlist

extension BrowserViewController: PlaylistScriptHandlerDelegate, PlaylistFolderSharingScriptHandlerDelegate {
static var didShowStorageFullWarning = false
func createPlaylistPopover(item: PlaylistInfo, tab: Tab?) -> PopoverController {

let folderName = PlaylistItem.getItem(uuid: item.tagId)?.playlistFolder?.title ?? Strings.PlaylistFolders.playlistSavedFolderTitle
let folderName = PlaylistItem.getItem(uuid: item.tagId)?.playlistFolder?.title ?? Strings.Playlist.defaultPlaylistTitle

return PopoverController(
content: PlaylistPopoverView(folderName: folderName) { [weak self] action in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Shared
import CoreData
import Favicon
import os.log
import Playlist

private enum PlaylistCarPlayTemplateID: String {
case folders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Preferences
import Shared
import Data
import UIKit
import Playlist

class PlaylistDetailViewController: UIViewController, UIGestureRecognizerDelegate {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Shared
import BraveShared
import os.log
import Growth
import Playlist

private enum Section: Int, CaseIterable {
case savedItems
Expand Down Expand Up @@ -201,7 +202,7 @@ extension PlaylistFolderController: UITableViewDataSource {
let itemCount = savedFolder?.playlistItems?.count ?? 0

cell.imageView?.image = folderIcon
cell.textLabel?.text = Strings.PlaylistFolders.playlistSavedFolderTitle
cell.textLabel?.text = Strings.Playlist.defaultPlaylistTitle
cell.detailTextLabel?.text = "\(itemCount == 1 ? Strings.PlaylistFolders.playlistFolderSubtitleItemSingleCount : String.localizedStringWithFormat(Strings.PlaylistFolders.playlistFolderSubtitleItemCount, itemCount))"
cell.detailTextLabel?.textColor = .secondaryBraveLabel
cell.accessoryType = .disclosureIndicator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import Foundation
import UIKit
import BraveUI
import Playlist

// MARK: - Reordering of cells

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import BraveUI
import Preferences
import Favicon
import os.log
import Playlist

// MARK: UITableViewDataSource

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Data
import MediaPlayer
import os.log
import Preferences
import Playlist

private extension PlaylistListViewController {
func shareItem(_ item: PlaylistInfo, anchorView: UIView?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import AVKit
import CoreData
import Combine
import os.log
import BraveShared

// Third-Party
import SDWebImage
Expand All @@ -19,6 +20,7 @@ import Shared
import Data
import SwiftUI
import Growth
import Playlist

// MARK: - PlaylistListViewController

Expand Down Expand Up @@ -704,7 +706,7 @@ extension PlaylistListViewController {
}
}

let items = try await PlaylistSharedFolderNetwork.fetchMediaItemInfo(item: model, viewForInvisibleWebView: self.playerView.window ?? self.playerView.superview ?? self.playerView)
let items = try await PlaylistSharedFolderNetwork.fetchMediaItemInfo(item: model, viewForInvisibleWebView: self.playerView.window ?? self.playerView.superview ?? self.playerView, webLoaderFactory: LivePlaylistWebLoaderFactory())
try Task.checkCancellation()

try folder.playlistItems?.forEach({ playlistItem in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import CoreData
import Shared
import BraveShared
import BraveUI
import Playlist

private struct PlaylistFolderImage: View {
let item: PlaylistItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import AVFoundation
import CarPlay
import MediaPlayer
import Combine

import Playlist
import Preferences
import Shared
import SDWebImage
Expand Down Expand Up @@ -76,7 +76,7 @@ class PlaylistViewController: UIViewController {
self.openInNewTab = openInNewTab
self.openPlaylistSettingsMenu = openPlaylistSettingsMenu
self.player = mediaPlayer
self.mediaStreamer = PlaylistMediaStreamer(playerView: playerView)
self.mediaStreamer = PlaylistMediaStreamer(playerView: playerView, webLoaderFactory: LivePlaylistWebLoaderFactory())
self.isPrivateBrowsing = isPrivateBrowsing
self.folderSharingUrl = nil

Expand Down
Loading

0 comments on commit dcd7547

Please sign in to comment.