Skip to content

Commit

Permalink
feat: add warning to download filenames (#630)
Browse files Browse the repository at this point in the history
* feat: add warning to download filenames

closes #623

* feat: add missing strings

---------

Co-authored-by: Kilian <19181985+kilrau@users.noreply.github.com>
  • Loading branch information
dni and kilrau authored Jul 16, 2024
1 parent b1111a4 commit 5a0d7f2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
13 changes: 5 additions & 8 deletions src/components/DownloadRefund.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ import QRCode from "qrcode/lib/server";

import { useGlobalContext } from "../context/Global";
import { usePayContext } from "../context/Pay";
import { download, downloadJson } from "../utils/download";
import { download, downloadJson, getRefundFileName } from "../utils/download";
import { isIos, isMobile } from "../utils/helper";

const getRefundFileName = (swap: any): string => {
return `boltz-refund-${swap.id}`;
};

const downloadRefundJson = (swap: any) => {
downloadJson(getRefundFileName(swap), swap);
downloadJson(getRefundFileName(swap.id), swap);
};

const DownloadRefund = () => {
Expand All @@ -27,11 +23,12 @@ const DownloadRefund = () => {
newTab.document.body.innerHTML = `
<!DOCTYPE html>
<body>
<h1>${t("ios_image_download_do_not_share")}</h1>
<h2>${t("ios_image_download")}</h2>
<img src="${url}">
<h1>${t("ios_image_download")}</h1>
</body>`;
} else {
download(`${getRefundFileName(swap)}.png`, url);
download(`${getRefundFileName(swap.id)}.png`, url);
}
})
.catch((err: Error) => {
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ const dict = {
refund_explainer: "You will be able to refund after the timeout",
swap_not_refundable_yet: "Your swap is not refundable yet",
wasm_not_supported: "Please activate WebAssembly in your browser",
ios_image_download_do_not_share: "CONFIDENTIAL! DO NOT SHARE!",
ios_image_download:
'Long press and select "Save to Photos" to download refund file',
created: "Created",
Expand Down Expand Up @@ -344,6 +345,7 @@ const dict = {
"Dein Swap kann noch nicht erstattet werden. Warte auf den Timeout, um eine Rückerstattung zu starten.",
wasm_not_supported:
"Bitte aktivieren Sie WebAssembly in Ihrem Browser!",
ios_image_download_do_not_share: "VERTRAULICH! NICHT TEILEN!",
ios_image_download:
'Lange drücken und "In Fotos speichern" auswählen, um die Rückerstattungsdatei herunterzuladen',
created: "Erstellt",
Expand Down Expand Up @@ -555,6 +557,7 @@ const dict = {
swap_not_refundable_yet:
"Tu intercambio aún no es reembolsable, por favor inténtelo de nuevo más tarde!",
wasm_not_supported: "Por favor, activa WebAssembly en tu navegador!",
ios_image_download_do_not_share: "¡CONFIDENCIAL! ¡NO COMPARTIR!",
ios_image_download:
'Mantén presionado y selecciona "Guardar en Fotos" para descargar el archivo de reembolso.',
created: "Creado",
Expand Down Expand Up @@ -751,6 +754,7 @@ const dict = {
refund_explainer: "您将能够在超时后退款",
swap_not_refundable_yet: "您的交换尚不可退还",
wasm_not_supported: "请在您的浏览器中激活WebAssembly",
ios_image_download_do_not_share: "机密!切勿共享!",
ios_image_download: "长按并选择“保存到照片”以下载退款文件",
created: "已创建",
view: "查看",
Expand Down
4 changes: 2 additions & 2 deletions src/pages/History.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SwapList from "../components/SwapList";
import SettingsCog from "../components/settings/SettingsCog";
import SettingsMenu from "../components/settings/SettingsMenu";
import { useGlobalContext } from "../context/Global";
import { downloadJson } from "../utils/download";
import { downloadJson, getBackupFileName } from "../utils/download";
import { isIos } from "../utils/helper";
import { latestStorageVersion, migrateBackupFile } from "../utils/migration";
import { SomeSwap } from "../utils/swapCreator";
Expand Down Expand Up @@ -63,7 +63,7 @@ const History = () => {
};

const backupLocalStorage = async () => {
downloadJson(`boltz-backup-${Math.floor(Date.now() / 1000)}`, {
downloadJson(getBackupFileName(), {
version: latestStorageVersion,
swaps: await getSwaps(),
});
Expand Down
8 changes: 8 additions & 0 deletions src/utils/download.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
export const getBackupFileName = (): string => {
return `boltz-backup-${Math.floor(Date.now() / 1000)}-SECRET_DO_NOT_SHARE`;
};

export const getRefundFileName = (swapId: string): string => {
return `boltz-refund-${swapId}-SECRET_DO_NOT_SHARE`;
};

export const download = (file: string, content: string) => {
const hidden = document.createElement("a");
hidden.download = file;
Expand Down

0 comments on commit 5a0d7f2

Please sign in to comment.