Merge pull request #77 from redsquirrel/encapsulate-cache-file-prefix

Encapsulating 'Cache File Prefix'
pull/1/head
chriseth 9 years ago committed by GitHub
commit 7a9b16956c
  1. 4
      src/app/editor.js
  2. 2
      src/app/storage-handler.js
  3. 6
      src/app/utils.js

@ -6,7 +6,7 @@ var ace = require('brace');
require('../mode-solidity.js');
function Editor (loadingFromGist) {
var SOL_CACHE_UNTITLED = utils.getCacheFilePrefix() + 'Untitled';
var SOL_CACHE_UNTITLED = utils.fileKey('Untitled');
var SOL_CACHE_FILE = null;
var editor = ace.edit('input');
@ -70,7 +70,7 @@ function Editor (loadingFromGist) {
function getFiles () {
var files = [];
for (var f in window.localStorage) {
if (f.indexOf(utils.getCacheFilePrefix(), 0) === 0) {
if (utils.isCachedFile(f)) {
files.push(f);
if (!sessions[f]) sessions[f] = newEditorSession(f);
}

@ -35,7 +35,7 @@ function StorageHandler (updateFiles) {
for (var y in window.localStorage) {
console.log('checking', y);
obj[y] = window.localStorage.getItem(y);
if (y.indexOf(utils.getCacheFilePrefix()) !== 0) {
if (!utils.isCachedFile(y)) {
continue;
}
count++;

@ -4,6 +4,10 @@ function getCacheFilePrefix () {
return SOL_CACHE_FILE_PREFIX;
}
function isCachedFile (name) {
return name.indexOf(getCacheFilePrefix(), 0) === 0;
}
function fileKey (name) {
return getCacheFilePrefix() + name;
}
@ -17,7 +21,7 @@ function errortype (message) {
}
module.exports = {
getCacheFilePrefix: getCacheFilePrefix,
isCachedFile: isCachedFile,
fileKey: fileKey,
fileNameFromKey: fileNameFromKey,
errortype: errortype

Loading…
Cancel
Save