diff --git a/src/Filee.App/Assets/i18n/ar.json b/src/Filee.App/Assets/i18n/ar.json index 19b5ed81d..7fa0f7949 100644 --- a/src/Filee.App/Assets/i18n/ar.json +++ b/src/Filee.App/Assets/i18n/ar.json @@ -63,6 +63,7 @@ "home.open_file": "فتح الملف", "home.open_with": "فتح باستخدام", "home.clear_history": "مسح", + "home.remove_from_history": "إزالة من السجل", "home.files": "عدد الملفات: {0}", "home.failed_files": "فشل: {0}", "home.undo": "تراجع", diff --git a/src/Filee.App/Assets/i18n/bn-BD.json b/src/Filee.App/Assets/i18n/bn-BD.json index 11c166f86..ab45ae4d3 100644 --- a/src/Filee.App/Assets/i18n/bn-BD.json +++ b/src/Filee.App/Assets/i18n/bn-BD.json @@ -77,6 +77,7 @@ "home.open_file": "ফাইল খুলুন", "home.open_with": "এর মাধ্যমে খুলুন", "home.clear_history": "মুছে ফেলুন", + "home.remove_from_history": "ইতিহাস থেকে সরান", "home.files": "{0}টি ফাইল", "home.failed_files": "{0}টি ব্যর্থ", "home.undo": "পূর্বাবস্থায় ফেরান", diff --git a/src/Filee.App/Assets/i18n/de.json b/src/Filee.App/Assets/i18n/de.json index a0752b95e..f74a37d95 100644 --- a/src/Filee.App/Assets/i18n/de.json +++ b/src/Filee.App/Assets/i18n/de.json @@ -63,6 +63,7 @@ "home.open_file": "Datei öffnen", "home.open_with": "Öffnen mit", "home.clear_history": "Leeren", + "home.remove_from_history": "Aus dem Verlauf entfernen", "home.files": "{0} Dateien", "home.failed_files": "{0} fehlgeschlagen", "home.undo": "Rückgängig", diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.json index 3fd090bcc..43af14cc0 100644 --- a/src/Filee.App/Assets/i18n/en.json +++ b/src/Filee.App/Assets/i18n/en.json @@ -66,6 +66,7 @@ "home.open_file": "Open file", "home.open_with": "Open with", "home.clear_history": "Clear", + "home.remove_from_history": "Remove from history", "home.files": "{0} files", "home.failed_files": "{0} failed", "home.undo": "Undo", diff --git a/src/Filee.App/Assets/i18n/es.json b/src/Filee.App/Assets/i18n/es.json index 92e0d4239..b9b74453e 100644 --- a/src/Filee.App/Assets/i18n/es.json +++ b/src/Filee.App/Assets/i18n/es.json @@ -63,6 +63,7 @@ "home.open_file": "Abrir archivo", "home.open_with": "Abrir con", "home.clear_history": "Borrar", + "home.remove_from_history": "Quitar del historial", "home.files": "{0} archivos", "home.failed_files": "{0} con error", "home.undo": "Deshacer", diff --git a/src/Filee.App/Assets/i18n/fa.json b/src/Filee.App/Assets/i18n/fa.json index 925321759..503f1e6cb 100644 --- a/src/Filee.App/Assets/i18n/fa.json +++ b/src/Filee.App/Assets/i18n/fa.json @@ -77,6 +77,7 @@ "home.open_file": "باز کردن فایل", "home.open_with": "باز کردن با", "home.clear_history": "پاک کردن", + "home.remove_from_history": "حذف از تاریخچه", "home.files": "{0} فایل", "home.failed_files": "{0} ناموفق", "home.undo": "واگرد", diff --git a/src/Filee.App/Assets/i18n/fr.json b/src/Filee.App/Assets/i18n/fr.json index fcc70ae58..5b25591ed 100644 --- a/src/Filee.App/Assets/i18n/fr.json +++ b/src/Filee.App/Assets/i18n/fr.json @@ -66,6 +66,7 @@ "home.open_file": "Ouvrir le fichier", "home.open_with": "Ouvrir avec", "home.clear_history": "Effacer", + "home.remove_from_history": "Retirer de l'historique", "home.files": "{0} fichiers", "home.failed_files": "{0} en échec", "home.undo": "Annuler", diff --git a/src/Filee.App/Assets/i18n/hi.json b/src/Filee.App/Assets/i18n/hi.json index 2ed15a5f9..647f22119 100644 --- a/src/Filee.App/Assets/i18n/hi.json +++ b/src/Filee.App/Assets/i18n/hi.json @@ -63,6 +63,7 @@ "home.open_file": "फ़ाइल खोलें", "home.open_with": "इसके साथ खोलें", "home.clear_history": "साफ़ करें", + "home.remove_from_history": "इतिहास से हटाएँ", "home.files": "{0} फ़ाइलें", "home.failed_files": "{0} विफल", "home.undo": "पूर्ववत करें", diff --git a/src/Filee.App/Assets/i18n/id.json b/src/Filee.App/Assets/i18n/id.json index cd3b82390..b095064f8 100644 --- a/src/Filee.App/Assets/i18n/id.json +++ b/src/Filee.App/Assets/i18n/id.json @@ -63,6 +63,7 @@ "home.open_file": "Buka file", "home.open_with": "Buka dengan", "home.clear_history": "Bersihkan", + "home.remove_from_history": "Hapus dari riwayat", "home.files": "{0} file", "home.failed_files": "{0} gagal", "home.undo": "Urungkan", diff --git a/src/Filee.App/Assets/i18n/it.json b/src/Filee.App/Assets/i18n/it.json index d630ede32..191bb158b 100644 --- a/src/Filee.App/Assets/i18n/it.json +++ b/src/Filee.App/Assets/i18n/it.json @@ -62,6 +62,7 @@ "home.open_file": "Apri file", "home.open_with": "Apri con", "home.clear_history": "Cancella", +"home.remove_from_history": "Rimuovi dalla cronologia", "home.files": "{0} file", "home.failed_files": "{0} non riusciti", "home.undo": "Annulla", diff --git a/src/Filee.App/Assets/i18n/ja.json b/src/Filee.App/Assets/i18n/ja.json index 648347088..b1ac47c86 100644 --- a/src/Filee.App/Assets/i18n/ja.json +++ b/src/Filee.App/Assets/i18n/ja.json @@ -63,6 +63,7 @@ "home.open_file": "ファイルを開く", "home.open_with": "プログラムから開く", "home.clear_history": "消去", + "home.remove_from_history": "履歴から削除", "home.files": "{0}個のファイル", "home.failed_files": "{0}件失敗", "home.undo": "元に戻す", diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.json index 6ef7553ab..9ee6496d7 100644 --- a/src/Filee.App/Assets/i18n/ko.json +++ b/src/Filee.App/Assets/i18n/ko.json @@ -66,6 +66,7 @@ "home.open_file": "파일 열기", "home.open_with": "연결 프로그램", "home.clear_history": "지우기", + "home.remove_from_history": "기록에서 제거", "home.files": "파일 {0}개", "home.failed_files": "{0}개 실패", "home.undo": "되돌리기", diff --git a/src/Filee.App/Assets/i18n/mn.json b/src/Filee.App/Assets/i18n/mn.json index 89063a2b6..e5af2f209 100644 --- a/src/Filee.App/Assets/i18n/mn.json +++ b/src/Filee.App/Assets/i18n/mn.json @@ -62,6 +62,7 @@ "home.open_file": "Файл нээх", "home.open_with": "Програмаар нээх", "home.clear_history": "Цэвэрлэх", + "home.remove_from_history": "Түүхээс устгах", "home.files": "{0} файл", "home.failed_files": "{0} амжилтгүй", "home.undo": "Буцаах", diff --git a/src/Filee.App/Assets/i18n/ne.json b/src/Filee.App/Assets/i18n/ne.json index 4b25a1b72..a318c2e1b 100644 --- a/src/Filee.App/Assets/i18n/ne.json +++ b/src/Filee.App/Assets/i18n/ne.json @@ -63,6 +63,7 @@ "home.open_file": "फाइल खोल्नुहोस्", "home.open_with": "यसमार्फत खोल्नुहोस्", "home.clear_history": "खाली गर्नुहोस्", + "home.remove_from_history": "इतिहासबाट हटाउनुहोस्", "home.files": "{0} फाइलहरू", "home.failed_files": "{0} असफल", "home.undo": "पूर्ववत गर्नुहोस्", diff --git a/src/Filee.App/Assets/i18n/pl.json b/src/Filee.App/Assets/i18n/pl.json index 665c48cbc..a651b06ac 100644 --- a/src/Filee.App/Assets/i18n/pl.json +++ b/src/Filee.App/Assets/i18n/pl.json @@ -66,6 +66,7 @@ "home.open_file": "Otwórz plik", "home.open_with": "Otwórz za pomocą", "home.clear_history": "Wyczyść", + "home.remove_from_history": "Usuń z historii", "home.files": "Pliki: {0}", "home.failed_files": "Błędy: {0}", "home.undo": "Cofnij", diff --git a/src/Filee.App/Assets/i18n/pt-BR.json b/src/Filee.App/Assets/i18n/pt-BR.json index 21b875205..3c474fa01 100644 --- a/src/Filee.App/Assets/i18n/pt-BR.json +++ b/src/Filee.App/Assets/i18n/pt-BR.json @@ -66,6 +66,7 @@ "home.open_file": "Abrir arquivo", "home.open_with": "Abrir com", "home.clear_history": "Limpar", + "home.remove_from_history": "Remover do histórico", "home.files": "{0} arquivos", "home.failed_files": "{0} falharam", "home.undo": "Desfazer", diff --git a/src/Filee.App/Assets/i18n/pt-PT.json b/src/Filee.App/Assets/i18n/pt-PT.json index dd67b7f9e..e654bdc97 100644 --- a/src/Filee.App/Assets/i18n/pt-PT.json +++ b/src/Filee.App/Assets/i18n/pt-PT.json @@ -66,6 +66,7 @@ "home.open_file": "Abrir ficheiro", "home.open_with": "Abrir com", "home.clear_history": "Limpar", + "home.remove_from_history": "Remover do histórico", "home.files": "{0} ficheiros", "home.failed_files": "Falhas: {0}", "home.undo": "Anular", diff --git a/src/Filee.App/Assets/i18n/ru.json b/src/Filee.App/Assets/i18n/ru.json index 62df4192b..e5db0045e 100644 --- a/src/Filee.App/Assets/i18n/ru.json +++ b/src/Filee.App/Assets/i18n/ru.json @@ -66,6 +66,7 @@ "home.open_file": "Открыть файл", "home.open_with": "Открыть с помощью", "home.clear_history": "Очистить", + "home.remove_from_history": "Удалить из истории", "home.files": "Файлов: {0}", "home.failed_files": "Ошибок: {0}", "home.undo": "Отменить", diff --git a/src/Filee.App/Assets/i18n/th.json b/src/Filee.App/Assets/i18n/th.json index fc17c57d4..afc73ec60 100644 --- a/src/Filee.App/Assets/i18n/th.json +++ b/src/Filee.App/Assets/i18n/th.json @@ -63,6 +63,7 @@ "home.open_file": "เปิดไฟล์", "home.open_with": "เปิดด้วย", "home.clear_history": "ล้างประวัติ", + "home.remove_from_history": "ลบออกจากประวัติ", "home.files": "{0} ไฟล์", "home.failed_files": "ล้มเหลว {0} ไฟล์", "home.undo": "เลิกทำ", diff --git a/src/Filee.App/Assets/i18n/tr.json b/src/Filee.App/Assets/i18n/tr.json index 32bfaa63a..cb76eb558 100644 --- a/src/Filee.App/Assets/i18n/tr.json +++ b/src/Filee.App/Assets/i18n/tr.json @@ -63,6 +63,7 @@ "home.open_file": "Dosyayı aç", "home.open_with": "Birlikte aç", "home.clear_history": "Temizle", + "home.remove_from_history": "Geçmişten kaldır", "home.files": "{0} dosya", "home.failed_files": "{0} başarısız", "home.undo": "Geri al", diff --git a/src/Filee.App/Assets/i18n/vi.json b/src/Filee.App/Assets/i18n/vi.json index a69d4b970..665922471 100644 --- a/src/Filee.App/Assets/i18n/vi.json +++ b/src/Filee.App/Assets/i18n/vi.json @@ -66,6 +66,7 @@ "home.open_file": "Mở tệp", "home.open_with": "Mở bằng", "home.clear_history": "Xóa", + "home.remove_from_history": "Xóa khỏi lịch sử", "home.files": "{0} tệp", "home.failed_files": "{0} lỗi", "home.undo": "Hoàn tác", diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.json index 82e3e8470..92ff68ec7 100644 --- a/src/Filee.App/Assets/i18n/zh-CN.json +++ b/src/Filee.App/Assets/i18n/zh-CN.json @@ -66,6 +66,7 @@ "home.open_file": "打开文件", "home.open_with": "打开方式", "home.clear_history": "清除", + "home.remove_from_history": "从历史记录中移除", "home.files": "{0} 个文件", "home.failed_files": "{0} 个失败", "home.undo": "撤销", diff --git a/src/Filee.App/Assets/i18n/zh-TW.json b/src/Filee.App/Assets/i18n/zh-TW.json index aeda0c1c2..5a92e0061 100644 --- a/src/Filee.App/Assets/i18n/zh-TW.json +++ b/src/Filee.App/Assets/i18n/zh-TW.json @@ -66,6 +66,7 @@ "home.open_file": "開啟檔案", "home.open_with": "開啟方式", "home.clear_history": "清除", + "home.remove_from_history": "從歷史記錄中移除", "home.files": "{0} 個檔案", "home.failed_files": "{0} 個失敗", "home.undo": "復原", diff --git a/src/Filee.App/ViewModels/Pages/HomePageViewModel.cs b/src/Filee.App/ViewModels/Pages/HomePageViewModel.cs index 304e3b214..4352993d1 100644 --- a/src/Filee.App/ViewModels/Pages/HomePageViewModel.cs +++ b/src/Filee.App/ViewModels/Pages/HomePageViewModel.cs @@ -178,6 +178,13 @@ private void Refused(HistoryOutput output, TrashRefusal refusal) CanUndo = UndoLeft(); } + /// + /// The card's X: drops this conversion from the history. Its results and sources stay where they are; only the entry + /// is forgotten (Clear drops them all). The list is rebuilt from the store's change notification. + /// + [RelayCommand] + private void RemoveFromHistory() => _store?.RemoveHistory(_entry); + [RelayCommand] private void OpenFolder() { diff --git a/src/Filee.App/Views/Pages/HomePage.axaml b/src/Filee.App/Views/Pages/HomePage.axaml index 03a00875d..92d3d8a32 100644 --- a/src/Filee.App/Views/Pages/HomePage.axaml +++ b/src/Filee.App/Views/Pages/HomePage.axaml @@ -161,31 +161,38 @@ - - - - - - - + + + + + + + + diff --git a/src/Filee.Core/Settings/UserDataStore.cs b/src/Filee.Core/Settings/UserDataStore.cs index e963a79db..c5b2cba09 100644 --- a/src/Filee.Core/Settings/UserDataStore.cs +++ b/src/Filee.Core/Settings/UserDataStore.cs @@ -189,6 +189,23 @@ public void ClearHistory() HistoryChanged?.Invoke(this, EventArgs.Empty); } + /// + /// Drops one finished conversion from the history (the card's X in Recent conversions). The files it made stay where + /// they are: this only forgets the entry, unlike which forgets all of them. + /// + /// Whether the entry was in the history and has been removed. + public bool RemoveHistory(HistoryEntry entry) + { + bool removed; + lock (_saveLock) + removed = History.Remove(entry); + if (!removed) + return false; + Write(HistoryPath, History, FileeJsonContext.Default.ListHistoryEntry); + HistoryChanged?.Invoke(this, EventArgs.Empty); + return true; + } + /// Replaces presets and profiles with factory defaults. public void ResetLibrary() { diff --git a/tests/Filee.App.Tests/RecentConversionTests.cs b/tests/Filee.App.Tests/RecentConversionTests.cs index 1eb7e0162..e3effd160 100644 --- a/tests/Filee.App.Tests/RecentConversionTests.cs +++ b/tests/Filee.App.Tests/RecentConversionTests.cs @@ -333,6 +333,45 @@ public async Task Undo_moves_the_results_to_the_trash_while_they_are_as_the_job_ } } + [AvaloniaFact] + public void A_card_can_be_removed_from_the_history_leaving_its_files() + { + TestServices.EnsureInitialized("en"); + var loc = AppHost.Get(); + var store = AppHost.Get(); + var folder = Directory.CreateTempSubdirectory("filee-remove-").FullName; + store.ClearHistory(); + try + { + var keep = Path.Combine(folder, "keep.png"); + var gone = Path.Combine(folder, "gone.png"); + File.WriteAllBytes(keep, [1]); + File.WriteAllBytes(gone, [2]); + store.AddHistory(Entry([keep], "PNG", [Path.Combine(folder, "keep.heic")])); + store.AddHistory(Entry([gone], "PNG", [Path.Combine(folder, "gone.heic")])); + Assert.Equal(2, store.History.Count); + var goneEntry = store.History[0]; // the newest, listed first + + // The card's X forgets that entry only, and the file it made stays where it is. + var item = new HistoryItemViewModel(goneEntry, loc, new OpeningPlatform(false), store: store); + item.RemoveFromHistoryCommand.Execute(null); + Assert.DoesNotContain(goneEntry, store.History); + Assert.Single(store.History); + Assert.True(File.Exists(gone)); + + // It is saved: the next application loads it without that entry. + var reloaded = new UserDataStore(store.Directory); + reloaded.Load(); + Assert.Single(reloaded.History); + Assert.DoesNotContain(goneEntry, reloaded.History); + } + finally + { + store.ClearHistory(); + Directory.Delete(folder, true); + } + } + private static HistoryOutput Stamp(string path) { var info = new FileInfo(path); diff --git a/tests/Filee.Core.Tests/UserDataStoreTests.cs b/tests/Filee.Core.Tests/UserDataStoreTests.cs index 887570306..028c797ed 100644 --- a/tests/Filee.Core.Tests/UserDataStoreTests.cs +++ b/tests/Filee.Core.Tests/UserDataStoreTests.cs @@ -688,6 +688,33 @@ public void History_is_kept_until_turned_off_and_can_be_cleared() Assert.Empty(reloaded.History); } + [Fact] + public void One_history_entry_can_be_removed_and_the_rest_are_saved() + { + using var dir = new TempDir(); + var store = new UserDataStore(dir.Path); + store.Load(); + + var a = new Filee.Core.History.HistoryEntry { JobId = "a" }; + var b = new Filee.Core.History.HistoryEntry { JobId = "b" }; + var c = new Filee.Core.History.HistoryEntry { JobId = "c" }; + store.AddHistory(a); + store.AddHistory(b); + store.AddHistory(c); // newest first: c, b, a + Assert.Equal(["c", "b", "a"], store.History.Select(e => e.JobId)); + + // Removing the middle one leaves the others, and is written to disk. + Assert.True(store.RemoveHistory(b)); + Assert.Equal(["c", "a"], store.History.Select(e => e.JobId)); + var reloaded = new UserDataStore(dir.Path); + reloaded.Load(); + Assert.Equal(["c", "a"], reloaded.History.Select(e => e.JobId)); + + // Removing one that is no longer there changes nothing and says so. + Assert.False(store.RemoveHistory(b)); + Assert.Equal(2, store.History.Count); + } + [Fact] public void History_keeps_the_newest_entries_up_to_the_limit() {