Skip to content

Commit 0989cbb

Browse files
SYM01dependabot[bot]transifex-integration[bot]
authored
v1.2.1: fix import bugs (#36)
* fix an import issue (#33) (#35) --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com>
1 parent 572f0bf commit 0989cbb

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/components/PreferencePage.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import { Host } from "@/adapters";
33
import { config2json, json2config } from "@/services/config/schema";
4-
import { listProfiles, saveProfile } from "@/services/profile";
4+
import { listProfiles, saveManyProfiles } from "@/services/profile";
55
import { useFileDialog } from "@vueuse/core";
66
import { Notification } from "@arco-design/web-vue";
77
import {
@@ -23,7 +23,7 @@ onChange(async (file) => {
2323
}
2424
2525
const profiles = json2config(await file[0].text());
26-
profiles.forEach(saveProfile);
26+
await saveManyProfiles(profiles);
2727
Notification.success({
2828
content: Host.getMessage(
2929
"preferences_feedback_n_profiles_being_imported",

src/services/profile.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,26 @@ async function overwriteProfiles(profiles: ProfilesStorage) {
108108
onProfileUpdateListeners.map((cb) => cb(profiles));
109109
}
110110

111+
/**
112+
* Save a single profile to the storage.
113+
* Please be noticed that this is not promise-safe. If you want to save multiple profiles, use `saveManyProfiles` instead.
114+
*
115+
* @param profile
116+
*/
111117
export async function saveProfile(profile: ProxyProfile) {
112118
const data = await listProfiles();
113119
data[profile.profileID] = profile;
114120
await overwriteProfiles(data);
115121
}
116122

123+
export async function saveManyProfiles(profiles: ProxyProfile[]) {
124+
let data = await listProfiles();
125+
profiles.forEach((p) => {
126+
data[p.profileID] = p;
127+
});
128+
await overwriteProfiles(data);
129+
}
130+
117131
export async function getProfile(
118132
profileID: string,
119133
userProfileOnly?: boolean

0 commit comments

Comments
 (0)