Просмотр исходного кода

app: fix first time startup. UI can be restarted but App remains persistant so we must also set the first_time flag to false.

darkfi 1 день назад
Родитель
Сommit
b29e981a6e
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      bin/app/src/app/mod.rs

+ 4 - 1
bin/app/src/app/mod.rs

@@ -212,7 +212,10 @@ impl App {
     /// Begins the draw of the tree, and then starts the UI procs.
     /// Begins the draw of the tree, and then starts the UI procs.
     pub async fn start(self: Arc<Self>, event_pub: GraphicsEventPublisherPtr, epoch: EpochIndex) {
     pub async fn start(self: Arc<Self>, event_pub: GraphicsEventPublisherPtr, epoch: EpochIndex) {
         d!("Starting app epoch={epoch}");
         d!("Starting app epoch={epoch}");
-        if self.is_first_time.load(Ordering::Relaxed) {
+        // On Android the foreground service keeps the process alive across
+        // UI restarts, so start() runs on every relaunch. swap() consumes
+        // the flag so the sound only plays on the very first launch.
+        if self.is_first_time.swap(false, Ordering::Relaxed) {
             sfx::play_commup();
             sfx::play_commup();
         }
         }
         let mut atom = PropertyAtomicGuard::none();
         let mut atom = PropertyAtomicGuard::none();