|
|
@ -685,10 +685,11 @@ define([
|
|
|
|
Store.setPadTitle = function (data, cb) {
|
|
|
|
Store.setPadTitle = function (data, cb) {
|
|
|
|
var title = data.title;
|
|
|
|
var title = data.title;
|
|
|
|
var href = data.href;
|
|
|
|
var href = data.href;
|
|
|
|
var padData = store.userObject.getFileData(store.userObject.getIdFromHref(href));
|
|
|
|
var channel = data.channel;
|
|
|
|
var p = Hash.parsePadUrl(href, padData && padData.password);
|
|
|
|
var p = Hash.parsePadUrl(href);
|
|
|
|
var h = p.hashData;
|
|
|
|
var h = p.hashData;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log(channel, data);
|
|
|
|
if (AppConfig.disableAnonymousStore && !store.loggedIn) { return void cb(); }
|
|
|
|
if (AppConfig.disableAnonymousStore && !store.loggedIn) { return void cb(); }
|
|
|
|
|
|
|
|
|
|
|
|
var owners;
|
|
|
|
var owners;
|
|
|
@ -713,19 +714,19 @@ define([
|
|
|
|
var pad = allPads[id];
|
|
|
|
var pad = allPads[id];
|
|
|
|
if (!pad.href) { continue; }
|
|
|
|
if (!pad.href) { continue; }
|
|
|
|
|
|
|
|
|
|
|
|
var p2 = Hash.parsePadUrl(pad.href, pad.password);
|
|
|
|
var p2 = Hash.parsePadUrl(pad.href);
|
|
|
|
var h2 = p2.hashData;
|
|
|
|
var h2 = p2.hashData;
|
|
|
|
|
|
|
|
|
|
|
|
// Different types, proceed to the next one
|
|
|
|
// Different types, proceed to the next one
|
|
|
|
// No hash data: corrupted pad?
|
|
|
|
// No hash data: corrupted pad?
|
|
|
|
if (p.type !== p2.type || !h2) { continue; }
|
|
|
|
if (p.type !== p2.type || !h2) { continue; }
|
|
|
|
|
|
|
|
// Different channel: continue
|
|
|
|
|
|
|
|
if (pad.channel !== channel) { continue; }
|
|
|
|
|
|
|
|
|
|
|
|
var shouldUpdate = p.hash.replace(/\/$/, '') === p2.hash.replace(/\/$/, '');
|
|
|
|
var shouldUpdate = p.hash.replace(/\/$/, '') === p2.hash.replace(/\/$/, '');
|
|
|
|
|
|
|
|
|
|
|
|
// If the hash is different but represents the same channel, check if weaker or stronger
|
|
|
|
// If the hash is different but represents the same channel, check if weaker or stronger
|
|
|
|
if (!shouldUpdate &&
|
|
|
|
if (!shouldUpdate && h.version !== 0) {
|
|
|
|
h.version === h2.version &&
|
|
|
|
|
|
|
|
h.channel === h2.channel) {
|
|
|
|
|
|
|
|
// We had view & now we have edit, update
|
|
|
|
// We had view & now we have edit, update
|
|
|
|
if (h2.mode === 'view' && h.mode === 'edit') { shouldUpdate = true; }
|
|
|
|
if (h2.mode === 'view' && h.mode === 'edit') { shouldUpdate = true; }
|
|
|
|
// Same mode and we had present URL, update
|
|
|
|
// Same mode and we had present URL, update
|
|
|
@ -762,13 +763,13 @@ define([
|
|
|
|
if (!contains) {
|
|
|
|
if (!contains) {
|
|
|
|
Store.addPad({
|
|
|
|
Store.addPad({
|
|
|
|
href: href,
|
|
|
|
href: href,
|
|
|
|
|
|
|
|
channel: channel,
|
|
|
|
title: title,
|
|
|
|
title: title,
|
|
|
|
owners: owners,
|
|
|
|
owners: owners,
|
|
|
|
expire: expire,
|
|
|
|
expire: expire,
|
|
|
|
password: store.data && store.data.newPadPassword,
|
|
|
|
password: data.password,
|
|
|
|
path: data.path || (store.data && store.data.initialPath)
|
|
|
|
path: data.path
|
|
|
|
}, cb);
|
|
|
|
}, cb);
|
|
|
|
delete store.data.newPadPassword;
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onSync(cb);
|
|
|
|
onSync(cb);
|
|
|
@ -807,14 +808,6 @@ define([
|
|
|
|
Store.getPadData = function (id, cb) {
|
|
|
|
Store.getPadData = function (id, cb) {
|
|
|
|
cb(store.userObject.getFileData(id));
|
|
|
|
cb(store.userObject.getFileData(id));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
Store.setInitialPath = function (path) {
|
|
|
|
|
|
|
|
if (!store.data) { return; }
|
|
|
|
|
|
|
|
store.data.initialPath = path;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
Store.setNewPadPassword = function (password) {
|
|
|
|
|
|
|
|
if (!store.data) { return; }
|
|
|
|
|
|
|
|
store.data.newPadPassword = password;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Messaging (manage friends from the userlist)
|
|
|
|
// Messaging (manage friends from the userlist)
|
|
|
|