-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'getAlby:master' into lawallet-extension
- Loading branch information
Showing
45 changed files
with
312 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
type Props = { | ||
heading: string; | ||
heading: string | React.ReactNode; | ||
content: string; | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import { CheckIcon } from "@bitcoin-design/bitcoin-icons-react/filled"; | ||
import ConfirmOrCancel from "@components/ConfirmOrCancel"; | ||
import Container from "@components/Container"; | ||
import PublisherCard from "@components/PublisherCard"; | ||
import { useState } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import ScreenHeader from "~/app/components/ScreenHeader"; | ||
import Checkbox from "~/app/components/form/Checkbox"; | ||
import { useNavigationState } from "~/app/hooks/useNavigationState"; | ||
import { USER_REJECTED_ERROR } from "~/common/constants"; | ||
import msg from "~/common/lib/msg"; | ||
import { OriginData } from "~/types"; | ||
|
||
function NostrConfirmDecrypt() { | ||
const { t } = useTranslation("translation", { | ||
keyPrefix: "nostr", | ||
}); | ||
const { t: tPermissions } = useTranslation("permissions"); | ||
const { t: tCommon } = useTranslation("common"); | ||
const navState = useNavigationState(); | ||
const origin = navState.origin as OriginData; | ||
|
||
const [loading, setLoading] = useState(false); | ||
|
||
const [rememberPermission, setRememberPermission] = useState(true); | ||
|
||
function confirm() { | ||
setLoading(true); | ||
msg.reply({ | ||
confirm: true, | ||
rememberPermission, | ||
}); | ||
setLoading(false); | ||
} | ||
|
||
function reject(event: React.MouseEvent<HTMLAnchorElement>) { | ||
event.preventDefault(); | ||
msg.error(USER_REJECTED_ERROR); | ||
} | ||
|
||
async function block(event: React.MouseEvent<HTMLAnchorElement>) { | ||
event.preventDefault(); | ||
await msg.request("addBlocklist", { | ||
domain: origin.domain, | ||
host: origin.host, | ||
}); | ||
alert(`Added ${origin.host} to the blocklist, please reload the website`); | ||
msg.error(USER_REJECTED_ERROR); | ||
} | ||
|
||
function handleSubmit(event: React.FormEvent<HTMLFormElement>) { | ||
event.preventDefault(); | ||
confirm(); | ||
} | ||
|
||
return ( | ||
<div className="h-full flex flex-col overflow-y-auto no-scrollbar"> | ||
<ScreenHeader title={t("title")} /> | ||
<form onSubmit={handleSubmit} className="h-full"> | ||
<Container justifyBetween maxWidth="sm"> | ||
<PublisherCard | ||
title={origin.name} | ||
image={origin.icon} | ||
url={origin.host} | ||
isSmall={false} | ||
/> | ||
<div className="dark:text-white pt-6 mb-4"> | ||
<p className="mb-2">{t("allow", { host: origin.host })}</p> | ||
<p className="dark:text-white"> | ||
<CheckIcon className="w-5 h-5 mr-2 inline" /> | ||
{tPermissions("nostr.nip04decrypt")} | ||
</p> | ||
</div> | ||
|
||
<div className="text-center flex flex-col"> | ||
<div className="flex items-center mb-4"> | ||
<Checkbox | ||
id="remember_permission" | ||
name="remember_permission" | ||
checked={rememberPermission} | ||
onChange={(event) => { | ||
setRememberPermission(event.target.checked); | ||
}} | ||
/> | ||
<label | ||
htmlFor="remember_permission" | ||
className="cursor-pointer ml-2 block text-sm text-gray-900 font-medium dark:text-white" | ||
> | ||
{tCommon("actions.remember")} | ||
</label> | ||
</div> | ||
<ConfirmOrCancel | ||
disabled={loading} | ||
loading={loading} | ||
label={tCommon("actions.confirm")} | ||
onCancel={reject} | ||
/> | ||
<a | ||
className="mt-4 underline text-sm text-gray-400 overflow-hidden text-ellipsis whitespace-nowrap" | ||
href="#" | ||
onClick={block} | ||
> | ||
{t("block_and_ignore", { host: origin.host })} | ||
</a> | ||
</div> | ||
</Container> | ||
</form> | ||
</div> | ||
); | ||
} | ||
|
||
export default NostrConfirmDecrypt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.