show "Style installed" in manager for styles added while it's open

This commit is contained in:
tophf 2017-12-02 07:07:12 +03:00
parent 536064ae9a
commit 7de3e37a51
5 changed files with 18 additions and 9 deletions

View File

@ -395,7 +395,7 @@ function saveStyle(style) {
.then(decide); .then(decide);
function maybeCalcDigest() { function maybeCalcDigest() {
if (reason === 'update' || reason === 'update-digest') { if (['install', 'update', 'update-digest'].includes(reason)) {
return calcStyleDigest(style).then(digest => { return calcStyleDigest(style).then(digest => {
style.originalDigest = digest; style.originalDigest = digest;
}); });

View File

@ -132,7 +132,8 @@
function saveStyleCode(message, name, addProps) { function saveStyleCode(message, name, addProps) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const needsConfirmation = message === 'styleInstall' || !saveStyleCode.confirmed; const isNew = message === 'styleInstall';
const needsConfirmation = isNew || !saveStyleCode.confirmed;
if (needsConfirmation && !confirm(chrome.i18n.getMessage(message, [name]))) { if (needsConfirmation && !confirm(chrome.i18n.getMessage(message, [name]))) {
reject(); reject();
return; return;
@ -148,10 +149,10 @@
chrome.runtime.sendMessage( chrome.runtime.sendMessage(
Object.assign(json, addProps, { Object.assign(json, addProps, {
method: 'saveStyle', method: 'saveStyle',
reason: 'update', reason: isNew ? 'install' : 'update',
}), }),
style => { style => {
if (message === 'styleUpdate' && style.updateUrl.includes('?')) { if (!isNew && style.updateUrl.includes('?')) {
enableUpdateButton(true); enableUpdateButton(true);
} else { } else {
sendEvent('styleInstalledChrome'); sendEvent('styleInstalledChrome');

View File

@ -371,6 +371,11 @@ label.nobreak input {
display: inline; display: inline;
} }
.newUI .up-to-date svg,
.newUI .updated svg {
cursor: auto;
}
.newUI .update-done .updated svg { .newUI .update-done .updated svg {
top: -4px; top: -4px;
position: relative; position: relative;

View File

@ -400,8 +400,8 @@ function handleUpdate(style, {reason, method} = {}) {
oldEntry.remove(); oldEntry.remove();
} }
} }
if (reason === 'update' && entry.matches('.updatable')) { if (reason === 'update' || reason === 'install' && entry.matches('.updatable')) {
handleUpdateInstalled(entry); handleUpdateInstalled(entry, reason);
} }
filterAndAppend({entry}); filterAndAppend({entry});
if (!entry.matches('.hidden') && reason !== 'import') { if (!entry.matches('.hidden') && reason !== 'import') {

View File

@ -185,9 +185,12 @@ function showUpdateHistory() {
} }
function handleUpdateInstalled(entry) { function handleUpdateInstalled(entry, reason) {
entry.classList.add('update-done'); const isNew = reason === 'install';
const note = t(isNew ? 'installButtonInstalled' : 'updateCompleted');
entry.classList.add('update-done', ...(isNew ? ['install-done'] : []));
entry.classList.remove('can-update', 'updatable'); entry.classList.remove('can-update', 'updatable');
$('.update-note', entry).textContent = t('updateCompleted'); $('.update-note', entry).textContent = note;
$('.updated', entry).title = note;
renderUpdatesOnlyFilter(); renderUpdatesOnlyFilter();
} }