From 921e6eb3c3fc3ba1b20602a15fdaa42b7f0bf083 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 11 Jun 2018 10:33:35 +0200 Subject: [PATCH] Fix wrong pad title in drive --- www/common/metadata-manager.js | 4 +++- www/common/sframe-common-outer.js | 3 ++- www/common/sframe-common-title.js | 7 +++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/www/common/metadata-manager.js b/www/common/metadata-manager.js index fed4183d3..1426bc7cf 100644 --- a/www/common/metadata-manager.js +++ b/www/common/metadata-manager.js @@ -64,7 +64,9 @@ define(['json.sortify'], function (Sortify) { if (metadataObj.title !== rememberedTitle) { rememberedTitle = metadataObj.title; - titleChangeHandlers.forEach(function (f) { f(metadataObj.title); }); + titleChangeHandlers.forEach(function (f) { + f(metadataObj.title, metadataObj.defaultTitle); + }); } changeHandlers.forEach(function (f) { f(); }); diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index c78bf53f9..5f0bac953 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -312,7 +312,8 @@ define([ var title = currentTabTitle.replace(/\{title\}/g, currentTitle || 'CryptPad'); document.title = title; }; - sframeChan.on('Q_SET_PAD_TITLE_IN_DRIVE', function (newTitle, cb) { + sframeChan.on('Q_SET_PAD_TITLE_IN_DRIVE', function (newData, cb) { + var newTitle = newData.title || newData.defaultTitle; currentTitle = newTitle; setDocumentTitle(); var data = { diff --git a/www/common/sframe-common-title.js b/www/common/sframe-common-title.js index 0a838ef34..dcbf6288a 100644 --- a/www/common/sframe-common-title.js +++ b/www/common/sframe-common-title.js @@ -59,8 +59,11 @@ define([ exp.defaultTitle = md.defaultTitle; exp.title = md.title; }); - metadataMgr.onTitleChange(function (title) { - sframeChan.query('Q_SET_PAD_TITLE_IN_DRIVE', title, function (err) { + metadataMgr.onTitleChange(function (title, defaultTitle) { + sframeChan.query('Q_SET_PAD_TITLE_IN_DRIVE', { + title: title, + defaultTitle: defaultTitle + }, function (err) { if (err === 'E_OVER_LIMIT') { return void UI.alert(Messages.pinLimitNotPinned, null, true); } else if (err) { return; }