P01yH3dr0n commited on
Commit
cbbb6e2
1 Parent(s): 1f361d6

cache chants

Browse files
Files changed (1) hide show
  1. tagcomplete/javascript/_utils.js +6 -2
tagcomplete/javascript/_utils.js CHANGED
@@ -39,7 +39,11 @@ function parseCSV(str) {
39
  // Load file
40
  async function readFile(filePath, json = false) {
41
  if (filePath in localStorage)
42
- return localStorage.getItem(filePath);
 
 
 
 
43
  while (true) {
44
  try {
45
  var response = await fetch(`file=${filePath}`);
@@ -56,7 +60,7 @@ async function readFile(filePath, json = false) {
56
 
57
  if (json) {
58
  let content = await response.json();
59
- localStorage.setItem(filePath, content);
60
  return content;
61
  }
62
  else {
 
39
  // Load file
40
  async function readFile(filePath, json = false) {
41
  if (filePath in localStorage)
42
+ if (json) {
43
+ return JSON.parse(localStorage.getItem(filePath));
44
+ } else {
45
+ return localStorage.getItem(filePath);
46
+ }
47
  while (true) {
48
  try {
49
  var response = await fetch(`file=${filePath}`);
 
60
 
61
  if (json) {
62
  let content = await response.json();
63
+ localStorage.setItem(filePath, JSON.stringify(content));
64
  return content;
65
  }
66
  else {