feat: add loading toast for republish actions

This commit is contained in:
codytseng
2025-09-23 21:51:10 +08:00
parent 1ff965969d
commit 5ef08b933e
17 changed files with 74 additions and 58 deletions

View File

@@ -64,19 +64,23 @@ export function useMenuActions({
label: <div className="text-left"> {t('Write relays')}</div>, label: <div className="text-left"> {t('Write relays')}</div>,
onClick: async () => { onClick: async () => {
closeDrawer() closeDrawer()
const promise = async () => {
const relays = await client.determineTargetRelays(event) const relays = await client.determineTargetRelays(event)
if (relays?.length) { if (relays?.length) {
await client await client.publishEvent(relays, event)
.publishEvent(relays, event) }
.then(() => { }
toast.success(t('Successfully republish to your write relays')) toast.promise(promise, {
}) loading: t('Republishing...'),
.catch((error) => { success: () => {
toast.error( return t('Successfully republish to your write relays')
t('Failed to republish to your write relays: {{error}}', { error: error.message }) },
) error: (err) => {
return t('Failed to republish to your write relays: {{error}}', {
error: err.message
}) })
} }
})
} }
}) })
} }
@@ -89,20 +93,18 @@ export function useMenuActions({
label: <div className="text-left truncate">{set.name}</div>, label: <div className="text-left truncate">{set.name}</div>,
onClick: async () => { onClick: async () => {
closeDrawer() closeDrawer()
await client const promise = client.publishEvent(set.relayUrls, event)
.publishEvent(set.relayUrls, event) toast.promise(promise, {
.then(() => { loading: t('Republishing...'),
toast.success( success: () => {
t('Successfully republish to relay set: {{name}}', { name: set.name }) return t('Successfully republish to relay set: {{name}}', { name: set.name })
) },
}) error: (err) => {
.catch((error) => { return t('Failed to republish to relay set: {{name}}. Error: {{error}}', {
toast.error(
t('Failed to republish to relay set: {{name}}. Error: {{error}}', {
name: set.name, name: set.name,
error: error.message error: err.message
}) })
) }
}) })
}, },
separator: index === 0 separator: index === 0
@@ -121,20 +123,18 @@ export function useMenuActions({
), ),
onClick: async () => { onClick: async () => {
closeDrawer() closeDrawer()
await client const promise = client.publishEvent([relay], event)
.publishEvent([relay], event) toast.promise(promise, {
.then(() => { loading: t('Republishing...'),
toast.success( success: () => {
t('Successfully republish to relay: {{url}}', { url: simplifyUrl(relay) }) return t('Successfully republish to relay: {{url}}', { url: simplifyUrl(relay) })
) },
}) error: (err) => {
.catch((error) => { return t('Failed to republish to relay: {{url}}. Error: {{error}}', {
toast.error(
t('Failed to republish to relay: {{url}}. Error: {{error}}', {
url: simplifyUrl(relay), url: simplifyUrl(relay),
error: error.message error: err.message
}) })
) }
}) })
}, },
separator: index === 0 separator: index === 0

View File

@@ -419,6 +419,7 @@ export default {
'No relays selected': 'لم يتم اختيار أي مرحل', 'No relays selected': 'لم يتم اختيار أي مرحل',
'Post to': 'نشر إلى', 'Post to': 'نشر إلى',
'Write relays and {{count}} other relays': 'مرحلات الكتابة و {{count}} مرحل آخر', 'Write relays and {{count}} other relays': 'مرحلات الكتابة و {{count}} مرحل آخر',
'{{count}} relays': '{{count}} ريلايات' '{{count}} relays': '{{count}} ريلايات',
'Republishing...': 'جارٍ إعادة النشر...'
} }
} }

View File

@@ -431,6 +431,7 @@ export default {
'No relays selected': 'Keine Relays ausgewählt', 'No relays selected': 'Keine Relays ausgewählt',
'Post to': 'Posten an', 'Post to': 'Posten an',
'Write relays and {{count}} other relays': 'Schreib-Relays und {{count}} andere Relays', '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...'
} }
} }

View File

@@ -418,6 +418,7 @@ export default {
'No relays selected': 'No relays selected', 'No relays selected': 'No relays selected',
'Post to': 'Post to', 'Post to': 'Post to',
'Write relays and {{count}} other relays': 'Write relays and {{count}} other relays', 'Write relays and {{count}} other relays': 'Write relays and {{count}} other relays',
'{{count}} relays': '{{count}} relays' '{{count}} relays': '{{count}} relays',
'Republishing...': 'Republishing...'
} }
} }

View File

@@ -426,6 +426,7 @@ export default {
'No relays selected': 'No hay relés seleccionados', 'No relays selected': 'No hay relés seleccionados',
'Post to': 'Publicar en', 'Post to': 'Publicar en',
'Write relays and {{count}} other relays': 'Relés de escritura y {{count}} otros relés', '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...'
} }
} }

View File

@@ -421,6 +421,7 @@ export default {
'No relays selected': 'هیچ رله‌ای انتخاب نشده', 'No relays selected': 'هیچ رله‌ای انتخاب نشده',
'Post to': 'پست کردن به', 'Post to': 'پست کردن به',
'Write relays and {{count}} other relays': 'رله‌های نوشتن و {{count}} رله دیگر', 'Write relays and {{count}} other relays': 'رله‌های نوشتن و {{count}} رله دیگر',
'{{count}} relays': '{{count}} رله' '{{count}} relays': '{{count}} رله',
'Republishing...': 'در حال بازنشر...'
} }
} }

View File

@@ -430,6 +430,7 @@ export default {
'No relays selected': 'Aucun relais sélectionné', 'No relays selected': 'Aucun relais sélectionné',
'Post to': 'Publier sur', 'Post to': 'Publier sur',
'Write relays and {{count}} other relays': 'Relais décriture et {{count}} autres relais', '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...'
} }
} }

View File

@@ -423,6 +423,7 @@ export default {
'No relays selected': 'कोई रिले चयनित नहीं', 'No relays selected': 'कोई रिले चयनित नहीं',
'Post to': 'पोस्ट करें', 'Post to': 'पोस्ट करें',
'Write relays and {{count}} other relays': 'राइट रिले और {{count}} अन्य रिले', 'Write relays and {{count}} other relays': 'राइट रिले और {{count}} अन्य रिले',
'{{count}} relays': '{{count}} रिले' '{{count}} relays': '{{count}} रिले',
'Republishing...': 'पुनः प्रकाशित कर रहे हैं...'
} }
} }

View File

@@ -426,6 +426,7 @@ export default {
'No relays selected': 'Nessun relay selezionato', 'No relays selected': 'Nessun relay selezionato',
'Post to': 'Pubblica su', 'Post to': 'Pubblica su',
'Write relays and {{count}} other relays': 'Relay di scrittura e {{count}} altri relay', '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...'
} }
} }

View File

@@ -422,6 +422,7 @@ export default {
'No relays selected': 'リレーが選択されていません', 'No relays selected': 'リレーが選択されていません',
'Post to': '投稿先', 'Post to': '投稿先',
'Write relays and {{count}} other relays': '書き込みリレーと他の {{count}} 個のリレー', 'Write relays and {{count}} other relays': '書き込みリレーと他の {{count}} 個のリレー',
'{{count}} relays': '{{count}} 個のリレー' '{{count}} relays': '{{count}} 個のリレー',
'Republishing...': '再公開中...'
} }
} }

View File

@@ -422,6 +422,7 @@ export default {
'No relays selected': '선택된 릴레이가 없습니다', 'No relays selected': '선택된 릴레이가 없습니다',
'Post to': '게시 대상', 'Post to': '게시 대상',
'Write relays and {{count}} other relays': '쓰기 릴레이 및 기타 {{count}}개 릴레이', 'Write relays and {{count}} other relays': '쓰기 릴레이 및 기타 {{count}}개 릴레이',
'{{count}} relays': '{{count}}개 릴레이' '{{count}} relays': '{{count}}개 릴레이',
'Republishing...': '다시 게시 중...'
} }
} }

View File

@@ -426,6 +426,7 @@ export default {
'No relays selected': 'Nie wybrano przekaźników', 'No relays selected': 'Nie wybrano przekaźników',
'Post to': 'Opublikuj na', 'Post to': 'Opublikuj na',
'Write relays and {{count}} other relays': 'Przekaźniki zapisu i {{count}} innych przekaźników', '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...'
} }
} }

View File

@@ -423,6 +423,7 @@ export default {
'No relays selected': 'Nenhum relay selecionado', 'No relays selected': 'Nenhum relay selecionado',
'Post to': 'Postar em', 'Post to': 'Postar em',
'Write relays and {{count}} other relays': 'Relays de escrita e {{count}} outros relays', 'Write relays and {{count}} other relays': 'Relays de escrita e {{count}} outros relays',
'{{count}} relays': '{{count}} relays' '{{count}} relays': '{{count}} relays',
'Republishing...': 'Republicando...'
} }
} }

View File

@@ -426,6 +426,7 @@ export default {
'No relays selected': 'Nenhum relay selecionado', 'No relays selected': 'Nenhum relay selecionado',
'Post to': 'Publicar para', 'Post to': 'Publicar para',
'Write relays and {{count}} other relays': 'Relays de escrita e {{count}} outros relays', 'Write relays and {{count}} other relays': 'Relays de escrita e {{count}} outros relays',
'{{count}} relays': '{{count}} relays' '{{count}} relays': '{{count}} relays',
'Republishing...': 'Republicando...'
} }
} }

View File

@@ -428,6 +428,7 @@ export default {
'Post to': 'Опубликовать в', 'Post to': 'Опубликовать в',
'Write relays and {{count}} other relays': 'Write relays and {{count}} other relays':
'Ретрансляторы записи и {{count}} других ретрансляторов', 'Ретрансляторы записи и {{count}} других ретрансляторов',
'{{count}} relays': '{{count}} ретрансляторов' '{{count}} relays': '{{count}} ретрансляторов',
'Republishing...': 'Ретрансляция...'
} }
} }

View File

@@ -417,6 +417,7 @@ export default {
'No relays selected': 'ไม่ได้เลือกรีเลย์', 'No relays selected': 'ไม่ได้เลือกรีเลย์',
'Post to': 'โพสต์ไปยัง', 'Post to': 'โพสต์ไปยัง',
'Write relays and {{count}} other relays': 'รีเลย์เขียนและรีเลย์อื่น ๆ {{count}} ตัว', 'Write relays and {{count}} other relays': 'รีเลย์เขียนและรีเลย์อื่น ๆ {{count}} ตัว',
'{{count}} relays': 'รีเลย์ {{count}} ตัว' '{{count}} relays': 'รีเลย์ {{count}} ตัว',
'Republishing...': 'กำลังเผยแพร่ซ้ำ...'
} }
} }

View File

@@ -415,6 +415,7 @@ export default {
'No relays selected': '未选择服务器', 'No relays selected': '未选择服务器',
'Post to': '发布到', 'Post to': '发布到',
'Write relays and {{count}} other relays': '写服务器和其他 {{count}} 个服务器', 'Write relays and {{count}} other relays': '写服务器和其他 {{count}} 个服务器',
'{{count}} relays': '{{count}} 个服务器' '{{count}} relays': '{{count}} 个服务器',
'Republishing...': '正在重新发布...'
} }
} }