fix: improve promise handling in DOM event listeners
Wrap async callbacks in void operators for DOM addEventListener calls to properly handle Promise<void> returns in void contexts. This follows TypeScript best practices and Obsidian plugin guidelines. Changes: - settings.ts: Fix 5 button click handlers (server controls, API key actions, config copy) - notification-history.ts: Fix export button click handler All async operations are properly awaited within void-wrapped IIFEs, ensuring errors are not silently swallowed while maintaining the expected void return type for event listeners.
This commit is contained in:
@@ -162,14 +162,16 @@ export class NotificationHistoryModal extends Modal {
|
||||
|
||||
// Export button
|
||||
const exportButton = actionsContainer.createEl('button', { text: 'Export to Clipboard' });
|
||||
exportButton.addEventListener('click', async () => {
|
||||
const exportData = JSON.stringify(this.filteredHistory, null, 2);
|
||||
await navigator.clipboard.writeText(exportData);
|
||||
// Show temporary success message
|
||||
exportButton.textContent = '✅ Copied!';
|
||||
setTimeout(() => {
|
||||
exportButton.textContent = 'Export to Clipboard';
|
||||
}, 2000);
|
||||
exportButton.addEventListener('click', () => {
|
||||
void (async () => {
|
||||
const exportData = JSON.stringify(this.filteredHistory, null, 2);
|
||||
await navigator.clipboard.writeText(exportData);
|
||||
// Show temporary success message
|
||||
exportButton.textContent = '✅ Copied!';
|
||||
setTimeout(() => {
|
||||
exportButton.textContent = 'Export to Clipboard';
|
||||
}, 2000);
|
||||
})();
|
||||
});
|
||||
|
||||
// Close button
|
||||
|
||||
Reference in New Issue
Block a user