mirror of
https://github.com/XFox111/TabsAsideExtension.git
synced 2026-04-22 07:58:01 +03:00
feat: Minor 3.1.0 (#150)
* Some features are now optional (#148) * fix(dev): yarn.lock tree fix * feat: bookmarks moved to optional permissions * fix: analytics not working in firefox * feat!: ability to turn off analytics (uses permissions on firefox) * feat: analytics tracker for bookmark export * feat: add privacy policy link in about section * docs: privacy policy update * feat: ability to chain multiple dialogs * fix(loc): analytics option translation * feat: settings review dialog * fix: background script fails to load because of frontend code * chore: use analytics permission as storage value * fix: inverted analytics value * feat!: option to disable thumbnail capture * fix(ci): sed typo * fix: minor fixes * fix(firefox): web-ext lint error fix * chore(ci): switch web-ext action * chore(lint): fix eslint warnings * chore(deps): monthly dependency bump (September 2025) (#149) * chore: 3.1.0 version bump * chore: minor cleanup * fix: allow analytics checkbox stays inactive after denying permission on firefox * fix(deps): yarn.lock rebuild * fix: type assertion for userId * fix: settings review dialog not showing if welcome dialog is not required * fix: analytics and thumbnail capture toggles react incorrectly if permission is denied
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
import { useDialog } from "@/contexts/DialogProvider";
|
||||
import { cloudDisabled, setCloudStorage } from "@/features/collectionStorage";
|
||||
import { clearGraphicsStorage, cloudDisabled, setCloudStorage, thumbnailCaptureEnabled } from "@/features/collectionStorage";
|
||||
import { useDangerStyles } from "@/hooks/useDangerStyles";
|
||||
import useStorageInfo from "@/hooks/useStorageInfo";
|
||||
import { Button, Field, MessageBar, MessageBarBody, MessageBarTitle, ProgressBar } from "@fluentui/react-components";
|
||||
import { Button, Field, InfoLabel, LabelProps, MessageBar, MessageBarBody, MessageBarTitle, ProgressBar, Switch } from "@fluentui/react-components";
|
||||
import { ArrowDownload20Regular, ArrowUpload20Regular } from "@fluentui/react-icons";
|
||||
import { useOptionsStyles } from "../hooks/useOptionsStyles";
|
||||
import exportData from "../utils/exportData";
|
||||
import importData from "../utils/importData";
|
||||
import { Unwatch } from "wxt/storage";
|
||||
|
||||
export default function StorageSection(): React.ReactElement
|
||||
{
|
||||
const { bytesInUse, storageQuota, usedStorageRatio } = useStorageInfo();
|
||||
const [importResult, setImportResult] = useState<boolean | null>(null);
|
||||
const [isCloudDisabled, setCloudDisabled] = useState<boolean>(null!);
|
||||
const [isThumbnailCaptureEnabled, setThumbnailCaptureEnabled] = useState<boolean | null>(null);
|
||||
|
||||
const dialog = useDialog();
|
||||
const cls = useOptionsStyles();
|
||||
@@ -20,10 +22,35 @@ export default function StorageSection(): React.ReactElement
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
thumbnailCaptureEnabled.getValue().then(setThumbnailCaptureEnabled);
|
||||
cloudDisabled.getValue().then(setCloudDisabled);
|
||||
return cloudDisabled.watch(setCloudDisabled);
|
||||
|
||||
const unwatchCloud: Unwatch = cloudDisabled.watch(setCloudDisabled);
|
||||
const unwatchThumbnails: Unwatch = thumbnailCaptureEnabled.watch(setThumbnailCaptureEnabled);
|
||||
|
||||
return () =>
|
||||
{
|
||||
unwatchCloud();
|
||||
unwatchThumbnails();
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleSetThumbnailCapture = (enabled: boolean): void =>
|
||||
{
|
||||
setThumbnailCaptureEnabled(null);
|
||||
thumbnailCaptureEnabled.setValue(enabled)
|
||||
.catch(() => setThumbnailCaptureEnabled(!enabled));
|
||||
};
|
||||
|
||||
const handleClearThumbnails = (): void =>
|
||||
dialog.pushPrompt({
|
||||
title: i18n.t("options_page.storage.clear_thumbnails.title"),
|
||||
content: i18n.t("options_page.storage.clear_thumbnails.prompt"),
|
||||
confirmText: i18n.t("common.actions.delete"),
|
||||
destructive: true,
|
||||
onConfirm: () => clearGraphicsStorage()
|
||||
});
|
||||
|
||||
const handleImport = (): void =>
|
||||
dialog.pushPrompt({
|
||||
title: i18n.t("options_page.storage.import_prompt.title"),
|
||||
@@ -51,6 +78,29 @@ export default function StorageSection(): React.ReactElement
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={ cls.group }>
|
||||
<Switch
|
||||
checked={ isThumbnailCaptureEnabled ?? true }
|
||||
disabled={ isThumbnailCaptureEnabled === null }
|
||||
onChange={ (_, e) => handleSetThumbnailCapture(e.checked as boolean) }
|
||||
label={ {
|
||||
children: (_: any, props: LabelProps) =>
|
||||
<InfoLabel
|
||||
{ ...props }
|
||||
label={ i18n.t("options_page.storage.thumbnail_capture") }
|
||||
info={
|
||||
<p>
|
||||
{ i18n.t("options_page.storage.thumbnail_capture_notice1") }<br /><br />
|
||||
{ i18n.t("options_page.storage.thumbnail_capture_notice2") }
|
||||
</p>
|
||||
} />
|
||||
} } />
|
||||
|
||||
<Button onClick={ handleClearThumbnails } className={ dangerCls.buttonSubtle } appearance="subtle">
|
||||
{ i18n.t("options_page.storage.clear_thumbnails.action") }
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{ isCloudDisabled === false &&
|
||||
<Field
|
||||
label={ i18n.t("options_page.storage.capacity.title") }
|
||||
|
||||
Reference in New Issue
Block a user