diff --git a/src/components/NoteOptions/useMenuActions.tsx b/src/components/NoteOptions/useMenuActions.tsx index 2dc2d655..68d494af 100644 --- a/src/components/NoteOptions/useMenuActions.tsx +++ b/src/components/NoteOptions/useMenuActions.tsx @@ -64,19 +64,23 @@ export function useMenuActions({ label:
{t('Write relays')}
, onClick: async () => { closeDrawer() - const relays = await client.determineTargetRelays(event) - if (relays?.length) { - await client - .publishEvent(relays, event) - .then(() => { - toast.success(t('Successfully republish to your write relays')) - }) - .catch((error) => { - toast.error( - t('Failed to republish to your write relays: {{error}}', { error: error.message }) - ) - }) + const promise = async () => { + const relays = await client.determineTargetRelays(event) + if (relays?.length) { + await client.publishEvent(relays, event) + } } + toast.promise(promise, { + loading: t('Republishing...'), + success: () => { + return t('Successfully republish to your write relays') + }, + error: (err) => { + return t('Failed to republish to your write relays: {{error}}', { + error: err.message + }) + } + }) } }) } @@ -89,21 +93,19 @@ export function useMenuActions({ label:
{set.name}
, onClick: async () => { closeDrawer() - await client - .publishEvent(set.relayUrls, event) - .then(() => { - toast.success( - t('Successfully republish to relay set: {{name}}', { name: set.name }) - ) - }) - .catch((error) => { - toast.error( - t('Failed to republish to relay set: {{name}}. Error: {{error}}', { - name: set.name, - error: error.message - }) - ) - }) + const promise = client.publishEvent(set.relayUrls, event) + toast.promise(promise, { + loading: t('Republishing...'), + success: () => { + return t('Successfully republish to relay set: {{name}}', { name: set.name }) + }, + error: (err) => { + return t('Failed to republish to relay set: {{name}}. Error: {{error}}', { + name: set.name, + error: err.message + }) + } + }) }, separator: index === 0 })) @@ -121,21 +123,19 @@ export function useMenuActions({ ), onClick: async () => { closeDrawer() - await client - .publishEvent([relay], event) - .then(() => { - toast.success( - t('Successfully republish to relay: {{url}}', { url: simplifyUrl(relay) }) - ) - }) - .catch((error) => { - toast.error( - t('Failed to republish to relay: {{url}}. Error: {{error}}', { - url: simplifyUrl(relay), - error: error.message - }) - ) - }) + const promise = client.publishEvent([relay], event) + toast.promise(promise, { + loading: t('Republishing...'), + success: () => { + return t('Successfully republish to relay: {{url}}', { url: simplifyUrl(relay) }) + }, + error: (err) => { + return t('Failed to republish to relay: {{url}}. Error: {{error}}', { + url: simplifyUrl(relay), + error: err.message + }) + } + }) }, separator: index === 0 })) diff --git a/src/i18n/locales/ar.ts b/src/i18n/locales/ar.ts index 8b7bf875..c3d8c162 100644 --- a/src/i18n/locales/ar.ts +++ b/src/i18n/locales/ar.ts @@ -419,6 +419,7 @@ export default { 'No relays selected': 'لم يتم اختيار أي مرحل', 'Post to': 'نشر إلى', 'Write relays and {{count}} other relays': 'مرحلات الكتابة و {{count}} مرحل آخر', - '{{count}} relays': '{{count}} ريلايات' + '{{count}} relays': '{{count}} ريلايات', + 'Republishing...': 'جارٍ إعادة النشر...' } } diff --git a/src/i18n/locales/de.ts b/src/i18n/locales/de.ts index a18dfbb6..0cad41a2 100644 --- a/src/i18n/locales/de.ts +++ b/src/i18n/locales/de.ts @@ -431,6 +431,7 @@ export default { 'No relays selected': 'Keine Relays ausgewählt', 'Post to': 'Posten an', 'Write relays and {{count}} other relays': 'Schreib-Relays und {{count}} andere Relays', - '{{count}} relays': '{{count}} Relays' + '{{count}} relays': '{{count}} Relays', + 'Republishing...': 'Wird erneut veröffentlicht...' } } diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index 010237f7..f05af379 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -418,6 +418,7 @@ export default { 'No relays selected': 'No relays selected', 'Post to': 'Post to', 'Write relays and {{count}} other relays': 'Write relays and {{count}} other relays', - '{{count}} relays': '{{count}} relays' + '{{count}} relays': '{{count}} relays', + 'Republishing...': 'Republishing...' } } diff --git a/src/i18n/locales/es.ts b/src/i18n/locales/es.ts index ff1882b8..cbd323ca 100644 --- a/src/i18n/locales/es.ts +++ b/src/i18n/locales/es.ts @@ -426,6 +426,7 @@ export default { 'No relays selected': 'No hay relés seleccionados', 'Post to': 'Publicar en', 'Write relays and {{count}} other relays': 'Relés de escritura y {{count}} otros relés', - '{{count}} relays': '{{count}} relés' + '{{count}} relays': '{{count}} relés', + 'Republishing...': 'Republicando...' } } diff --git a/src/i18n/locales/fa.ts b/src/i18n/locales/fa.ts index 5bc57451..fbdec74e 100644 --- a/src/i18n/locales/fa.ts +++ b/src/i18n/locales/fa.ts @@ -421,6 +421,7 @@ export default { 'No relays selected': 'هیچ رله‌ای انتخاب نشده', 'Post to': 'پست کردن به', 'Write relays and {{count}} other relays': 'رله‌های نوشتن و {{count}} رله دیگر', - '{{count}} relays': '{{count}} رله' + '{{count}} relays': '{{count}} رله', + 'Republishing...': 'در حال بازنشر...' } } diff --git a/src/i18n/locales/fr.ts b/src/i18n/locales/fr.ts index 36e7fe94..26940b9f 100644 --- a/src/i18n/locales/fr.ts +++ b/src/i18n/locales/fr.ts @@ -430,6 +430,7 @@ export default { 'No relays selected': 'Aucun relais sélectionné', 'Post to': 'Publier sur', 'Write relays and {{count}} other relays': 'Relais d’écriture et {{count}} autres relais', - '{{count}} relays': '{{count}} relais' + '{{count}} relays': '{{count}} relais', + 'Republishing...': 'Republication en cours...' } } diff --git a/src/i18n/locales/hi.ts b/src/i18n/locales/hi.ts index 618cf2cf..9bfb6855 100644 --- a/src/i18n/locales/hi.ts +++ b/src/i18n/locales/hi.ts @@ -423,6 +423,7 @@ export default { 'No relays selected': 'कोई रिले चयनित नहीं', 'Post to': 'पोस्ट करें', 'Write relays and {{count}} other relays': 'राइट रिले और {{count}} अन्य रिले', - '{{count}} relays': '{{count}} रिले' + '{{count}} relays': '{{count}} रिले', + 'Republishing...': 'पुनः प्रकाशित कर रहे हैं...' } } diff --git a/src/i18n/locales/it.ts b/src/i18n/locales/it.ts index 81a99733..514b0418 100644 --- a/src/i18n/locales/it.ts +++ b/src/i18n/locales/it.ts @@ -426,6 +426,7 @@ export default { 'No relays selected': 'Nessun relay selezionato', 'Post to': 'Pubblica su', 'Write relays and {{count}} other relays': 'Relay di scrittura e {{count}} altri relay', - '{{count}} relays': '{{count}} relay' + '{{count}} relays': '{{count}} relay', + 'Republishing...': 'Ricondivisione in corso...' } } diff --git a/src/i18n/locales/ja.ts b/src/i18n/locales/ja.ts index 732ec188..0b2b96d3 100644 --- a/src/i18n/locales/ja.ts +++ b/src/i18n/locales/ja.ts @@ -422,6 +422,7 @@ export default { 'No relays selected': 'リレーが選択されていません', 'Post to': '投稿先', 'Write relays and {{count}} other relays': '書き込みリレーと他の {{count}} 個のリレー', - '{{count}} relays': '{{count}} 個のリレー' + '{{count}} relays': '{{count}} 個のリレー', + 'Republishing...': '再公開中...' } } diff --git a/src/i18n/locales/ko.ts b/src/i18n/locales/ko.ts index 9c34bc77..85cdf69b 100644 --- a/src/i18n/locales/ko.ts +++ b/src/i18n/locales/ko.ts @@ -422,6 +422,7 @@ export default { 'No relays selected': '선택된 릴레이가 없습니다', 'Post to': '게시 대상', 'Write relays and {{count}} other relays': '쓰기 릴레이 및 기타 {{count}}개 릴레이', - '{{count}} relays': '{{count}}개 릴레이' + '{{count}} relays': '{{count}}개 릴레이', + 'Republishing...': '다시 게시 중...' } } diff --git a/src/i18n/locales/pl.ts b/src/i18n/locales/pl.ts index d13c0f87..1b965adf 100644 --- a/src/i18n/locales/pl.ts +++ b/src/i18n/locales/pl.ts @@ -426,6 +426,7 @@ export default { 'No relays selected': 'Nie wybrano przekaźników', 'Post to': 'Opublikuj na', 'Write relays and {{count}} other relays': 'Przekaźniki zapisu i {{count}} innych przekaźników', - '{{count}} relays': '{{count}} przekaźników' + '{{count}} relays': '{{count}} przekaźników', + 'Republishing...': 'Ponowne publikowanie...' } } diff --git a/src/i18n/locales/pt-BR.ts b/src/i18n/locales/pt-BR.ts index 80f5ab78..7d199758 100644 --- a/src/i18n/locales/pt-BR.ts +++ b/src/i18n/locales/pt-BR.ts @@ -423,6 +423,7 @@ export default { 'No relays selected': 'Nenhum relay selecionado', 'Post to': 'Postar em', 'Write relays and {{count}} other relays': 'Relays de escrita e {{count}} outros relays', - '{{count}} relays': '{{count}} relays' + '{{count}} relays': '{{count}} relays', + 'Republishing...': 'Republicando...' } } diff --git a/src/i18n/locales/pt-PT.ts b/src/i18n/locales/pt-PT.ts index d37ea540..141728b3 100644 --- a/src/i18n/locales/pt-PT.ts +++ b/src/i18n/locales/pt-PT.ts @@ -426,6 +426,7 @@ export default { 'No relays selected': 'Nenhum relay selecionado', 'Post to': 'Publicar para', 'Write relays and {{count}} other relays': 'Relays de escrita e {{count}} outros relays', - '{{count}} relays': '{{count}} relays' + '{{count}} relays': '{{count}} relays', + 'Republishing...': 'Republicando...' } } diff --git a/src/i18n/locales/ru.ts b/src/i18n/locales/ru.ts index d8938847..e9725130 100644 --- a/src/i18n/locales/ru.ts +++ b/src/i18n/locales/ru.ts @@ -428,6 +428,7 @@ export default { 'Post to': 'Опубликовать в', 'Write relays and {{count}} other relays': 'Ретрансляторы записи и {{count}} других ретрансляторов', - '{{count}} relays': '{{count}} ретрансляторов' + '{{count}} relays': '{{count}} ретрансляторов', + 'Republishing...': 'Ретрансляция...' } } diff --git a/src/i18n/locales/th.ts b/src/i18n/locales/th.ts index b724fefb..53bef223 100644 --- a/src/i18n/locales/th.ts +++ b/src/i18n/locales/th.ts @@ -417,6 +417,7 @@ export default { 'No relays selected': 'ไม่ได้เลือกรีเลย์', 'Post to': 'โพสต์ไปยัง', 'Write relays and {{count}} other relays': 'รีเลย์เขียนและรีเลย์อื่น ๆ {{count}} ตัว', - '{{count}} relays': 'รีเลย์ {{count}} ตัว' + '{{count}} relays': 'รีเลย์ {{count}} ตัว', + 'Republishing...': 'กำลังเผยแพร่ซ้ำ...' } } diff --git a/src/i18n/locales/zh.ts b/src/i18n/locales/zh.ts index 868ea62d..7b44dc57 100644 --- a/src/i18n/locales/zh.ts +++ b/src/i18n/locales/zh.ts @@ -415,6 +415,7 @@ export default { 'No relays selected': '未选择服务器', 'Post to': '发布到', 'Write relays and {{count}} other relays': '写服务器和其他 {{count}} 个服务器', - '{{count}} relays': '{{count}} 个服务器' + '{{count}} relays': '{{count}} 个服务器', + 'Republishing...': '正在重新发布...' } }