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);
function maybeCalcDigest() {
if (reason === 'update' || reason === 'update-digest') {
if (['install', 'update', 'update-digest'].includes(reason)) {
return calcStyleDigest(style).then(digest => {
style.originalDigest = digest;
});

View File

@ -132,7 +132,8 @@
function saveStyleCode(message, name, addProps) {
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]))) {
reject();
return;
@ -148,10 +149,10 @@
chrome.runtime.sendMessage(
Object.assign(json, addProps, {
method: 'saveStyle',
reason: 'update',
reason: isNew ? 'install' : 'update',
}),
style => {
if (message === 'styleUpdate' && style.updateUrl.includes('?')) {
if (!isNew && style.updateUrl.includes('?')) {
enableUpdateButton(true);
} else {
sendEvent('styleInstalledChrome');

View File

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

View File

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

View File

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