Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions app/src/ui/services/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ fn kind_key(kind: NoticeKind) -> &'static str {
NoticeKind::UpdateApplied => "update-applied",
NoticeKind::TaskFinished => "task-finished",
NoticeKind::TaskFailed => "task-error",
NoticeKind::TaskCancelled => "task-cancelled",
NoticeKind::GameCrashed => "game-crashed",
NoticeKind::SetupSkipped => "setup-skipped",
NoticeKind::MinecraftReleased => "minecraft-released",
Expand All @@ -279,7 +278,6 @@ fn kind_icon(kind: NoticeKind) -> &'static str {
NoticeKind::UpdateApplied => "checkmark-outline",
NoticeKind::TaskFinished => "checkmark-outline",
NoticeKind::TaskFailed => "warning",
NoticeKind::TaskCancelled => "ban",
NoticeKind::GameCrashed => "warning",
NoticeKind::SetupSkipped => "refresh",
NoticeKind::MinecraftReleased => "minecraft",
Expand Down Expand Up @@ -335,8 +333,8 @@ mod tests {
#[test]
fn new_notices_go_to_the_front_of_both_models() {
let controller = NotificationController::new();
controller.send(Notice::new(NoticeKind::TaskCancelled));
controller.send(Notice::new(NoticeKind::TaskFinished));
controller.send(Notice::new(NoticeKind::TaskFailed));

let first = controller.notifications.row_data(0).expect("newest notice");
let preview = controller.toasts.row_data(0).expect("newest preview");
Expand Down Expand Up @@ -400,7 +398,7 @@ mod tests {
#[test]
fn a_plain_notice_is_not_actionable() {
let controller = NotificationController::new();
controller.send(Notice::new(NoticeKind::TaskCancelled));
controller.send(Notice::new(NoticeKind::TaskFailed));

let item = controller.notifications.row_data(0).expect("one notice");
assert!(!item.has_action);
Expand Down
30 changes: 17 additions & 13 deletions app/src/usecases/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

//! The task centre: the application's scheduler of long-running work.
//!
//! It owns the ids, the ordering, the cancellation policy and the completion
//! notices; a task is removed when it ends, because a finished task becomes a
//! notification. `submit` hands over the description and the work, and nothing
//! runs until the centre admits it — a task waits while its lane is full. A
//! launch is not scheduled here: [`TaskCenter::reserve_exclusive`] lets it wait
//! for the centre to go idle and then hold the exclusive lane itself.
//! It owns the ids, the ordering, the cancellation policy and the end-of-task
//! notices: a task that finishes or fails becomes a notification, while the
//! cancel the user just asked for does not. `submit` hands over the description
//! and the work, and nothing runs until the centre admits it — a task waits
//! while its lane is full. A launch is not scheduled here:
//! [`TaskCenter::reserve_exclusive`] lets it wait for the centre to go idle and
//! then hold the exclusive lane itself.

use std::{
collections::{HashMap, VecDeque},
Expand Down Expand Up @@ -399,7 +400,9 @@ impl TaskCenter {
id,
outcome: outcome.clone(),
});
(self.notices)(notice_for(&spec, &outcome, &self.action));
if let Some(notice) = notice_for(&spec, &outcome, &self.action) {
(self.notices)(notice);
}
self.drain();
}

Expand Down Expand Up @@ -436,17 +439,18 @@ fn instance_of(target: &TaskTarget) -> Option<&str> {
}
}

fn notice_for(spec: &TaskSpec, outcome: &TaskOutcome, action: &TaskNoticeAction) -> Notice {
fn notice_for(spec: &TaskSpec, outcome: &TaskOutcome, action: &TaskNoticeAction) -> Option<Notice> {
match outcome {
TaskOutcome::Completed => {
let mut notice = Notice::new(NoticeKind::TaskFinished)
.with_arg(spec.subject.clone())
.with_arg(spec.kind.key());
notice.action = action(&spec.target);
notice
Some(notice)
}
TaskOutcome::Failed(error) => Notice::new(NoticeKind::TaskFailed).with_arg(error),
TaskOutcome::Cancelled => Notice::new(NoticeKind::TaskCancelled).with_arg(&spec.subject),
TaskOutcome::Failed(error) => Some(Notice::new(NoticeKind::TaskFailed).with_arg(error)),
// The user did it; telling them what they just did is noise.
TaskOutcome::Cancelled => None,
}
}

Expand Down Expand Up @@ -779,7 +783,7 @@ mod tests {
}

#[test]
fn a_short_task_cancels_immediately() {
fn a_short_task_cancels_immediately_without_a_notice() {
let (center, events, notices) = centre();
let runs = Arc::new(AtomicUsize::new(0));
let cancelled = Arc::new(AtomicBool::new(false));
Expand All @@ -795,7 +799,7 @@ mod tests {
..
})
));
assert_eq!(lock(&notices)[0].kind, NoticeKind::TaskCancelled);
assert!(lock(&notices).is_empty());
}

#[test]
Expand Down
1 change: 0 additions & 1 deletion crates/shared/src/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub enum NoticeKind {
TaskFinished,
/// `args[0]` is the failure detail.
TaskFailed,
TaskCancelled,
/// `args[0]` is the crashed instance's display name.
GameCrashed,
SetupSkipped,
Expand Down
2 changes: 2 additions & 0 deletions tools/update-i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@
("NotificationText", "Launcher update ready"),
("NotificationText", "Task failed"),
("NotificationText", "Task cancelled"),
# A cancel is the user's own click, so it posts no notice any more.
("NotificationText", "The task was cancelled"),
("NotificationText", "Minecraft task finished"),
("NotificationText", "Notification"),
("NotificationText", "Setup skipped"),
Expand Down
3 changes: 0 additions & 3 deletions ui/globals/notifications.slint
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ export global NotificationText {
if item.kind == "task-error" {
return @tr("NotificationText" => "{}", arg(item, 0));
}
if item.kind == "task-cancelled" {
return @tr("NotificationText" => "The task was cancelled");
}
if item.kind == "task-finished" {
if arg(item, 1) == "content-download" || arg(item, 1) == "library-download" {
return @tr("NotificationText" => "{} downloaded. Click here to view", arg(item, 0));
Expand Down
5 changes: 0 additions & 5 deletions ui/i18n/de_DE/LC_MESSAGES/conic-ui.po
Original file line number Diff line number Diff line change
Expand Up @@ -3183,11 +3183,6 @@ msgctxt "NotificationText"
msgid "{}"
msgstr "{}"

#: ui
msgctxt "NotificationText"
msgid "The task was cancelled"
msgstr "Die Aufgabe wurde abgebrochen"

#: ui
msgctxt "NotificationText"
msgid "The task finished"
Expand Down
5 changes: 0 additions & 5 deletions ui/i18n/en_US/LC_MESSAGES/conic-ui.po
Original file line number Diff line number Diff line change
Expand Up @@ -3188,11 +3188,6 @@ msgctxt "NotificationText"
msgid "{}"
msgstr "{}"

#: ui
msgctxt "NotificationText"
msgid "The task was cancelled"
msgstr "The task was cancelled"

#: ui
msgctxt "NotificationText"
msgid "The task finished"
Expand Down
5 changes: 0 additions & 5 deletions ui/i18n/es_ES/LC_MESSAGES/conic-ui.po
Original file line number Diff line number Diff line change
Expand Up @@ -3183,11 +3183,6 @@ msgctxt "NotificationText"
msgid "{}"
msgstr "{}"

#: ui
msgctxt "NotificationText"
msgid "The task was cancelled"
msgstr "La tarea fue cancelada"

#: ui
msgctxt "NotificationText"
msgid "The task finished"
Expand Down
5 changes: 0 additions & 5 deletions ui/i18n/fr_FR/LC_MESSAGES/conic-ui.po
Original file line number Diff line number Diff line change
Expand Up @@ -3183,11 +3183,6 @@ msgctxt "NotificationText"
msgid "{}"
msgstr "{}"

#: ui
msgctxt "NotificationText"
msgid "The task was cancelled"
msgstr "La tâche a été annulée"

#: ui
msgctxt "NotificationText"
msgid "The task finished"
Expand Down
5 changes: 0 additions & 5 deletions ui/i18n/ja_JP/LC_MESSAGES/conic-ui.po
Original file line number Diff line number Diff line change
Expand Up @@ -3183,11 +3183,6 @@ msgctxt "NotificationText"
msgid "{}"
msgstr "{}"

#: ui
msgctxt "NotificationText"
msgid "The task was cancelled"
msgstr "タスクはキャンセルされました"

#: ui
msgctxt "NotificationText"
msgid "The task finished"
Expand Down
5 changes: 0 additions & 5 deletions ui/i18n/ko_KR/LC_MESSAGES/conic-ui.po
Original file line number Diff line number Diff line change
Expand Up @@ -3183,11 +3183,6 @@ msgctxt "NotificationText"
msgid "{}"
msgstr "{}"

#: ui
msgctxt "NotificationText"
msgid "The task was cancelled"
msgstr "작업이 취소되었습니다"

#: ui
msgctxt "NotificationText"
msgid "The task finished"
Expand Down
5 changes: 0 additions & 5 deletions ui/i18n/pl_PL/LC_MESSAGES/conic-ui.po
Original file line number Diff line number Diff line change
Expand Up @@ -3183,11 +3183,6 @@ msgctxt "NotificationText"
msgid "{}"
msgstr "{}"

#: ui
msgctxt "NotificationText"
msgid "The task was cancelled"
msgstr "Zadanie zostało anulowane"

#: ui
msgctxt "NotificationText"
msgid "The task finished"
Expand Down
5 changes: 0 additions & 5 deletions ui/i18n/pt_BR/LC_MESSAGES/conic-ui.po
Original file line number Diff line number Diff line change
Expand Up @@ -3183,11 +3183,6 @@ msgctxt "NotificationText"
msgid "{}"
msgstr "{}"

#: ui
msgctxt "NotificationText"
msgid "The task was cancelled"
msgstr "A tarefa foi cancelada"

#: ui
msgctxt "NotificationText"
msgid "The task finished"
Expand Down
5 changes: 0 additions & 5 deletions ui/i18n/ru_RU/LC_MESSAGES/conic-ui.po
Original file line number Diff line number Diff line change
Expand Up @@ -3183,11 +3183,6 @@ msgctxt "NotificationText"
msgid "{}"
msgstr "{}"

#: ui
msgctxt "NotificationText"
msgid "The task was cancelled"
msgstr "Задача была отменена"

#: ui
msgctxt "NotificationText"
msgid "The task finished"
Expand Down
5 changes: 0 additions & 5 deletions ui/i18n/tr_TR/LC_MESSAGES/conic-ui.po
Original file line number Diff line number Diff line change
Expand Up @@ -3183,11 +3183,6 @@ msgctxt "NotificationText"
msgid "{}"
msgstr "{}"

#: ui
msgctxt "NotificationText"
msgid "The task was cancelled"
msgstr "Görev iptal edildi"

#: ui
msgctxt "NotificationText"
msgid "The task finished"
Expand Down
5 changes: 0 additions & 5 deletions ui/i18n/zh_CN/LC_MESSAGES/conic-ui.po
Original file line number Diff line number Diff line change
Expand Up @@ -3078,11 +3078,6 @@ msgctxt "NotificationText"
msgid "{}"
msgstr "{}"

#: ui
msgctxt "NotificationText"
msgid "The task was cancelled"
msgstr "任务已取消"

#: ui
msgctxt "NotificationText"
msgid "The task finished"
Expand Down
5 changes: 0 additions & 5 deletions ui/i18n/zh_TW/LC_MESSAGES/conic-ui.po
Original file line number Diff line number Diff line change
Expand Up @@ -3183,11 +3183,6 @@ msgctxt "NotificationText"
msgid "{}"
msgstr "{}"

#: ui
msgctxt "NotificationText"
msgid "The task was cancelled"
msgstr "工作已取消"

#: ui
msgctxt "NotificationText"
msgid "The task finished"
Expand Down
Loading