MCPcopy Create free account
hub / github.com/Authenticator-Extension/Authenticator / commitItems

Method commitItems

src/models/settings.ts:86–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

84 }
85
86 static async commitItems() {
87 const storageLocation =
88 UserSettings.items.storageLocation || StorageLocation.Local;
89
90 if (storageLocation === StorageLocation.Local) {
91 await chrome.storage[storageLocation].set({
92 // JSON.parse(JSON.stringify()) strips functions (e.g. getItem, setItem, ...) which may have been added to the object.
93 // Without this, a crash may occur as chrome.storage throws an error when trying to serialize a function.
94 UserSettings: JSON.parse(JSON.stringify(UserSettings.items)),
95 });
96 } else {
97 const { syncableSettings, localSettings } = UserSettings.splitSettings(
98 UserSettings.items
99 );
100
101 await Promise.all([
102 chrome.storage[StorageLocation.Local].set({
103 UserSettings: JSON.parse(JSON.stringify(localSettings)),
104 }),
105 chrome.storage[StorageLocation.Sync].set({
106 UserSettings: JSON.parse(JSON.stringify(syncableSettings)),
107 }),
108 ]);
109 }
110
111 await UserSettings.updateItems();
112 }
113
114 static async removeItem(key: keyof UserSettingsData) {
115 const localSettings = await UserSettings.getStorageData(

Callers 15

getBackupTokenFunction · 0.80
syncTimeWithGoogleFunction · 0.80
initFunction · 0.80
runScheduledBackupFunction · 0.80
getModuleMethod · 0.80
getModuleMethod · 0.80
getModuleMethod · 0.80
setAutofillMethod · 0.80
setSmartFilterMethod · 0.80
setEnableContextMenuMethod · 0.80
setThemeMethod · 0.80
setAutolockMethod · 0.80

Calls 3

splitSettingsMethod · 0.80
updateItemsMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected