Skip to content

Commit 130f315

Browse files
committed
Request for background access on app start only if set in preference
1 parent 6c12807 commit 130f315

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/window.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ mod imp {
214214
obj.setup_connection_monitors();
215215
obj.setup_notification_actions_monitor();
216216
obj.setup_rqs_service();
217-
obj.request_background();
217+
obj.request_background_at_start();
218218
}
219219
}
220220

@@ -965,12 +965,15 @@ impl PacketApplicationWindow {
965965
}
966966
}
967967

968-
fn request_background(&self) {
968+
fn request_background_at_start(&self) {
969969
glib::spawn_future_local(clone!(
970970
#[weak(rename_to = this)]
971971
self,
972972
async move {
973973
let is_run_in_background = this.imp().settings.boolean("run-in-background");
974+
if !is_run_in_background {
975+
return;
976+
}
974977
if let Some(response) = this.portal_request_background().await {
975978
tracing::debug!(?response, "Background request successful");
976979

@@ -981,7 +984,7 @@ impl PacketApplicationWindow {
981984
app.imp().start_in_background.replace(false);
982985
}
983986
}
984-
} else if is_run_in_background {
987+
} else {
985988
this.add_toast(&gettext("Packet cannot run in the background"));
986989
}
987990
}

0 commit comments

Comments
 (0)