Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}).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');
}
});
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
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
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);
}
}
);
});
}
});
}
}
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();
});
});
}
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")
}
})
}
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()
});
}
});
}
}, 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
})
}
})
}
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()');
});
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
})
}
});
},