mirror of
https://github.com/Equicord/Equicord.git
synced 2025-02-24 00:59:09 -05:00
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:
parent
50166e4c31
commit
584cd3d2e6
2 changed files with 7 additions and 3 deletions
|
@ -44,6 +44,7 @@ function BackupRestoreTab() {
|
||||||
<li>— Custom QuickCSS</li>
|
<li>— Custom QuickCSS</li>
|
||||||
<li>— Theme Links</li>
|
<li>— Theme Links</li>
|
||||||
<li>— Plugin Settings</li>
|
<li>— Plugin Settings</li>
|
||||||
|
<li>— Plugin DataStores (e.g. Timezones or IRememberYou)</li>
|
||||||
</ul>
|
</ul>
|
||||||
</Text>
|
</Text>
|
||||||
<Flex>
|
<Flex>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { DataStore } from "@api/index";
|
||||||
import { showNotification } from "@api/Notifications";
|
import { showNotification } from "@api/Notifications";
|
||||||
import { PlainSettings, Settings } from "@api/Settings";
|
import { PlainSettings, Settings } from "@api/Settings";
|
||||||
import { moment, Toasts } from "@webpack/common";
|
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));
|
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);
|
Object.assign(PlainSettings, parsed.settings);
|
||||||
await VencordNative.settings.set(parsed.settings);
|
await VencordNative.settings.set(parsed.settings);
|
||||||
await VencordNative.quickCss.set(parsed.quickCss);
|
await VencordNative.quickCss.set(parsed.quickCss);
|
||||||
|
await DataStore.setMany(parsed.dataStore);
|
||||||
} else
|
} 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; } = {}) {
|
export async function exportSettings({ minify }: { minify?: boolean; } = {}) {
|
||||||
const settings = VencordNative.settings.get();
|
const settings = VencordNative.settings.get();
|
||||||
const quickCss = await VencordNative.quickCss.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() {
|
export async function downloadSettingsBackup() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue