Browse Source

feat: add confirmation prompt when publishing event signed by a different user

imwald
codytseng 10 months ago
parent
commit
46b9f5625b
  1. 4
      src/i18n/locales/ar.ts
  2. 4
      src/i18n/locales/de.ts
  3. 4
      src/i18n/locales/en.ts
  4. 4
      src/i18n/locales/es.ts
  5. 4
      src/i18n/locales/fr.ts
  6. 4
      src/i18n/locales/it.ts
  7. 4
      src/i18n/locales/ja.ts
  8. 4
      src/i18n/locales/pl.ts
  9. 4
      src/i18n/locales/pt-BR.ts
  10. 4
      src/i18n/locales/pt-PT.ts
  11. 4
      src/i18n/locales/ru.ts
  12. 4
      src/i18n/locales/zh.ts
  13. 29
      src/providers/NostrProvider/index.tsx

4
src/i18n/locales/ar.ts

@ -227,6 +227,8 @@ export default {
Autoplay: 'التشغيل التلقائي', Autoplay: 'التشغيل التلقائي',
'Enable video autoplay on this device': 'تمكين التشغيل التلقائي للفيديو على هذا الجهاز', 'Enable video autoplay on this device': 'تمكين التشغيل التلقائي للفيديو على هذا الجهاز',
'Paste or drop media files to upload': 'الصق أو اسحب ملفات الوسائط لتحميلها', 'Paste or drop media files to upload': 'الصق أو اسحب ملفات الوسائط لتحميلها',
Preview: 'معاينة' Preview: 'معاينة',
'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?':
'أنت على وشك نشر حدث موقع من قبل [{{eventAuthorName}}]. أنت حالياً مسجل الدخول كـ [{{currentUsername}}]. هل أنت متأكد؟'
} }
} }

4
src/i18n/locales/de.ts

@ -233,6 +233,8 @@ export default {
'Aktiviere die automatische Video-Wiedergabe auf diesem Gerät', 'Aktiviere die automatische Video-Wiedergabe auf diesem Gerät',
'Paste or drop media files to upload': 'Paste or drop media files to upload':
'Füge Medien-Dateien ein oder ziehe sie hierher, um sie hochzuladen', 'Füge Medien-Dateien ein oder ziehe sie hierher, um sie hochzuladen',
Preview: 'Vorschau' Preview: 'Vorschau',
'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?':
'Du bist dabei, ein Ereignis zu veröffentlichen, das von [{{eventAuthorName}}] signiert wurde. Du bist derzeit als [{{currentUsername}}] angemeldet. Bist du sicher?'
} }
} }

4
src/i18n/locales/en.ts

@ -227,6 +227,8 @@ export default {
Autoplay: 'Autoplay', Autoplay: 'Autoplay',
'Enable video autoplay on this device': 'Enable video autoplay on this device', 'Enable video autoplay on this device': 'Enable video autoplay on this device',
'Paste or drop media files to upload': 'Paste or drop media files to upload', 'Paste or drop media files to upload': 'Paste or drop media files to upload',
Preview: 'Preview' Preview: 'Preview',
'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?':
'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?'
} }
} }

4
src/i18n/locales/es.ts

@ -232,6 +232,8 @@ export default {
'Enable video autoplay on this device': 'Enable video autoplay on this device':
'Habilitar reproducción automática de video en este dispositivo', 'Habilitar reproducción automática de video en este dispositivo',
'Paste or drop media files to upload': 'Pegar o soltar archivos multimedia para cargar', 'Paste or drop media files to upload': 'Pegar o soltar archivos multimedia para cargar',
Preview: 'Vista previa' Preview: 'Vista previa',
'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?':
'Estás a punto de publicar un evento firmado por [{{eventAuthorName}}]. Actualmente has iniciado sesión como [{{currentUsername}}]. ¿Estás seguro?'
} }
} }

4
src/i18n/locales/fr.ts

@ -232,6 +232,8 @@ export default {
'Activer la lecture automatique des vidéos sur cet appareil', 'Activer la lecture automatique des vidéos sur cet appareil',
'Paste or drop media files to upload': 'Paste or drop media files to upload':
'Coller ou déposer des fichiers multimédias à télécharger', 'Coller ou déposer des fichiers multimédias à télécharger',
Preview: 'Aperçu' Preview: 'Aperçu',
'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?':
'Vous êtes sur le point de publier un événement signé par [{{eventAuthorName}}]. Vous êtes actuellement connecté en tant que [{{currentUsername}}]. Êtes-vous sûr ?'
} }
} }

4
src/i18n/locales/it.ts

@ -231,6 +231,8 @@ export default {
'Enable video autoplay on this device': 'Enable video autoplay on this device':
'Abilita riproduzione automatica video su questo dispositivo', 'Abilita riproduzione automatica video su questo dispositivo',
'Paste or drop media files to upload': 'Incolla o trascina i file multimediali per caricarli', 'Paste or drop media files to upload': 'Incolla o trascina i file multimediali per caricarli',
Preview: 'Anteprima' Preview: 'Anteprima',
'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?':
'Stai per pubblicare un evento firmato da [{{eventAuthorName}}]. Attualmente sei connesso come [{{currentUsername}}]. Sei sicuro?'
} }
} }

4
src/i18n/locales/ja.ts

@ -228,6 +228,8 @@ export default {
Autoplay: '自動再生', Autoplay: '自動再生',
'Enable video autoplay on this device': 'このデバイスでのビデオ自動再生を有効にする', 'Enable video autoplay on this device': 'このデバイスでのビデオ自動再生を有効にする',
'Paste or drop media files to upload': 'メディアファイルを貼り付けるかドロップしてアップロード', 'Paste or drop media files to upload': 'メディアファイルを貼り付けるかドロップしてアップロード',
Preview: 'プレビュー' Preview: 'プレビュー',
'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?':
'あなたは[{{eventAuthorName}}]によって署名されたイベントを公開しようとしています。現在[{{currentUsername}}]としてログインしています。よろしいですか?'
} }
} }

4
src/i18n/locales/pl.ts

@ -230,6 +230,8 @@ export default {
'Enable video autoplay on this device': 'Enable video autoplay on this device':
'Włącz automatyczne odtwarzanie wideo na tym urządzeniu', 'Włącz automatyczne odtwarzanie wideo na tym urządzeniu',
'Paste or drop media files to upload': 'Wklej lub upuść pliki multimedialne, aby przesłać', 'Paste or drop media files to upload': 'Wklej lub upuść pliki multimedialne, aby przesłać',
Preview: 'Podgląd' Preview: 'Podgląd',
'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?':
'Zaraz opublikujesz zdarzenie podpisane przez [{{eventAuthorName}}]. Obecnie jesteś zalogowany jako [{{currentUsername}}]. Czy jesteś pewien?'
} }
} }

4
src/i18n/locales/pt-BR.ts

@ -230,6 +230,8 @@ export default {
'Enable video autoplay on this device': 'Enable video autoplay on this device':
'Habilitar reprodução automática de vídeo neste dispositivo', 'Habilitar reprodução automática de vídeo neste dispositivo',
'Paste or drop media files to upload': 'Cole ou arraste arquivos de mídia para fazer upload', 'Paste or drop media files to upload': 'Cole ou arraste arquivos de mídia para fazer upload',
Preview: 'Pré-visualização' Preview: 'Pré-visualização',
'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?':
'Você está prestes a publicar um evento assinado por [{{eventAuthorName}}]. Você está atualmente logado como [{{currentUsername}}]. Tem certeza?'
} }
} }

4
src/i18n/locales/pt-PT.ts

@ -231,6 +231,8 @@ export default {
'Enable video autoplay on this device': 'Enable video autoplay on this device':
'Habilitar reprodução automática de vídeo neste dispositivo', 'Habilitar reprodução automática de vídeo neste dispositivo',
'Paste or drop media files to upload': 'Cole ou solte arquivos de mídia para fazer upload', 'Paste or drop media files to upload': 'Cole ou solte arquivos de mídia para fazer upload',
Preview: 'Pré-visualização' Preview: 'Pré-visualização',
'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?':
'Você está prestes a publicar um evento assinado por [{{eventAuthorName}}]. Você está atualmente logado como [{{currentUsername}}]. Tem certeza?'
} }
} }

4
src/i18n/locales/ru.ts

@ -231,6 +231,8 @@ export default {
Autoplay: 'Автовоспроизведение', Autoplay: 'Автовоспроизведение',
'Enable video autoplay on this device': 'Включить автовоспроизведение видео на этом устройстве', 'Enable video autoplay on this device': 'Включить автовоспроизведение видео на этом устройстве',
'Paste or drop media files to upload': 'Вставьте или перетащите медиафайлы для загрузки', 'Paste or drop media files to upload': 'Вставьте или перетащите медиафайлы для загрузки',
Preview: 'Предварительный просмотр' Preview: 'Предварительный просмотр',
'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?':
'Вы собираетесь опубликовать событие, подписанное [{{eventAuthorName}}]. Вы в данный момент вошли как [{{currentUsername}}]. Вы уверены?'
} }
} }

4
src/i18n/locales/zh.ts

@ -228,6 +228,8 @@ export default {
Autoplay: '自动播放', Autoplay: '自动播放',
'Enable video autoplay on this device': '在此设备上启用视频自动播放', 'Enable video autoplay on this device': '在此设备上启用视频自动播放',
'Paste or drop media files to upload': '支持粘贴或拖放媒体文件进行上传', 'Paste or drop media files to upload': '支持粘贴或拖放媒体文件进行上传',
Preview: '预览' Preview: '预览',
'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?':
'您即将发布一条由 [{{eventAuthorName}}] 签名的事件。您当前以 [{{currentUsername}}] 登录。确定吗?'
} }
} }

29
src/providers/NostrProvider/index.tsx

@ -514,11 +514,30 @@ export function NostrProvider({ children }: { children: React.ReactNode }) {
} }
const event = await signEvent(draftEvent) const event = await signEvent(draftEvent)
const relays = specifiedRelayUrls?.length
? specifiedRelayUrls if (event.pubkey !== account.pubkey) {
: (relayList?.write.slice(0, 10) ?? []) const eventAuthor = await client.fetchProfile(event.pubkey)
.concat(Array.from(new Set(additionalRelayUrls)) ?? []) const result = confirm(
.concat(client.getCurrentRelayUrls()) t(
'You are about to publish an event signed by [{{eventAuthorName}}]. You are currently logged in as [{{currentUsername}}]. Are you sure?',
{ eventAuthorName: eventAuthor?.username, currentUsername: profile?.username }
)
)
if (!result) {
throw new Error(t('Cancelled'))
}
}
let relays: string[]
if (specifiedRelayUrls?.length) {
relays = specifiedRelayUrls
} else {
const relayList = await client.fetchRelayList(event.pubkey)
relays = (relayList?.write.slice(0, 10) ?? [])
.concat(Array.from(new Set(additionalRelayUrls)) ?? [])
.concat(client.getCurrentRelayUrls())
}
if (!relays.length) { if (!relays.length) {
relays.push(...BIG_RELAY_URLS) relays.push(...BIG_RELAY_URLS)
} }

Loading…
Cancel
Save