dataStore in local backup (#146)

* add preferFriends to showMeYourName

* add dataStores to local backup

* Add dataStores to export contains in settings
This commit is contained in:
mochie 2025-02-11 12:58:05 +01:00 committed by GitHub
parent 50166e4c31
commit 584cd3d2e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View file

@ -44,6 +44,7 @@ function BackupRestoreTab() {
<li>&mdash; Custom QuickCSS</li>
<li>&mdash; Theme Links</li>
<li>&mdash; Plugin Settings</li>
<li>&mdash; Plugin DataStores (e.g. Timezones or IRememberYou)</li>
</ul>
</Text>
<Flex>

View file

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { DataStore } from "@api/index";
import { showNotification } from "@api/Notifications";
import { PlainSettings, Settings } from "@api/Settings";
import { moment, Toasts } from "@webpack/common";
@ -34,18 +35,20 @@ export async function importSettings(data: string) {
throw new Error("Failed to parse JSON: " + String(err));
}
if ("settings" in parsed && "quickCss" in parsed) {
if ("settings" in parsed && "quickCss" in parsed && "dataStore" in parsed) {
Object.assign(PlainSettings, parsed.settings);
await VencordNative.settings.set(parsed.settings);
await VencordNative.quickCss.set(parsed.quickCss);
await DataStore.setMany(parsed.dataStore);
} else
throw new Error("Invalid Settings. Is this even a Equicord Settings file?");
throw new Error("Invalid Settings. Is this even an Equicord Settings file?");
}
export async function exportSettings({ minify }: { minify?: boolean; } = {}) {
const settings = VencordNative.settings.get();
const quickCss = await VencordNative.quickCss.get();
return JSON.stringify({ settings, quickCss }, null, minify ? undefined : 4);
const dataStore = await DataStore.entries();
return JSON.stringify({ settings, quickCss, dataStore }, null, minify ? undefined : 4);
}
export async function downloadSettingsBackup() {