change history to clean

This commit is contained in:
Julian Freeman
2026-04-17 13:44:41 -04:00
parent b9f24e07cf
commit 6d2b117200
11 changed files with 696 additions and 351 deletions

View File

@@ -16,13 +16,17 @@ const {
configsLoading,
createConfigForm,
createCustomBrowserConfig,
cleanupHistoryError,
cleanupHistoryForProfile,
cleanupHistoryResults,
cleanupHistorySelectedProfiles,
cleanupSelectedHistoryProfiles,
currentBrowser,
deleteCustomBrowserConfig,
domainFromUrl,
error,
extensionMonogram,
extensionSortKey,
historyDomainSortKey,
historyCleanupBusy,
isDeletingConfig,
isOpeningProfile,
loading,
@@ -39,13 +43,13 @@ const {
selectedBrowserId,
showBookmarkProfilesModal,
showExtensionProfilesModal,
showHistoryDomainProfilesModal,
showPasswordSiteProfilesModal,
sortedBookmarks,
sortedExtensions,
sortedHistoryDomains,
sortedPasswordSites,
sortedProfiles,
toggleAllHistoryProfiles,
toggleHistoryProfile,
closeAssociatedProfilesModal,
} = useBrowserManager();
</script>
@@ -109,29 +113,32 @@ const {
:extension-sort-key="extensionSortKey"
:bookmark-sort-key="bookmarkSortKey"
:password-site-sort-key="passwordSiteSortKey"
:history-domain-sort-key="historyDomainSortKey"
:sorted-profiles="sortedProfiles"
:sorted-extensions="sortedExtensions"
:sorted-bookmarks="sortedBookmarks"
:sorted-password-sites="sortedPasswordSites"
:sorted-history-domains="sortedHistoryDomains"
:history-selected-profile-ids="cleanupHistorySelectedProfiles"
:cleanup-history-busy="historyCleanupBusy"
:cleanup-history-error="cleanupHistoryError"
:cleanup-history-results="cleanupHistoryResults"
:open-profile-error="openProfileError"
:section-count="sectionCount"
:is-opening-profile="isOpeningProfile"
:extension-monogram="extensionMonogram"
:domain-from-url="domainFromUrl"
:associated-profiles-modal="associatedProfilesModal"
@update:active-section="activeSection = $event"
@update:profile-sort-key="profileSortKey = $event"
@update:extension-sort-key="extensionSortKey = $event"
@update:bookmark-sort-key="bookmarkSortKey = $event"
@update:password-site-sort-key="passwordSiteSortKey = $event"
@update:history-domain-sort-key="historyDomainSortKey = $event"
@open-profile="(browserId, profileId) => openBrowserProfile(browserId, profileId)"
@show-extension-profiles="showExtensionProfilesModal"
@show-bookmark-profiles="showBookmarkProfilesModal"
@show-password-site-profiles="showPasswordSiteProfilesModal"
@show-history-domain-profiles="showHistoryDomainProfilesModal"
@toggle-history-profile="toggleHistoryProfile"
@toggle-all-history-profiles="toggleAllHistoryProfiles"
@cleanup-selected-history="cleanupSelectedHistoryProfiles"
@cleanup-history-for-profile="cleanupHistoryForProfile"
@close-associated-profiles="closeAssociatedProfilesModal"
/>

View File

@@ -6,14 +6,14 @@ import type {
BookmarkSortKey,
BrowserView,
ExtensionSortKey,
HistoryDomainSortKey,
CleanupHistoryResult,
PasswordSiteSortKey,
ProfileSortKey,
} from "../../types/browser";
import AssociatedProfilesModal from "./AssociatedProfilesModal.vue";
import BookmarksList from "./BookmarksList.vue";
import ExtensionsList from "./ExtensionsList.vue";
import HistoryDomainsList from "./HistoryDomainsList.vue";
import HistoryCleanupList from "./HistoryCleanupList.vue";
import PasswordSitesList from "./PasswordSitesList.vue";
import ProfilesList from "./ProfilesList.vue";
@@ -24,17 +24,18 @@ defineProps<{
extensionSortKey: ExtensionSortKey;
bookmarkSortKey: BookmarkSortKey;
passwordSiteSortKey: PasswordSiteSortKey;
historyDomainSortKey: HistoryDomainSortKey;
sortedProfiles: BrowserView["profiles"];
sortedExtensions: BrowserView["extensions"];
sortedBookmarks: BrowserView["bookmarks"];
sortedPasswordSites: BrowserView["passwordSites"];
sortedHistoryDomains: BrowserView["historyDomains"];
historySelectedProfileIds: string[];
cleanupHistoryBusy: boolean;
cleanupHistoryError: string;
cleanupHistoryResults: CleanupHistoryResult[];
openProfileError: string;
sectionCount: (section: ActiveSection) => number;
isOpeningProfile: (browserId: string, profileId: string) => boolean;
extensionMonogram: (name: string) => string;
domainFromUrl: (url: string) => string;
associatedProfilesModal: {
title: string;
browserId: string;
@@ -49,12 +50,14 @@ const emit = defineEmits<{
"update:extensionSortKey": [value: ExtensionSortKey];
"update:bookmarkSortKey": [value: BookmarkSortKey];
"update:passwordSiteSortKey": [value: PasswordSiteSortKey];
"update:historyDomainSortKey": [value: HistoryDomainSortKey];
openProfile: [browserId: string, profileId: string];
showExtensionProfiles: [extensionId: string];
showBookmarkProfiles: [url: string];
showPasswordSiteProfiles: [url: string];
showHistoryDomainProfiles: [domain: string];
toggleHistoryProfile: [profileId: string];
toggleAllHistoryProfiles: [];
cleanupSelectedHistory: [];
cleanupHistoryForProfile: [profileId: string];
closeAssociatedProfiles: [];
}>();
</script>
@@ -146,12 +149,19 @@ const emit = defineEmits<{
@show-profiles="emit('showPasswordSiteProfiles', $event)"
/>
<HistoryDomainsList
<HistoryCleanupList
v-else
:history-domains="sortedHistoryDomains"
:sort-key="historyDomainSortKey"
@update:sort-key="emit('update:historyDomainSortKey', $event)"
@show-profiles="emit('showHistoryDomainProfiles', $event)"
:browser-id="currentBrowser.browserId"
:browser-family-id="currentBrowser.browserFamilyId"
:profiles="sortedProfiles"
:selected-profile-ids="historySelectedProfileIds"
:cleanup-busy="cleanupHistoryBusy"
:cleanup-error="cleanupHistoryError"
:cleanup-results="cleanupHistoryResults"
@toggle-profile="emit('toggleHistoryProfile', $event)"
@toggle-all-profiles="emit('toggleAllHistoryProfiles')"
@cleanup-selected="emit('cleanupSelectedHistory')"
@cleanup-profile="emit('cleanupHistoryForProfile', $event)"
/>
</div>

View File

@@ -0,0 +1,391 @@
<script setup lang="ts">
import { computed } from "vue";
import type {
CleanupHistoryResult,
CleanupFileStatus,
ProfileSummary,
} from "../../types/browser";
import { profileAvatarSrc } from "../../utils/icons";
const props = defineProps<{
browserId: string;
browserFamilyId: string | null;
profiles: ProfileSummary[];
selectedProfileIds: string[];
cleanupBusy: boolean;
cleanupError: string;
cleanupResults: CleanupHistoryResult[];
}>();
const emit = defineEmits<{
toggleProfile: [profileId: string];
toggleAllProfiles: [];
cleanupSelected: [];
cleanupProfile: [profileId: string];
}>();
const selectableProfiles = computed(() =>
props.profiles.filter((profile) =>
hasAnyHistoryFile([
profile.historyCleanup.history,
profile.historyCleanup.topSites,
profile.historyCleanup.visitedLinks,
]),
),
);
const allSelected = computed(
() =>
selectableProfiles.value.length > 0 &&
selectableProfiles.value.every((profile) =>
props.selectedProfileIds.includes(profile.id),
),
);
function statusLabel(status: CleanupFileStatus) {
return status === "found" ? "Found" : "Missing";
}
function statusClass(status: CleanupFileStatus) {
return status === "found" ? "found" : "missing";
}
function isSelected(profileId: string) {
return props.selectedProfileIds.includes(profileId);
}
function isSelectable(profile: ProfileSummary) {
return hasAnyHistoryFile([
profile.historyCleanup.history,
profile.historyCleanup.topSites,
profile.historyCleanup.visitedLinks,
]);
}
function hasAnyHistoryFile(statuses: CleanupFileStatus[]) {
return statuses.some((status) => status === "found");
}
</script>
<template>
<section class="table-section">
<div v-if="cleanupError" class="inline-error">
{{ cleanupError }}
</div>
<div v-if="cleanupResults.length" class="result-strip">
<article
v-for="result in cleanupResults"
:key="result.profileId"
class="result-chip"
:class="{ error: result.error }"
>
<strong>{{ result.profileId }}</strong>
<span v-if="result.error">{{ result.error }}</span>
<span v-else-if="result.deletedFiles.length">
Deleted {{ result.deletedFiles.join(", ") }}
</span>
<span v-else>
Nothing to delete
</span>
</article>
</div>
<div class="history-toolbar">
<label class="toolbar-checkbox" :class="{ disabled: !selectableProfiles.length }">
<input
type="checkbox"
:checked="allSelected"
:disabled="!selectableProfiles.length || cleanupBusy"
@change="emit('toggleAllProfiles')"
/>
<span>Select All</span>
</label>
<button
class="danger-button"
type="button"
:disabled="!selectedProfileIds.length || cleanupBusy"
@click="emit('cleanupSelected')"
>
{{ cleanupBusy ? "Cleaning..." : `Clean Selected (${selectedProfileIds.length})` }}
</button>
</div>
<div v-if="profiles.length" class="data-table">
<div class="data-table-header history-grid">
<div class="header-cell checkbox-cell">Pick</div>
<div class="header-cell icon-cell">Avatar</div>
<div class="header-cell">Profile</div>
<div class="header-cell">History</div>
<div class="header-cell">Top Sites</div>
<div class="header-cell">Visited Links</div>
<div class="header-cell actions-cell">Action</div>
</div>
<div class="data-table-body styled-scrollbar">
<article v-for="profile in profiles" :key="profile.id" class="data-table-row history-grid">
<div class="row-cell checkbox-cell">
<input
type="checkbox"
:checked="isSelected(profile.id)"
:disabled="!isSelectable(profile) || cleanupBusy"
@change="emit('toggleProfile', profile.id)"
/>
</div>
<div class="profile-avatar table-avatar">
<img
v-if="profileAvatarSrc(profile, browserFamilyId)"
:src="profileAvatarSrc(profile, browserFamilyId) ?? undefined"
:alt="`${profile.name} avatar`"
/>
<span v-else>{{ profile.avatarLabel }}</span>
</div>
<div class="row-cell primary-cell">
<strong>{{ profile.name }}</strong>
<span class="subtle-line">{{ profile.id }}</span>
</div>
<div class="row-cell">
<span class="status-pill" :class="statusClass(profile.historyCleanup.history)">
{{ statusLabel(profile.historyCleanup.history) }}
</span>
</div>
<div class="row-cell">
<span class="status-pill" :class="statusClass(profile.historyCleanup.topSites)">
{{ statusLabel(profile.historyCleanup.topSites) }}
</span>
</div>
<div class="row-cell">
<span class="status-pill" :class="statusClass(profile.historyCleanup.visitedLinks)">
{{ statusLabel(profile.historyCleanup.visitedLinks) }}
</span>
</div>
<div class="row-cell actions-cell">
<button
class="danger-button action-button"
type="button"
:disabled="!isSelectable(profile) || cleanupBusy"
@click="emit('cleanupProfile', profile.id)"
>
Clean
</button>
</div>
</article>
</div>
</div>
<div v-else class="empty-card">
<p>No profile directories were found for this browser.</p>
</div>
</section>
</template>
<style scoped>
.table-section {
display: flex;
flex-direction: column;
gap: 10px;
padding: 0;
height: 100%;
min-height: 0;
}
.history-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.toolbar-checkbox {
display: inline-flex;
align-items: center;
gap: 10px;
color: var(--text);
font-size: 0.88rem;
}
.toolbar-checkbox.disabled {
opacity: 0.55;
}
.result-strip {
display: flex;
gap: 8px;
overflow: auto;
padding-bottom: 2px;
}
.result-chip {
display: grid;
gap: 4px;
min-width: 220px;
padding: 10px 12px;
border: 1px solid rgba(16, 185, 129, 0.2);
border-radius: 14px;
background: rgba(236, 253, 245, 0.92);
color: #065f46;
font-size: 0.82rem;
}
.result-chip.error {
border-color: rgba(239, 68, 68, 0.18);
background: rgba(254, 242, 242, 0.96);
color: #b42318;
}
.data-table {
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
border: 1px solid rgba(148, 163, 184, 0.18);
border-radius: 22px;
background: var(--panel);
box-shadow: var(--shadow);
overflow: hidden;
}
.data-table-body {
min-height: 0;
overflow: auto;
scrollbar-gutter: stable;
}
.history-grid {
display: grid;
grid-template-columns: 52px 56px minmax(170px, 1fr) 118px 118px 128px 108px;
gap: 12px;
align-items: center;
}
.data-table-header {
position: sticky;
top: 0;
z-index: 2;
padding: 10px 24px 10px 14px;
border-bottom: 1px solid rgba(148, 163, 184, 0.14);
background: rgba(248, 250, 252, 0.94);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.data-table-row {
padding: 12px 14px;
border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}
.data-table-row:last-child {
border-bottom: 0;
}
.data-table-row:hover {
background: rgba(248, 250, 252, 0.65);
}
.header-cell {
color: var(--muted);
font-size: 0.81rem;
font-weight: 700;
letter-spacing: 0.02em;
}
.checkbox-cell {
display: flex;
justify-content: center;
}
.icon-cell {
padding-left: 4px;
}
.row-cell {
min-width: 0;
}
.profile-avatar {
display: grid;
place-items: center;
flex-shrink: 0;
background: linear-gradient(135deg, #dbeafe, #eff6ff);
color: #1d4ed8;
font-size: 0.96rem;
font-weight: 700;
overflow: hidden;
}
.table-avatar {
width: 36px;
height: 36px;
border-radius: 999px;
}
.profile-avatar img {
width: 100%;
height: 100%;
object-fit: cover;
}
.primary-cell strong {
display: block;
font-size: 0.93rem;
line-height: 1.3;
}
.subtle-line {
display: block;
margin-top: 3px;
color: var(--muted-soft);
font-size: 0.8rem;
}
.status-pill {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 78px;
padding: 6px 10px;
border-radius: 999px;
font-size: 0.79rem;
font-weight: 700;
}
.status-pill.found {
background: rgba(37, 99, 235, 0.12);
color: #1d4ed8;
}
.status-pill.missing {
background: rgba(226, 232, 240, 0.7);
color: var(--badge-text);
}
.actions-cell {
display: flex;
justify-content: flex-end;
}
.action-button {
padding-inline: 12px;
}
@media (max-width: 900px) {
.history-grid {
grid-template-columns: 52px 56px minmax(160px, 1fr) 110px 110px 118px 100px;
}
}
@media (max-width: 720px) {
.history-toolbar {
flex-direction: column;
align-items: stretch;
}
.history-grid {
grid-template-columns: 52px 56px minmax(0, 1fr) 108px;
}
.history-grid > :nth-child(5),
.history-grid > :nth-child(6),
.history-grid > :nth-child(7) {
display: none;
}
}
</style>

View File

@@ -1,165 +0,0 @@
<script setup lang="ts">
import type { HistoryDomainSortKey, HistoryDomainSummary } from "../../types/browser";
defineProps<{
historyDomains: HistoryDomainSummary[];
sortKey: HistoryDomainSortKey;
}>();
const emit = defineEmits<{
"update:sortKey": [value: HistoryDomainSortKey];
showProfiles: [domain: string];
}>();
</script>
<template>
<section class="table-section">
<div v-if="historyDomains.length" class="data-table">
<div class="data-table-header history-grid">
<button class="header-cell sortable" :class="{ active: sortKey === 'domain' }" type="button" @click="emit('update:sortKey', 'domain')">Domain</button>
<button class="header-cell sortable" :class="{ active: sortKey === 'visits' }" type="button" @click="emit('update:sortKey', 'visits')">Visits</button>
<div class="header-cell actions-cell">Profiles</div>
</div>
<div class="data-table-body styled-scrollbar">
<article
v-for="historyDomain in historyDomains"
:key="historyDomain.domain"
class="data-table-row history-grid"
>
<div class="row-cell primary-cell">
<strong>{{ historyDomain.domain }}</strong>
</div>
<div class="row-cell muted-cell">{{ historyDomain.visitCount.toLocaleString() }}</div>
<div class="row-cell actions-cell">
<button class="disclosure-button" type="button" @click="emit('showProfiles', historyDomain.domain)">
<span>View</span>
<span class="badge neutral">{{ historyDomain.profileIds.length }}</span>
</button>
</div>
</article>
</div>
</div>
<div v-else class="empty-card">
<p>No browsing history domains were discovered for this browser.</p>
</div>
</section>
</template>
<style scoped>
.table-section {
padding: 0;
height: 100%;
min-height: 0;
}
.data-table {
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
border: 1px solid rgba(148, 163, 184, 0.18);
border-radius: 22px;
background: var(--panel);
box-shadow: var(--shadow);
overflow: hidden;
}
.data-table-body {
min-height: 0;
overflow: auto;
scrollbar-gutter: stable;
}
.history-grid {
display: grid;
grid-template-columns: minmax(240px, 1.2fr) 140px 154px;
gap: 12px;
align-items: center;
}
.data-table-header {
position: sticky;
top: 0;
z-index: 2;
padding: 10px 24px 10px 14px;
border-bottom: 1px solid rgba(148, 163, 184, 0.14);
background: rgba(248, 250, 252, 0.94);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.header-cell {
color: var(--muted);
font-size: 0.81rem;
font-weight: 700;
letter-spacing: 0.02em;
}
.header-cell.sortable {
padding: 0;
text-align: left;
background: transparent;
cursor: pointer;
}
.header-cell.sortable.active {
color: var(--text);
}
.data-table-row {
padding: 12px 14px;
border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}
.data-table-row:last-child {
border-bottom: 0;
}
.data-table-row:hover {
background: rgba(248, 250, 252, 0.65);
}
.row-cell {
min-width: 0;
}
.primary-cell strong {
display: block;
font-size: 0.93rem;
line-height: 1.3;
}
.muted-cell {
color: var(--muted);
font-size: 0.87rem;
}
.disclosure-button {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
width: fit-content;
min-width: 120px;
padding: 7px 10px;
border-radius: 12px;
background: rgba(241, 245, 249, 0.9);
color: var(--badge-text);
cursor: pointer;
}
.actions-cell {
display: flex;
justify-content: flex-end;
}
@media (max-width: 720px) {
.history-grid {
grid-template-columns: minmax(0, 1fr) 120px;
}
.history-grid > :nth-child(2) {
display: none;
}
}
</style>

View File

@@ -2,13 +2,7 @@ import { computed, onMounted, ref, watch } from "vue";
import { invoke } from "@tauri-apps/api/core";
import { open } from "@tauri-apps/plugin-dialog";
import {
sortBookmarks,
sortExtensions,
sortHistoryDomains,
sortPasswordSites,
sortProfiles,
} from "../utils/sort";
import { sortBookmarks, sortExtensions, sortPasswordSites, sortProfiles } from "../utils/sort";
import type {
ActiveSection,
AppPage,
@@ -18,9 +12,10 @@ import type {
BrowserConfigEntry,
BrowserConfigListResponse,
BrowserView,
CleanupHistoryInput,
CleanupHistoryResponse,
CreateCustomBrowserConfigInput,
ExtensionSortKey,
HistoryDomainSortKey,
PasswordSiteSortKey,
ProfileSortKey,
ScanResponse,
@@ -56,7 +51,10 @@ export function useBrowserManager() {
const extensionSortKey = ref<ExtensionSortKey>("name");
const bookmarkSortKey = ref<BookmarkSortKey>("title");
const passwordSiteSortKey = ref<PasswordSiteSortKey>("domain");
const historyDomainSortKey = ref<HistoryDomainSortKey>("visits");
const cleanupHistorySelectedProfiles = ref<string[]>([]);
const historyCleanupBusy = ref(false);
const cleanupHistoryError = ref("");
const cleanupHistoryResults = ref<CleanupHistoryResponse["results"]>([]);
const browsers = computed(() => response.value.browsers);
const currentBrowser = computed<BrowserView | null>(
@@ -78,9 +76,6 @@ export function useBrowserManager() {
const sortedPasswordSites = computed(() =>
sortPasswordSites(currentBrowser.value?.passwordSites ?? [], passwordSiteSortKey.value),
);
const sortedHistoryDomains = computed(() =>
sortHistoryDomains(currentBrowser.value?.historyDomains ?? [], historyDomainSortKey.value),
);
watch(
browsers,
@@ -104,6 +99,9 @@ export function useBrowserManager() {
watch(selectedBrowserId, () => {
openProfileError.value = "";
associatedProfilesModal.value = null;
cleanupHistorySelectedProfiles.value = [];
cleanupHistoryResults.value = [];
cleanupHistoryError.value = "";
});
async function loadBrowserConfigs() {
@@ -284,21 +282,13 @@ export function useBrowserManager() {
return name.trim().slice(0, 1).toUpperCase() || "?";
}
function domainFromUrl(url: string) {
try {
return new URL(url).hostname;
} catch {
return url;
}
}
function sectionCount(section: ActiveSection) {
if (!currentBrowser.value) return 0;
if (section === "profiles") return currentBrowser.value.profiles.length;
if (section === "extensions") return currentBrowser.value.extensions.length;
if (section === "bookmarks") return currentBrowser.value.bookmarks.length;
if (section === "passwords") return currentBrowser.value.passwordSites.length;
return currentBrowser.value.historyDomains.length;
return currentBrowser.value.stats.historyCleanupProfileCount;
}
function showExtensionProfilesModal(extensionId: string) {
@@ -334,17 +324,78 @@ export function useBrowserManager() {
};
}
function showHistoryDomainProfilesModal(domain: string) {
const historyDomain = currentBrowser.value?.historyDomains.find(
(item) => item.domain === domain,
);
if (!historyDomain || !currentBrowser.value) return;
associatedProfilesModal.value = {
title: `${historyDomain.domain} Profiles`,
browserId: currentBrowser.value.browserId,
profiles: historyDomain.profiles,
isBookmark: false,
};
function toggleHistoryProfile(profileId: string) {
if (cleanupHistorySelectedProfiles.value.includes(profileId)) {
cleanupHistorySelectedProfiles.value = cleanupHistorySelectedProfiles.value.filter(
(selectedId) => selectedId !== profileId,
);
return;
}
cleanupHistorySelectedProfiles.value = [
...cleanupHistorySelectedProfiles.value,
profileId,
];
}
function toggleAllHistoryProfiles() {
const current = currentBrowser.value;
if (!current) return;
const selectableIds = current.profiles
.filter((profile) => {
const cleanup = profile.historyCleanup;
return (
cleanup.history === "found" ||
cleanup.topSites === "found" ||
cleanup.visitedLinks === "found"
);
})
.map((profile) => profile.id);
const allSelected =
selectableIds.length > 0 &&
selectableIds.every((profileId) =>
cleanupHistorySelectedProfiles.value.includes(profileId),
);
cleanupHistorySelectedProfiles.value = allSelected ? [] : selectableIds;
}
async function cleanupHistoryProfiles(profileIds: string[]) {
if (!currentBrowser.value || profileIds.length === 0) return;
historyCleanupBusy.value = true;
cleanupHistoryError.value = "";
cleanupHistoryResults.value = [];
try {
const input: CleanupHistoryInput = {
browserId: currentBrowser.value.browserId,
profileIds,
};
const result = await invoke<CleanupHistoryResponse>("cleanup_history_files", { input });
cleanupHistoryResults.value = result.results;
cleanupHistorySelectedProfiles.value = cleanupHistorySelectedProfiles.value.filter(
(profileId) => !profileIds.includes(profileId),
);
await scanBrowsers();
} catch (cleanupErrorValue) {
cleanupHistoryError.value =
cleanupErrorValue instanceof Error
? cleanupErrorValue.message
: "Failed to clean history files.";
} finally {
historyCleanupBusy.value = false;
}
}
async function cleanupSelectedHistoryProfiles() {
await cleanupHistoryProfiles(cleanupHistorySelectedProfiles.value);
}
async function cleanupHistoryForProfile(profileId: string) {
await cleanupHistoryProfiles([profileId]);
}
function closeAssociatedProfilesModal() {
@@ -369,11 +420,15 @@ export function useBrowserManager() {
createCustomBrowserConfig,
currentBrowser,
deleteCustomBrowserConfig,
domainFromUrl,
error,
extensionMonogram,
extensionSortKey,
historyDomainSortKey,
cleanupHistoryError,
cleanupHistoryForProfile,
cleanupHistoryResults,
cleanupHistorySelectedProfiles,
cleanupSelectedHistoryProfiles,
historyCleanupBusy,
isDeletingConfig,
isOpeningProfile,
loading,
@@ -390,13 +445,13 @@ export function useBrowserManager() {
selectedBrowserId,
showBookmarkProfilesModal,
showExtensionProfilesModal,
showHistoryDomainProfilesModal,
showPasswordSiteProfilesModal,
sortedBookmarks,
sortedExtensions,
sortedHistoryDomains,
sortedPasswordSites,
sortedProfiles,
toggleAllHistoryProfiles,
toggleHistoryProfile,
closeAssociatedProfilesModal,
};
}

View File

@@ -3,7 +3,7 @@ export type BrowserStats = {
extensionCount: number;
bookmarkCount: number;
passwordSiteCount: number;
historyDomainCount: number;
historyCleanupProfileCount: number;
};
export type ProfileSummary = {
@@ -16,6 +16,7 @@ export type ProfileSummary = {
defaultAvatarStrokeColor: number | null;
avatarLabel: string;
path: string;
historyCleanup: HistoryCleanupSummary;
};
export type ExtensionSummary = {
@@ -41,11 +42,28 @@ export type PasswordSiteSummary = {
profiles: AssociatedProfileSummary[];
};
export type HistoryDomainSummary = {
domain: string;
visitCount: number;
export type HistoryCleanupSummary = {
history: CleanupFileStatus;
topSites: CleanupFileStatus;
visitedLinks: CleanupFileStatus;
};
export type CleanupFileStatus = "found" | "missing";
export type CleanupHistoryInput = {
browserId: string;
profileIds: string[];
profiles: AssociatedProfileSummary[];
};
export type CleanupHistoryResult = {
profileId: string;
deletedFiles: string[];
skippedFiles: string[];
error: string | null;
};
export type CleanupHistoryResponse = {
results: CleanupHistoryResult[];
};
export type AssociatedProfileSummary = {
@@ -73,7 +91,6 @@ export type ProfileSortKey = "name" | "email" | "id";
export type ExtensionSortKey = "name" | "id";
export type BookmarkSortKey = "title" | "url";
export type PasswordSiteSortKey = "domain" | "url";
export type HistoryDomainSortKey = "visits" | "domain";
export type AssociatedProfileSortKey = "id" | "name";
export type ActiveSection = "profiles" | "extensions" | "bookmarks" | "passwords" | "history";
export type AppPage = "browserData" | "configuration";
@@ -111,7 +128,6 @@ export type BrowserView = {
extensions: ExtensionSummary[];
bookmarks: BookmarkSummary[];
passwordSites: PasswordSiteSummary[];
historyDomains: HistoryDomainSummary[];
stats: BrowserStats;
};

View File

@@ -3,8 +3,6 @@ import type {
BookmarkSummary,
ExtensionSortKey,
ExtensionSummary,
HistoryDomainSortKey,
HistoryDomainSummary,
PasswordSiteSortKey,
PasswordSiteSummary,
AssociatedProfileSortKey,
@@ -90,16 +88,6 @@ export function sortPasswordSites(items: PasswordSiteSummary[], sortKey: Passwor
});
}
export function sortHistoryDomains(items: HistoryDomainSummary[], sortKey: HistoryDomainSortKey) {
const historyDomains = [...items];
return historyDomains.sort((left, right) => {
if (sortKey === "domain") {
return compareOptionalText(left.domain, right.domain) || right.visitCount - left.visitCount;
}
return right.visitCount - left.visitCount || compareOptionalText(left.domain, right.domain);
});
}
export function sortAssociatedProfiles(
items: (AssociatedProfileSummary | BookmarkAssociatedProfileSummary)[],
sortKey: AssociatedProfileSortKey,