Remove strong self references

This commit is contained in:
Aiden Vigue 2021-05-22 18:44:39 -04:00
parent fdea0d4573
commit 1389b54b98
7 changed files with 24 additions and 21 deletions

View File

@ -33,7 +33,7 @@ struct HostingWindowFinder: UIViewRepresentable {
func makeUIView(context: Context) -> UIView {
let view = UIView()
DispatchQueue.main.async { [weak view] in
self.callback(view?.window)
callback(view?.window)
}
return view
}
@ -348,7 +348,7 @@ struct ContentView: View {
if(!needsToSelectServer && !isSignInErrored) {
VStack(alignment: .leading) {
ScrollView() {
Spacer().frame(height: self.isPortrait ? 0 : 15)
Spacer().frame(height: isPortrait ? 0 : 15)
ContinueWatchingView()
NextUpView().padding(EdgeInsets(top: 4, leading: 0, bottom: 0, trailing: 0))
ForEach(librariesShowRecentlyAdded, id: \.self) { library_id in
@ -377,7 +377,7 @@ struct ContentView: View {
Image(systemName: "gear")
}
}
}.popover( isPresented: self.$showSettingsPopover, arrowEdge: .bottom) { SettingsView(close: $showSettingsPopover).environmentObject(self.globalData) }
}.popover( isPresented: $showSettingsPopover, arrowEdge: .bottom) { SettingsView(close: $showSettingsPopover).environmentObject(globalData) }
}
.tabItem({
Text("Home")
@ -406,10 +406,10 @@ struct ContentView: View {
} else {
Text("Signing in...")
.onAppear(perform: {
DispatchQueue.main.async { [self] in
DispatchQueue.main.async { [weak self] in
_viewDidLoad.wrappedValue = false
usleep(500000);
self.jsi.did = false;
self?.jsi.did = false;
}
})
}

View File

@ -74,7 +74,7 @@ struct EpisodeItemView: View {
init(item: ResumeItem) {
self.item = item;
self.fullItem = DetailItem();
fullItem = DetailItem();
}
func lockOrientations() {

View File

@ -121,7 +121,7 @@ struct MovieItemView: View {
init(item: ResumeItem) {
self.item = item;
self.fullItem = DetailItem();
fullItem = DetailItem();
}
func lockOrientations() {

View File

@ -34,8 +34,8 @@ extension String {
return "\(padString)\(self)"
}
}
struct PlayerDemo: View {
@EnvironmentObject var globalData: GlobalData
var item: DetailItem;
@ -55,7 +55,7 @@ struct PlayerDemo: View {
@State private var captionConfiguration: Bool = false {
didSet {
if(captionConfiguration == false) {
DispatchQueue.global(qos: .userInitiated).async { [self] in
DispatchQueue.global(qos: .userInitiated).async { _ in
vlcplayer.pause()
usleep(10000);
vlcplayer.play()
@ -205,7 +205,7 @@ struct PlayerDemo: View {
func startStream() {
_streamLoading.wrappedValue = true;
let request = RestRequest(method: .post, url: (globalData.server?.baseURI ?? "") + "/Items/\(item.Id)/PlaybackInfo?UserId=\(globalData.user?.user_id ?? "")&StartTimeTicks=\(item.Progress)&IsPlayback=true&AutoOpenLiveStream=true&MaxStreamingBitrate=70000000")
let request = RestRequest(method: .post, url: (globalData.server?.baseURI ?? "") + "/Items/\(item.Id)/PlaybackInfo?UserId=\(globalData.user?.user_id ?? "")&StartTimeTicks=\(Int(item.Progress))&IsPlayback=true&AutoOpenLiveStream=true&MaxStreamingBitrate=70000000")
request.headerParameters["X-Emby-Authorization"] = globalData.authHeader
request.contentType = "application/json"
request.acceptType = "application/json"
@ -251,8 +251,8 @@ struct PlayerDemo: View {
_isPlaying.wrappedValue = true;
}
DispatchQueue.global(qos: .userInteractive).async { [self] in
self.keepUpWithPlayerState()
DispatchQueue.global(qos: .userInteractive).async { [weak self] in
self?.keepUpWithPlayerState()
}
} catch {
@ -361,8 +361,8 @@ struct PlayerDemo: View {
let videoDuration = Double(vlcplayer.time.intValue + abs(vlcplayer.remainingTime.intValue))
if(bool == true) {
vlcplayer.pause()
DispatchQueue.global(qos: .userInitiated).async { [self] in
self.processScrubbingState()
DispatchQueue.global(qos: .userInitiated).async { [weak self] in
self?.processScrubbingState()
}
} else {
//Scrub is value from 0..1 - find position in video and add / or remove.
@ -390,6 +390,11 @@ struct PlayerDemo: View {
.onAppear(perform: startStream)
.navigationBarHidden(true)
.navigationBarBackButtonHidden(true)
.prefersHomeIndicatorAutoHidden(true)
.preferredColorScheme(.dark)
.introspectTabBarController { (UITabBarController) in
UITabBarController.tabBar.isHidden = true
}
.statusBar(hidden: true)
.edgesIgnoringSafeArea(.all)
.onTapGesture(perform: resetTimer)

View File

@ -22,7 +22,7 @@ struct SeasonItemView: View {
@State private var hasAppearedOnce: Bool = false;
init(item: ResumeItem) {
self.item = item;
self.fullItem = DetailItem();
fullItem = DetailItem();
}
func loadData() {

View File

@ -85,7 +85,7 @@ struct SeriesItemView: View {
var body: some View {
LoadingView(isShowing: $isLoading) {
GeometryReader { geometry in
Grid(tracks: self.tracks, spacing: GridSpacing(horizontal: 0, vertical: 20)) {
Grid(tracks: tracks, spacing: GridSpacing(horizontal: 0, vertical: 20)) {
ForEach(items, id: \.Id) { item in
NavigationLink(destination: ItemView(item: item )) {
VStack(alignment: .leading) {
@ -131,7 +131,7 @@ struct SeriesItemView: View {
}.frame(width: 100)
}
}
Spacer().frame(height: 2).gridSpan(column: self.isPortrait ? 3 : 6)
Spacer().frame(height: 2).gridSpan(column: isPortrait ? 3 : 6)
}.gridContentMode(.scroll)
}
}

View File

@ -59,10 +59,8 @@ class PlayerUIView: UIView, VLCMediaPlayerDelegate {
func videoSetup() {
if(lastUrl == nil || lastUrl?.videoUrl != url.wrappedValue.videoUrl) {
lastUrl = url.wrappedValue
print("update called")
print(self.url.wrappedValue.videoUrl)
mediaPlayer.wrappedValue.stop()
mediaPlayer.wrappedValue.media = VLCMedia(url: self.url.wrappedValue.videoUrl)
mediaPlayer.wrappedValue.media = VLCMedia(url: url.wrappedValue.videoUrl)
self.url.wrappedValue.subtitles.forEach() { sub in
if(sub.id != -1 && sub.delivery == "External") {
mediaPlayer.wrappedValue.addPlaybackSlave(sub.url, type: .subtitle, enforce: false)
@ -70,7 +68,7 @@ class PlayerUIView: UIView, VLCMediaPlayerDelegate {
}
mediaPlayer.wrappedValue.perform(Selector(("setTextRendererFontSize:")), with: 14)
mediaPlayer.wrappedValue.perform(Selector(("setTextRendererFont:")), with: "Copperplate")
//mediaPlayer.wrappedValue.perform(Selector(("setTextRendererFont:")), with: "Copperplate")
mediaPlayer.wrappedValue.jumpForward(Int32(startTime/10000000))
mediaPlayer.wrappedValue.play()
}