Fix clearAllData() not working properly (#708)

This commit is contained in:
redphx 2025-06-21 16:00:46 +07:00
parent 4da2cfaf49
commit 67fdf5ea12
4 changed files with 7 additions and 6 deletions

View File

@ -2760,7 +2760,7 @@ function parseDetailsPath(path) {
return { titleSlug, productId };
}
function clearAllData() {
for (let i = 0;i < localStorage.length; i++) {
for (let i = localStorage.length - 1;i >= 0; i--) {
let key = localStorage.key(i);
if (!key) continue;
if (key.startsWith("BetterXcloud") || key.startsWith("better_xcloud")) localStorage.removeItem(key);
@ -7387,7 +7387,7 @@ class SettingsDialog extends NavigationDialog {
($parent) => {
$parent.appendChild(createButton({
label: t("clear-data"),
style: 8 | 128 | 64,
style: 4 | 16 | 128 | 64,
onClick: (e) => {
if (confirm(t("clear-data-confirm"))) clearAllData();
}

File diff suppressed because one or more lines are too long

View File

@ -373,7 +373,7 @@ export class SettingsDialog extends NavigationDialog {
$parent => {
$parent.appendChild(createButton({
label: t('clear-data'),
style: ButtonStyle.GHOST | ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE,
style: ButtonStyle.DANGER | ButtonStyle.FROSTED | ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE,
onClick: e => {
if (confirm(t('clear-data-confirm'))) {
clearAllData();

View File

@ -136,7 +136,8 @@ export function parseDetailsPath(path: string) {
export function clearAllData() {
// Delete localStorage items
for (let i = 0; i < localStorage.length; i++) {
for (let i = localStorage.length - 1; i >= 0; i--) {
const key = localStorage.key(i);
if (!key) {
continue;