Triggering onAppear Once or Capturing Button Click Events in DestinationVideo Demo

In the DestinationVideo demo, the onAppear in UpNextView is triggered again when it is closed, but I only want it to be triggered once. How can I achieve this?

Alternatively, I would like to capture the button click events in the player menu, as shown in the screenshot below.

I use this for making something happen only once. Put it into an Extensions.swift file or something like that:

extension View {
func onFirstAppear(perform: @escaping () -> Void) -> some View {
modifier(OnFirstAppear(perform: perform))
}
}
private struct OnFirstAppear: ViewModifier {
let perform: () -> Void
@State private var firstTime = true
func body(content: Content) -> some View {
content.onAppear {
if firstTime {
firstTime = false
perform()
}
}
}
}

And you use it like you would use .onAppear, i.e.:

.onFirstAppear {
// Do something once
}
Triggering onAppear Once or Capturing Button Click Events in DestinationVideo Demo
 
 
Q