![]()
+import type { CleanupHistoryResult, ProfileSummary } from "../../types/browser";
+
+defineProps<{
+ mode: "confirm" | "result";
+ title: string;
+ profiles: ProfileSummary[];
+ results: CleanupHistoryResult[];
+ busy?: boolean;
+ generalError?: string;
+}>();
+
+const emit = defineEmits<{
+ close: [];
+ confirm: [];
+}>();
+
+
+
+
+
+
+
+
+
+ The selected profiles will have History, Top Sites, and
+ Visited Links removed.
+
+
+
+
+
+
+
+
+
+
+
+ {{ generalError }}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/composables/useBrowserManager.ts b/src/composables/useBrowserManager.ts
index 279ced8..67960df 100644
--- a/src/composables/useBrowserManager.ts
+++ b/src/composables/useBrowserManager.ts
@@ -55,6 +55,8 @@ export function useBrowserManager() {
const historyCleanupBusy = ref(false);
const cleanupHistoryError = ref("");
const cleanupHistoryResults = ref
([]);
+ const historyCleanupConfirmProfileIds = ref([]);
+ const historyCleanupResultOpen = ref(false);
const browsers = computed(() => response.value.browsers);
const currentBrowser = computed(
@@ -102,6 +104,8 @@ export function useBrowserManager() {
cleanupHistorySelectedProfiles.value = [];
cleanupHistoryResults.value = [];
cleanupHistoryError.value = "";
+ historyCleanupConfirmProfileIds.value = [];
+ historyCleanupResultOpen.value = false;
});
async function loadBrowserConfigs() {
@@ -362,42 +366,112 @@ export function useBrowserManager() {
cleanupHistorySelectedProfiles.value = allSelected ? [] : selectableIds;
}
- async function cleanupHistoryProfiles(profileIds: string[]) {
+ function cleanupProfileIdsWithHistory(browser: BrowserView) {
+ return browser.profiles
+ .filter((profile) => {
+ const cleanup = profile.historyCleanup;
+ return (
+ cleanup.history === "found" ||
+ cleanup.topSites === "found" ||
+ cleanup.visitedLinks === "found"
+ );
+ })
+ .map((profile) => profile.id);
+ }
+
+ function historyCleanupConfirmProfiles() {
+ const browser = currentBrowser.value;
+ if (!browser) return [];
+ return browser.profiles.filter((profile) =>
+ historyCleanupConfirmProfileIds.value.includes(profile.id),
+ );
+ }
+
+ function cleanupSelectedHistoryProfiles() {
+ if (!cleanupHistorySelectedProfiles.value.length) return;
+ historyCleanupConfirmProfileIds.value = [...cleanupHistorySelectedProfiles.value];
+ }
+
+ function cleanupHistoryForProfile(profileId: string) {
+ historyCleanupConfirmProfileIds.value = [profileId];
+ }
+
+ function closeHistoryCleanupConfirm() {
+ if (historyCleanupBusy.value) return;
+ historyCleanupConfirmProfileIds.value = [];
+ }
+
+ function closeHistoryCleanupResult() {
+ historyCleanupResultOpen.value = false;
+ cleanupHistoryResults.value = [];
+ cleanupHistoryError.value = "";
+ }
+
+ function applyCleanupHistoryResults(results: CleanupHistoryResponse["results"]) {
+ const browser = currentBrowser.value;
+ if (!browser) return;
+
+ const succeededProfileIds = results
+ .filter((result) => !result.error)
+ .map((result) => result.profileId);
+
+ if (!succeededProfileIds.length) return;
+
+ for (const profile of browser.profiles) {
+ if (!succeededProfileIds.includes(profile.id)) continue;
+
+ const deletedFiles = results.find((result) => result.profileId === profile.id)?.deletedFiles ?? [];
+ if (deletedFiles.includes("History")) {
+ profile.historyCleanup.history = "missing";
+ }
+ if (deletedFiles.includes("Top Sites")) {
+ profile.historyCleanup.topSites = "missing";
+ }
+ if (deletedFiles.includes("Visited Links")) {
+ profile.historyCleanup.visitedLinks = "missing";
+ }
+ }
+
+ browser.stats.historyCleanupProfileCount = cleanupProfileIdsWithHistory(browser).length;
+ }
+
+ async function confirmHistoryCleanup() {
+ const browser = currentBrowser.value;
+ const profileIds = [...historyCleanupConfirmProfileIds.value];
+ if (!browser || profileIds.length === 0) return;
+
if (!currentBrowser.value || profileIds.length === 0) return;
historyCleanupBusy.value = true;
cleanupHistoryError.value = "";
cleanupHistoryResults.value = [];
+ historyCleanupResultOpen.value = false;
try {
const input: CleanupHistoryInput = {
- browserId: currentBrowser.value.browserId,
+ browserId: browser.browserId,
profileIds,
};
const result = await invoke("cleanup_history_files", { input });
+ applyCleanupHistoryResults(result.results);
cleanupHistoryResults.value = result.results;
cleanupHistorySelectedProfiles.value = cleanupHistorySelectedProfiles.value.filter(
(profileId) => !profileIds.includes(profileId),
);
- await scanBrowsers();
+ historyCleanupConfirmProfileIds.value = [];
+ historyCleanupResultOpen.value = true;
} catch (cleanupErrorValue) {
+ historyCleanupConfirmProfileIds.value = [];
cleanupHistoryError.value =
cleanupErrorValue instanceof Error
? cleanupErrorValue.message
: "Failed to clean history files.";
+ historyCleanupResultOpen.value = true;
} finally {
historyCleanupBusy.value = false;
}
}
- async function cleanupSelectedHistoryProfiles() {
- await cleanupHistoryProfiles(cleanupHistorySelectedProfiles.value);
- }
-
- async function cleanupHistoryForProfile(profileId: string) {
- await cleanupHistoryProfiles([profileId]);
- }
-
function closeAssociatedProfilesModal() {
associatedProfilesModal.value = null;
}
@@ -424,11 +498,15 @@ export function useBrowserManager() {
extensionMonogram,
extensionSortKey,
cleanupHistoryError,
- cleanupHistoryForProfile,
cleanupHistoryResults,
cleanupHistorySelectedProfiles,
cleanupSelectedHistoryProfiles,
+ closeHistoryCleanupConfirm,
+ closeHistoryCleanupResult,
+ confirmHistoryCleanup,
historyCleanupBusy,
+ historyCleanupConfirmProfiles: computed(historyCleanupConfirmProfiles),
+ historyCleanupResultOpen,
isDeletingConfig,
isOpeningProfile,
loading,
@@ -450,6 +528,7 @@ export function useBrowserManager() {
sortedExtensions,
sortedPasswordSites,
sortedProfiles,
+ cleanupHistoryForProfile,
toggleAllHistoryProfiles,
toggleHistoryProfile,
closeAssociatedProfilesModal,