Hansimov commited on
Commit
970785f
1 Parent(s): cb0dedb

:recycle: [Refactor] Separate datimer from chat_history_storage

Browse files
storages/chat_history_storage.js CHANGED
@@ -1,14 +1,15 @@
 
1
  class ChatStorageItem {
2
  constructor(chat_history_storage) {
3
  this.chat_history_storage = chat_history_storage;
4
  }
5
  create_index() {
6
- let datetime_string = moment().format("YYYY-MM-DD_HH-mm-ss_SSS");
7
  let chat_index = `chat_${datetime_string}`;
8
  return chat_index;
9
  }
10
  create_title() {
11
- let chat_title = moment().format("YYYY-MM-DD HH:mm:ss");
12
  return chat_title;
13
  }
14
  get_messagers_container_html() {
@@ -20,7 +21,7 @@ class ChatStorageItem {
20
  }
21
  }
22
  get_current_datetime_string() {
23
- return moment().format("YYYY-MM-DD HH:mm:ss.SSS");
24
  }
25
  construct() {
26
  this.html = this.get_messagers_container_html();
 
1
+ import { datetimer } from "./datetimer.js";
2
  class ChatStorageItem {
3
  constructor(chat_history_storage) {
4
  this.chat_history_storage = chat_history_storage;
5
  }
6
  create_index() {
7
+ let datetime_string = datetimer.now_with_ms_as_pathname();
8
  let chat_index = `chat_${datetime_string}`;
9
  return chat_index;
10
  }
11
  create_title() {
12
+ let chat_title = datetimer.now();
13
  return chat_title;
14
  }
15
  get_messagers_container_html() {
 
21
  }
22
  }
23
  get_current_datetime_string() {
24
+ return datetimer.now_with_ms();
25
  }
26
  construct() {
27
  this.html = this.get_messagers_container_html();
storages/datetimer.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class Datetimer {
2
+ constructor() {}
3
+ now() {
4
+ return moment().format("YYYY-MM-DD HH:mm:ss");
5
+ }
6
+ now_with_ms() {
7
+ return moment().format("YYYY-MM-DD HH:mm:ss.SSS");
8
+ }
9
+ now_as_pathname() {
10
+ return moment().format("YYYY-MM-DD_HH-mm-ss");
11
+ }
12
+ now_with_ms_as_pathname() {
13
+ return moment().format("YYYY-MM-DD_HH-mm-ss_SSS");
14
+ }
15
+ }
16
+
17
+ export let datetimer = new Datetimer();
storages/endpoint_storage.js CHANGED
@@ -41,7 +41,7 @@ class EndpointStorage {
41
  index: endpoint.endpoint,
42
  endpoint: endpoint.endpoint,
43
  api_key: endpoint.api_key,
44
- need_protect: endpoint.need_protect || true,
45
  });
46
  });
47
  });
 
41
  index: endpoint.endpoint,
42
  endpoint: endpoint.endpoint,
43
  api_key: endpoint.api_key,
44
+ need_protect: endpoint.need_protect || false,
45
  });
46
  });
47
  });