fixing the timing in btn pressing actions
This commit is contained in:
parent
e28726f30f
commit
fc803700fa
2 changed files with 4 additions and 7 deletions
|
|
@ -83,7 +83,7 @@ function _ensureContainer() {
|
|||
|
||||
const toolbar = document.createElement('div');
|
||||
toolbar.id = 'mzta-toolbar';
|
||||
toolbar.style.cssText = `display: none; align-items: flex-start; gap: 8px; padding: 4px 0.2rem;; background-color: ${colors.toolbar.bg}; border-bottom: 1px solid ${colors.toolbar.border}; font-size: 13px; color: ${colors.toolbar.text};`;
|
||||
toolbar.style.cssText = `display: none; align-items: flex-start; justify-content: flex-end; gap: 8px; padding: 4px 0.2rem;; background-color: ${colors.toolbar.bg}; border-bottom: 1px solid ${colors.toolbar.border}; font-size: 13px; color: ${colors.toolbar.text};`;
|
||||
container.appendChild(toolbar);
|
||||
|
||||
const panels = document.createElement('div');
|
||||
|
|
@ -102,12 +102,6 @@ function _updateToolbarVisibility() {
|
|||
if (!toolbar) return;
|
||||
const hasItems = toolbar.querySelector('#mzta-toolbar-spam, #mzta-toolbar-summary, #mzta-toolbar-translation');
|
||||
toolbar.style.display = hasItems ? 'flex' : 'none';
|
||||
// Push the first button (summary or translation) to the right
|
||||
const summary = document.getElementById('mzta-toolbar-summary');
|
||||
const translation = document.getElementById('mzta-toolbar-translation');
|
||||
const firstBtn = summary || translation;
|
||||
if (summary) summary.style.marginLeft = (firstBtn === summary) ? 'auto' : '';
|
||||
if (translation) translation.style.marginLeft = (firstBtn === translation) ? 'auto' : '';
|
||||
}
|
||||
|
||||
const _TOOLBAR_SLOT_ORDER = ['mzta-toolbar-spam', 'mzta-toolbar-summary', 'mzta-toolbar-translation'];
|
||||
|
|
@ -1483,6 +1477,7 @@ switch (message.command) {
|
|||
}
|
||||
|
||||
case "showTranslationButton": {
|
||||
_removePanel('mzta-translation-generating');
|
||||
if (document.getElementById('mzta-toolbar-translation')) return Promise.resolve(true);
|
||||
|
||||
const colors = _getThemeColors();
|
||||
|
|
|
|||
|
|
@ -399,6 +399,8 @@ messenger.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|||
case 'triggerTranslationGeneration':
|
||||
async function _triggerTranslationGeneration(message) {
|
||||
let tabId = sender.tab.id;
|
||||
// Fire the inline loading indicator immediately, before any await
|
||||
browser.tabs.sendMessage(tabId, { command: "showTranslationGenerating" });
|
||||
let prefs_tl = await browser.storage.sync.get({
|
||||
translate_lang: prefs_default.translate_lang,
|
||||
default_chatgpt_lang: prefs_default.default_chatgpt_lang
|
||||
|
|
|
|||
Loading…
Reference in a new issue