Le mirroring des dépôts vers Github est maintenant natif dans Gitlab (et donc Framagit). Merci de passer à la fonction native pour que nous puissions couper notre solution maison. Détails sur https://docs.gitlab.com/ee/workflow/repository_mirroring.html#pushing-to-a-remote-repository (pensez à supprimer le webhook de notre solution maison).

Commit 2ecb4cb0 by yPhil

Sync: New Object structure validation fn

parent 336a70ee
......@@ -37,13 +37,8 @@ PTL.menu = {
$('<div id="sideMenu">').appendTo($('body')).load('/static/templates/menu.html form#sideMenu', function() {
console.log('MENU OK');
var $menu = $(this),
$overlay = $('#overlay'),
$menuButton = $('#menuButton'),
$helpButton = $('#helpButton'),
$newSourceButton = $('#newSourceButton'),
$sourceCodeButton = $('button#sourceCode'),
$importButton = $("button#fileImport"),
$fileImportInput = $("input#fileImport"),
......
......@@ -29,7 +29,7 @@
PTL.sync = (function() {
var synchronized = false;
PTL.synchronized = false;
var syncDirectory = 'petrolette';
......@@ -39,7 +39,7 @@ PTL.sync = (function() {
return {
exports: {
read: function () {
return privateClient.getFile('petrolette.confz')
return privateClient.getFile('petrolette.conf')
.then(function (file) {
return file.data;
});
......@@ -64,17 +64,17 @@ PTL.sync = (function() {
// });
remoteStorage.on('connected', function() {
synchronized = true;
PTL.synchronized = true;
console.info('Pétrolette | ' + PTL.tr('Connected to remote storage'));
});
remoteStorage.on('not-connected', function() {
synchronized = true;
PTL.synchronized = false;
console.info('Pétrolette | ' + PTL.tr('NOT connected to remote storage'));
});
remoteStorage.on('disconnected', function() {
synchronized = false;
PTL.synchronized = false;
console.warn('Pétrolette | ' + PTL.tr('Disconnected from remote storage'));
});
......@@ -97,30 +97,21 @@ PTL.sync = (function() {
if (PTL.utilities.isValidSourcesFile(JSON.parse(data))) {
console.info('Pétrolette | ' + PTL.tr('Remote file validation OK'));
console.log('plop');
return PTL.tab.populate(JSON.parse(data));
} else {
console.warn('Pétrolette | ' + PTL.tr('Remote file validation NOT OK (error [%1]) now reading from browser cache', data));
if (PTL.utilities.isValidSourcesFile(JSON.parse(PTL.prefs.readConfig('tabs')))) {
PTL.tab.populate(JSON.parse(PTL.prefs.readConfig('tabs')));
} else {
localStorage.setItem("tabs", "");
}
PTL.tab.populate(JSON.parse(PTL.prefs.readConfig('tabs')));
}
})
.catch((err) => {
if (PTL.utilities.isValidSourcesFile(JSON.parse(PTL.prefs.readConfig('tabs')))) {
PTL.tab.populate(JSON.parse(PTL.prefs.readConfig('tabs')));
} else {
localStorage.setItem("tabs", "");
}
console.warn('Pétrolette | ' + PTL.tr('Remote file validation NOT OK (error [%1]) now reading from browser cache', err));
PTL.tab.populate(JSON.parse(PTL.prefs.readConfig('tabs')));
});
......
......@@ -3,27 +3,12 @@
PTL.utilities = {
isValidSourcesFile:function(sources) {
function checkElt(val) {
return val === 'news';
}
function has(object, key) {
return object ? hasOwnProperty.call(object, key) : false;
}
// console.log('sources', sources.find('name'));
console.log('feeds', sources.hasOwnProperty('name'));
console.log('sources: ', has(sources, 'feeds'));
var isValid = false;
// sources.find('name');
sources.forEach(function(element) {
if (element.feeds) isValid = true;
});
var isValid = false;
if (Object.prototype.toString.call(sources) === '[object Array]') {
isValid = sources.some(obj => Array.isArray(obj.feeds) && obj.feeds.some(feed => Object.prototype.hasOwnProperty.call(feed, 'url')));
} else {
isValid = false;
}
return isValid;
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment