Skip to content

Commit 134086d

Browse files
committed
fix settings loading causing freezing
1 parent 492bd0b commit 134086d

File tree

6 files changed

+30
-38
lines changed

6 files changed

+30
-38
lines changed

src/App.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@ export default {
204204
await this.$FeathersVuex.api.Setting.find({ query: { $limit: 9999999 } });
205205
const { Setting } = this.$FeathersVuex.api;
206206
const { data } = Setting.findInStore({ query: { key: 'editor' } });
207-
// eslint-disable-next-line no-console
208-
console.log(data[0]);
209207
this.$vuetify.theme.dark = /(dark)|(black)/.test(data[0]?.value?.theme ?? '');
210208
},
211209
};

src/components/files/editor.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ export default {
2121
const { Setting } = this.$FeathersVuex.api;
2222
const { data } = Setting.findInStore({ query: { key: 'editor' } });
2323
if (data[0]) return data[0].value;
24-
const settings = new Setting({ key: 'editor' });
25-
settings.save();
26-
return settings.value;
24+
return {};
2725
},
2826
currentFile() {
2927
const { File } = this.$FeathersVuex.api;

src/components/ide.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ export default {
3535
const { Setting } = this.$FeathersVuex.api;
3636
const { data } = Setting.findInStore({ query: { key: 'editor' } });
3737
if (data[0]) return data[0].value;
38-
const settings = new Setting({ key: 'editor' });
39-
settings.save();
40-
return settings.value;
38+
return {};
4139
},
4240
editorOptions() {
4341
return {

src/components/settings/compiler.vue

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</v-card-title>
66
<v-card-text>
77
<v-row>
8-
<v-col cols="12" sm="6" md="4" class="py-0">
8+
<v-col cols="12" sm="6" md="4" class="pt-0">
99
<v-checkbox
1010
:input-value="!!settings.value.verbose"
1111
label="Verbose Output"
@@ -14,15 +14,6 @@
1414
@change="$set(settings.value, 'verbose', $event)"
1515
/>
1616
</v-col>
17-
<v-col cols="12" sm="6" md="4" class="py-0">
18-
<v-checkbox
19-
:input-value="!!settings.value.preferLocal"
20-
label="Prefer Local Upload"
21-
hint="If possible, will use a locally ported upload protocol over using the remote server"
22-
persistent-hint
23-
@change="$set(settings.value, 'preferLocal', $event)"
24-
/>
25-
</v-col>
2617
</v-row>
2718
</v-card-text>
2819
</v-card>
@@ -31,30 +22,36 @@
3122
<script>
3223
3324
export default {
34-
computed: {
35-
settings() {
25+
data() {
26+
return {
27+
settings: { value: {} },
28+
};
29+
},
30+
methods: {
31+
loadSettings() {
3632
const { Setting } = this.$FeathersVuex.api;
3733
const { data } = Setting.findInStore({ query: { key: 'compiler' } });
38-
if (data[0]) return data[0];
34+
if (data[0]) {
35+
[this.settings] = data;
36+
return;
37+
}
3938
const settings = new Setting({ key: 'compiler' });
4039
settings.save();
41-
return settings;
40+
this.settings = settings;
4241
},
43-
},
44-
methods: {
4542
handleSave(to, from) {
4643
if (JSON.stringify(to) === JSON.stringify(from)) return false;
4744
this.settings.save();
4845
return true;
4946
},
5047
},
48+
mounted() {
49+
this.loadSettings();
50+
},
5151
watch: {
5252
'settings.value.verbose': {
5353
handler(to, from) { this.handleSave(to, from); },
5454
},
55-
'settings.value.preferLocal': {
56-
handler(to, from) { this.handleSave(to, from); },
57-
},
5855
},
5956
};
6057
</script>

src/components/settings/editor.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,30 @@ export default {
8787
{ text: 'High Contrast', value: 'hc-black' },
8888
],
8989
demoCode,
90+
settings: { value: {} },
9091
};
9192
},
92-
computed: {
93-
settings() {
93+
methods: {
94+
loadSettings() {
9495
const { Setting } = this.$FeathersVuex.api;
9596
const { data } = Setting.findInStore({ query: { key: 'editor' } });
96-
if (data[0]) return data[0];
97+
if (data[0]) {
98+
[this.settings] = data;
99+
return;
100+
}
97101
const settings = new Setting({ key: 'editor' });
98102
settings.save();
99-
return settings;
103+
this.settings = settings;
100104
},
101-
},
102-
methods: {
103105
handleSave(to, from) {
104106
if (JSON.stringify(to) === JSON.stringify(from)) return false;
105107
this.settings.save();
106108
return true;
107109
},
108110
},
111+
mounted() {
112+
this.loadSettings();
113+
},
109114
watch: {
110115
'settings.value.theme': {
111116
handler(to, from) {

src/plugins/compile-server.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ class CompileServer extends EventEmitter {
8686
}
8787

8888
async load() {
89-
// eslint-disable-next-line no-console
90-
console.log(this.isValid());
9189
if (!this.isValid()) return;
9290
// eslint-disable-next-line no-console
9391
console.log('loading start');
@@ -151,8 +149,6 @@ class CompileServer extends EventEmitter {
151149
}
152150

153151
async librariesSearch(search, limit = 10, skip = 0, sortBy = 'name', sortDesc = false) {
154-
// eslint-disable-next-line no-console
155-
console.log('lib-search');
156152
await this.initPromise;
157153
const e = encodeURIComponent;
158154
const query = `?search=${e(search ?? '')}&limit=${limit}&skip=${skip}&sortBy=${e(sortBy)}&sortDesc=${sortDesc}`;
@@ -259,7 +255,7 @@ class CompileServer extends EventEmitter {
259255
const hex = await this.compile(1, false);
260256
this.emit('console.progress', { percent: 0.5, message: 'Uploading code...' });
261257
// eslint-disable-next-line no-console
262-
console.log(this.Vue.$serial);
258+
// console.log(this.Vue.$serial);
263259
await this.Vue.$uploader.upload(hex, { ...flags });
264260
this.emit('console.progress', { percent: 1.0, message: 'Done!' });
265261
} catch (err) {

0 commit comments

Comments
 (0)