mirror of
https://github.com/XFox111/TabsAsideExtension.git
synced 2026-04-22 07:58:01 +03:00
e21022d985
* 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
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
import { analyticsPermission } from "@/features/analytics";
|
|
import { Runtime } from "wxt/browser";
|
|
import { settingsForReview } from "./showSettingsReviewDialog";
|
|
|
|
export default async function setSettingsReviewNeeded(installReason: Runtime.OnInstalledReason, previousVersion?: string): Promise<void>
|
|
{
|
|
const needsReview: string[] = await settingsForReview.getValue();
|
|
|
|
if (!needsReview.includes(reviewSettings.ANALYTICS) && await checkAnalyticsReviewNeeded(installReason, previousVersion))
|
|
needsReview.push(reviewSettings.ANALYTICS);
|
|
|
|
if (!needsReview.includes(reviewSettings.THUMBNAILS) && await checkThumbnailsReviewNeeded(installReason, previousVersion))
|
|
needsReview.push(reviewSettings.THUMBNAILS);
|
|
|
|
console.log("Settings needing review:", needsReview);
|
|
// Add more settings here as needed
|
|
|
|
if (needsReview.length > 0)
|
|
await settingsForReview.setValue(needsReview);
|
|
}
|
|
|
|
export const reviewSettings =
|
|
{
|
|
ANALYTICS: "analytics",
|
|
THUMBNAILS: "thumbnails"
|
|
};
|
|
|
|
async function checkAnalyticsReviewNeeded(installReason: Runtime.OnInstalledReason, previousVersion?: string): Promise<boolean>
|
|
{
|
|
if (installReason === "install")
|
|
return !await analyticsPermission.getValue();
|
|
|
|
if (installReason === "update")
|
|
{
|
|
const [major, minor, patch] = (previousVersion ?? "0.0.0").split(".").map(parseInt);
|
|
const cumulative: number = major * 10000 + minor * 100 + patch;
|
|
|
|
if (cumulative < 30100) // < 3.1.0
|
|
return true;
|
|
}
|
|
|
|
if (import.meta.env.DEV)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
async function checkThumbnailsReviewNeeded(installReason: Runtime.OnInstalledReason, previousVersion?: string): Promise<boolean>
|
|
{
|
|
if (installReason === "install")
|
|
return true;
|
|
|
|
if (installReason === "update")
|
|
{
|
|
const [major, minor, patch] = (previousVersion ?? "0.0.0").split(".").map(parseInt);
|
|
const cumulative: number = major * 10000 + minor * 100 + patch;
|
|
|
|
if (cumulative < 30100) // < 3.1.0
|
|
return true;
|
|
}
|
|
|
|
if (import.meta.env.DEV)
|
|
return true;
|
|
|
|
return false;
|
|
}
|