How to use the electron-json-storage.has function in electron-json-storage

To help you get started, we’ve selected a few electron-json-storage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mitchas / ffftp / app / controllers / base.js View on Github external
}).then((data) => {
      if (data.version !== $scope.appVersion.toString()) {
        $scope.showUpdate = true;
      }
    }, () => {
      console.log('Error getting update notification');
    });

    $scope.updateApp = () => {
      shell.openExternal('http://ffftp.site/download/' + $scope.appVersion);
    };

    // Load Favorites
    const storage = require('electron-json-storage');
    $scope.favorites = [];
    storage.has('favorites', (error, hasKey) => {
      if (error) throw error;

      if (hasKey) {
        storage.get('favorites', (error, data) => {
          if (error) throw error;

          $timeout(() => {
            $scope.favorites = data;
            console.log('FAVORITES');
            console.log(data);
          }, 0);
        });
      } else {
        console.log('No favs');
      }
    });
github gielcobben / caption / main.development.js View on Github external
Storage.get("moveApp", async (error, value) => {
          if (value) {
            try {
              const moved = await moveToApplications();
            } catch (error) {
              console.log(error);
            }
          } else {
            console.log("user choosed to not move the app!");
          }
        });
      }
    });

    // Set default property for nothing-found-window
    Storage.has("noting-found-window", (error, hasKey) => {
      if (error) throw error;
      if (!hasKey) {
        Storage.set("noting-found-window", true, error => {
          if (error) throw error;
          nothingFoundWindowValue = true;
        });
      }
    });
  }

  app.setAboutPanelOptions({
    applicationName: "Caption",
    applicationVersion: pkg.version,
    copyright: "Made with 💖 by Giel Cobben. \n www.gielcobben.com",
    credits: `With the invaluable help of: \n OpenSubtitles.org and Addic7ed.com`,
    version: pkg.version
github Aveek-Saha / MusicPlayer / main.js View on Github external
pathname: path.join(__dirname, 'app/index.html'),
      protocol: 'file:',
      slashes: true
    })
  )

  // fs.readFile('path.txt', 'utf-8', function (err, buf) {
  //   if (err) {
  //     return
  //   }
  //   var temp = [buf.toString()];
  //   scanDir(temp);

  // });

  storage.has('path', function (error, hasKey) {
    if (error) throw error
    if (hasKey) {
      storage.get('path', function (error, data) {
        if (error) throw error

        scanDir([data.path.toString()])
      })
    }
  })

  // Open the DevTools.
  // win.webContents.openDevTools()

  // Emitted when the window is closed.
  win.on('closed', () => {
    win = null
github pioneers / PieCentral / dawn / main.js View on Github external
click: function() {
          storage.has('runtimeAddress', (err, hasKey)=>{
            if(hasKey) {
              storage.get('runtimeAddress', (err, data)=>{
                let runtimeAddress = data.address;
                request.get(
                  `http://${runtimeAddress}:5000/restart`).end((err, res)=>{
                    if (err) {
                      console.log('Error on restart:', err);
                    }
                  }
                );
              });
            }
          });
        }
      }
github javikr / jukebox-spotify-electron / app / js / settingsController.js View on Github external
function loadPlaylists() {
        storage.has('spotify_token', function (error, hasKey) {
            if (error) throw error;
            if (hasKey == false) {
                ipcRenderer.send("request_oauth_token")
                return
            }
            storage.get('spotify_token', function (error, data) {
                if (error) throw error;

                spotifyApi.setAccessToken(data.access_token);
                console.log("update access token -> " + data.access_token)
                doLoadUserPlayLists();
            });
        });
    }
github javikr / jukebox-spotify-electron / app / js / mainController.js View on Github external
function checkAccessToken(completion) {
        storage.has('spotify_token', function (error, hasKey) {
            if (error) throw error;

            if (hasKey == true) {
                storage.get('spotify_token', function (error, data) {
                    if (error) throw error;
                    console.log("Saved token!");
                    spotifyApi.setAccessToken(data.access_token);
                    completion()
                });
            } else {
                ipcRenderer.send("request_oauth_token")
            }
        })
    }
github javikr / jukebox-spotify-electron / app / js / mainController.js View on Github external
function savePlayListInScope(completion) {
        storage.has('playlist', function (error, hasKey) {
            if (hasKey == true) {
                storage.get('playlist', function (error, playlistData) {
                    if (error) throw error;
                    $scope.playList = playlistData;
                    $scope.$apply();
                    completion()
                });
            }
        });
    }
github matthewgonzalez / fontplop / src / checkupdates.js View on Github external
}, response => {
    if (response === 0) {
      shell.openExternal(updateURL)
    } else if (response === 1) {
      storage.has('ignoreVersion', (error, hasKey) => {
        if (error) throw error
        if (hasKey) storage.remove('ignoreVersion', (error) => {
          if (error) throw error
        })
      })
    } else if (response === 2) {
      storage.set('ignoreVersion', update.tag_name, (error) => {
        if (error) throw error
      })
    }
  })
}
github willyb321 / media_mate / app / main / index.js View on Github external
function onBoard() {
	let actuallyFirstRun;
	try {
		actuallyFirstRun = firstRun({
			name: pkg.name
		});
	} catch (err) {
		Raven.captureException(err);
	}
	if (actuallyFirstRun) {
		storage.has('path', (err, hasKey) => {
			if (err) {
				Raven.captureException(err);
			} else if (!hasKey) {
				storage.set('path', {
					path: path.join(require('os').homedir(), 'media_matedl')
				}, err => {
					if (err) {
						log.info('MAIN: Error in onBoard (storage.set)');
						Raven.captureException(err);
					}
				});
			}
		});
		mainWindow.webContents.once('dom-ready', () => {
			mainWindow.webContents.executeJavaScript('firstrun()');
		});
github RALMAZ / Record-Player / src / renderer / App.vue View on Github external
created() {
      storage.has('setVolume', (error, hasKey) => {
        if (hasKey) storage.get('setVolume', (e, data) => this.setVolume(data))
      })

      storage.has('setFavorite', (error, hasKey) => {
        if (hasKey) {
          storage.get('setFavorite', (e, data) => this.setFavorite(data))
        } else {
          this.source = Stations.sort((a, b) => {
            if (a.name.charAt(0) > b.name.charAt(0)) return 1
            if (a.name.charAt(0) < b.name.charAt(0)) return -1
            return 0
          })
        }
      });
    },