Hansimov commited on
Commit
da5489b
·
1 Parent(s): 11e9138

:boom: [Fix] Revert default_model set from Dexie back to localStorage

Browse files
components/buttons_binder.js CHANGED
@@ -246,8 +246,8 @@ class AvailableModelsSelectBinder {
246
  bind() {
247
  const select = $("#available-models-select");
248
  select.change(() => {
249
- console.log(select.val());
250
- endpoint_storage.db.default_model = select.val();
251
  });
252
  }
253
  }
 
246
  bind() {
247
  const select = $("#available-models-select");
248
  select.change(() => {
249
+ localStorage.setItem("default_model", select.val());
250
+ console.log("set default_model:", select.val());
251
  });
252
  }
253
  }
networks/endpoint_storage.js CHANGED
@@ -15,7 +15,6 @@ class EndpointStorage {
15
  this.db = new Dexie("endpoints");
16
  this.db.version(1).stores({
17
  endpoints: "index, endpoint, api_key",
18
- data: "",
19
  });
20
  this.db.endpoints.count((count) => {
21
  console.log(`${count} endpoints loaded.`);
@@ -127,30 +126,24 @@ class EndpointStorage {
127
 
128
  // set default model
129
  let default_model = "";
130
- let db_default_model = "";
131
- this.db.data.get("default_model").then((value) => {
132
- db_default_model = value;
133
- console.log("db_default_model:", db_default_model);
134
- if (
135
- db_default_model &&
136
- available_models.includes(db_default_model)
137
- ) {
138
- default_model = db_default_model;
139
- } else if (available_models) {
140
- default_model = available_models[0];
141
- this.db.data.put({
142
- key: "default_model",
143
- value: default_model,
144
- });
145
- } else {
146
- default_model = "";
147
- }
148
-
149
- select.val(default_model);
150
- console.log(`default_model: ${select.val()}`);
151
- });
152
  });
153
  }
 
154
  render_endpoint_and_api_key_items() {
155
  this.create_endpoint_and_api_key_items();
156
  this.bind_endpoint_and_api_key_buttons();
 
15
  this.db = new Dexie("endpoints");
16
  this.db.version(1).stores({
17
  endpoints: "index, endpoint, api_key",
 
18
  });
19
  this.db.endpoints.count((count) => {
20
  console.log(`${count} endpoints loaded.`);
 
126
 
127
  // set default model
128
  let default_model = "";
129
+ let storage_default_model = localStorage.getItem("default_model");
130
+ console.log("storage_default_model:", storage_default_model);
131
+ if (
132
+ storage_default_model &&
133
+ available_models.includes(storage_default_model)
134
+ ) {
135
+ default_model = storage_default_model;
136
+ } else if (available_models) {
137
+ default_model = available_models[0];
138
+ localStorage.setItem("default_model", default_model);
139
+ } else {
140
+ default_model = "";
141
+ }
142
+ select.val(default_model);
143
+ console.log(`default_model: ${select.val()}`);
 
 
 
 
 
 
 
144
  });
145
  }
146
+
147
  render_endpoint_and_api_key_items() {
148
  this.create_endpoint_and_api_key_items();
149
  this.bind_endpoint_and_api_key_buttons();