Change the hash in the address bar when browsing a shared folder

pull/1/head
yflory 6 years ago
parent 38daf4676c
commit f662036817

@ -223,6 +223,8 @@ define({
// Refresh the drive when the drive has changed ('change' or 'remove' events) // Refresh the drive when the drive has changed ('change' or 'remove' events)
'EV_DRIVE_CHANGE': true, 'EV_DRIVE_CHANGE': true,
'EV_DRIVE_REMOVE': true, 'EV_DRIVE_REMOVE': true,
// Set shared folder hash in the address bar
'EV_DRIVE_SET_HASH': true,
// Remove an owned pad from the server // Remove an owned pad from the server
'Q_REMOVE_OWNED_CHANNEL': true, 'Q_REMOVE_OWNED_CHANNEL': true,

@ -1895,8 +1895,8 @@ define([
'class': 'cp-toolbar-share-button', 'class': 'cp-toolbar-share-button',
title: Messages.shareButton title: Messages.shareButton
}); });
var $icon = $sharedIcon.clone().appendTo($shareBlock); $sharedIcon.clone().appendTo($shareBlock);
var $text = $('<span>').text(Messages.shareButton).appendTo($shareBlock); $('<span>').text(Messages.shareButton).appendTo($shareBlock);
var data = manager.getSharedFolderData(id); var data = manager.getSharedFolderData(id);
var parsed = Hash.parsePadUrl(data.href); var parsed = Hash.parsePadUrl(data.href);
if (!parsed || !parsed.hash) { return void console.error("Invalid href: "+data.href); } if (!parsed || !parsed.hash) { return void console.error("Invalid href: "+data.href); }
@ -2579,7 +2579,12 @@ define([
createNewButton(isInRoot, $toolbar.find('.cp-app-drive-toolbar-leftside')); createNewButton(isInRoot, $toolbar.find('.cp-app-drive-toolbar-leftside'));
var sfId = manager.isInSharedFolder(currentPath); var sfId = manager.isInSharedFolder(currentPath);
if (sfId) { if (sfId) {
var sfData = manager.getSharedFolderData(sfId);
var parsed = Hash.parsePadUrl(sfData.href);
sframeChan.event('EV_DRIVE_SET_HASH', parsed.hash || '');
createShareButton(sfId, $toolbar.find('.cp-app-drive-toolbar-leftside')); createShareButton(sfId, $toolbar.find('.cp-app-drive-toolbar-leftside'));
} else {
sframeChan.event('EV_DRIVE_SET_HASH', '');
} }
createTitle($toolbar.find('.cp-app-drive-path'), path); createTitle($toolbar.find('.cp-app-drive-path'), path);

@ -87,6 +87,14 @@ define([
cb(obj); cb(obj);
}); });
}); });
sframeChan.on('EV_DRIVE_SET_HASH', function (hash) {
// Update the hash in the address bar
var ohc = window.onhashchange;
window.onhashchange = function () {};
window.location.hash = hash || '';
window.onhashchange = ohc;
ohc({reset:true});
});
Cryptpad.onNetworkDisconnect.reg(function () { Cryptpad.onNetworkDisconnect.reg(function () {
sframeChan.event('EV_NETWORK_DISCONNECT'); sframeChan.event('EV_NETWORK_DISCONNECT');
}); });

Loading…
Cancel
Save