Dynamically update show more title

This commit is contained in:
Cohee
2025-05-14 00:49:33 +03:00
parent dfbc5ec4ac
commit 155172a2b4
2 changed files with 6 additions and 1 deletions

View File

@@ -73,7 +73,7 @@
{{/with}} {{/with}}
{{/each}} {{/each}}
{{#if more}} {{#if more}}
<button class="menu_button menu_button_icon showMoreChats" data-i18n="[title]Show more recent chats" title="Show more recent chats"> <button class="menu_button menu_button_icon showMoreChats">
<small class="fa-solid fa-chevron-down fa-fw fa-1x"></small> <small class="fa-solid fa-chevron-down fa-fw fa-1x"></small>
</button> </button>
{{/if}} {{/if}}

View File

@@ -135,12 +135,17 @@ async function sendWelcomePanel() {
}); });
const hiddenChats = fragment.querySelectorAll('.recentChat.hidden'); const hiddenChats = fragment.querySelectorAll('.recentChat.hidden');
fragment.querySelectorAll('button.showMoreChats').forEach((button) => { fragment.querySelectorAll('button.showMoreChats').forEach((button) => {
const showRecentChatsTitle = t`Show more recent chats`;
const hideRecentChatsTitle = t`Show less recent chats`;
button.setAttribute('title', showRecentChatsTitle);
button.addEventListener('click', () => { button.addEventListener('click', () => {
const rotate = button.classList.contains('rotated'); const rotate = button.classList.contains('rotated');
hiddenChats.forEach((chatItem) => { hiddenChats.forEach((chatItem) => {
chatItem.classList.toggle('hidden', rotate); chatItem.classList.toggle('hidden', rotate);
}); });
button.classList.toggle('rotated', !rotate); button.classList.toggle('rotated', !rotate);
button.setAttribute('title', rotate ? showRecentChatsTitle : hideRecentChatsTitle);
}); });
}); });
fragment.querySelectorAll('button.openTemporaryChat').forEach((button) => { fragment.querySelectorAll('button.openTemporaryChat').forEach((button) => {