Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update most links to dashboard to open in quick-settings instead. #500

Draft
wants to merge 3 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/components/popup/WalletHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,9 @@ export default function WalletHeader() {
{
icon: <Users01 style={{ width: "18px", height: "18px" }} />,
title: "setting_contacts",
route: () =>
browser.tabs.create({
url: browser.runtime.getURL("tabs/dashboard.html#/contacts")
})
route: () => {
push("/quick-settings/contacts");
}
},
{
icon: <Container style={{ width: "18px", height: "17px" }} />,
Expand Down
16 changes: 9 additions & 7 deletions src/components/popup/WalletSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Arweave from "arweave";
import { svgie } from "~utils/svgies";
import { Action } from "./WalletHeader";
import copy from "copy-to-clipboard";
import { useHistory } from "~utils/hash_router";

export default function WalletSwitcher({
open,
Expand Down Expand Up @@ -165,6 +166,8 @@ export default function WalletSwitcher({
// toasts
const { setToast } = useToasts();

const [push] = useHistory();

return (
<AnimatePresence>
{open && (
Expand Down Expand Up @@ -239,6 +242,7 @@ export default function WalletSwitcher({
</Wallet>
))}
</Wallets>

{showOptions && (
<ActionBar>
<AddWalletButton
Expand All @@ -258,13 +262,11 @@ export default function WalletSwitcher({
position="topEnd"
>
<EditButton
onClick={() =>
browser.tabs.create({
url: browser.runtime.getURL(
`tabs/dashboard.html#/wallets/${activeAddress}`
)
})
}
onClick={(e) => {
e.preventDefault();

push(`/quick-settings/wallets/${activeAddress}`);
}}
/>
</TooltipV2>
</ActionBar>
Expand Down
29 changes: 29 additions & 0 deletions src/injected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,35 @@ for (const mod of modules) {
// @ts-expect-error
window.arweaveWallet = WalletAPI;

/*
if (process.env.NODE_ENV === "development") {
// @ts-expect-error
window.arweaveWalletDev = WalletAPI;

console.log(`Forcing development wallet (${ WalletAPI.walletName } ${ WalletAPI.walletVersion }) to be injected...`);

const t0 = Date.now();

const intervalID = setInterval(() => {
if (window.arweaveWallet && window.arweaveWallet !== WalletAPI) {
// @ts-expect-error
console.log(`Another wallet (${ window.arweaveWallet.walletName } ${ window.arweaveWallet.walletVersion }) was injected. Overriding...`);

// @ts-expect-error
window.arweaveWallet = WalletAPI;
}

const elapsed = Date.now() - t0;

if (elapsed >= 30000) {
console.log(`Stopped forcing development wallet (${ WalletAPI.walletName } ${ WalletAPI.walletVersion }) to be injected.`);

clearInterval(intervalID);
}
}, 250);
}
*/

// at the end of the injected script,
// we dispatch the wallet loaded event
dispatchEvent(new CustomEvent("arweaveWalletLoaded", { detail: {} }));
Expand Down
20 changes: 14 additions & 6 deletions src/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,24 @@ export default function Popup() {
</Route>
<Route path="/quick-settings/tokens" component={QuickTokens} />
<Route path="/quick-settings/tokens/:id">
{(params: { id: string }) => <TokenSettings id={params?.id} />}
{(params: { id: string }) =>
params?.id === "new" ? (
<NewToken />
) : (
<TokenSettings id={params?.id} />
)
}
</Route>
<Route path="/quick-settings/tokens/new" component={NewToken} />
<Route path="/quick-settings/contacts" component={Contacts} />
<Route path="/quick-settings/contacts/:address">
{(params: { address: string }) => (
<ContactSettings address={params?.address} />
)}
{(params: { address: string }) =>
params?.address === "new" ? (
<NewContact />
) : (
<ContactSettings address={params?.address} />
)
}
</Route>
<Route path="/quick-settings/contacts/new" component={NewContact} />
<Route
path="/quick-settings/notifications"
component={NotificationSettings}
Expand Down
19 changes: 13 additions & 6 deletions src/routes/popup/tokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import { useStorage } from "@plasmohq/storage/hook";

export default function Tokens() {
const [isLoading, setIsLoading] = useState(false);
const [hasNextPage, setHasNextPage] = useState(true);
const [hasNextPage, setHasNextPage] = useState<boolean | undefined>(
undefined
);
// all tokens
const tokens = useTokens();
// ao Tokens
Expand Down Expand Up @@ -166,9 +168,7 @@ export default function Tokens() {
onClick={() => push(`/token/${token.id}`)}
onSettingsClick={(e) => {
e.preventDefault();
window.open(
`${browser.runtime.getURL("tabs/dashboard.html")}#/tokens`
);
push(`/quick-settings/tokens/${token.id}`);
}}
key={i}
/>
Expand All @@ -192,9 +192,10 @@ export default function Tokens() {
}}
/>
))}

{aoSupport && hasNextPage && (
<ButtonV2
disabled={!hasNextPage || isLoading}
disabled={isLoading}
style={{ alignSelf: "center", marginTop: "5px" }}
onClick={searchAoTokens}
>
Expand All @@ -207,8 +208,14 @@ export default function Tokens() {
)}
</ButtonV2>
)}

<ManageButton
href={`${browser.runtime.getURL("tabs/dashboard.html")}#/tokens`}
// TODO: The base should be iframe.html for the extension and some domain for the iframe.
href="#/quick-settings/tokens"
onClick={(e) => {
e.preventDefault();
push("/quick-settings/tokens");
}}
>
<EditIcon />
{browser.i18n.getMessage("manage_assets_button")}
Expand Down
28 changes: 15 additions & 13 deletions src/routes/popup/transaction/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default function Transaction({ id: rawId, gw, message }: Props) {
timestamp
}
}
}
}
`,
{ id },
gateway
Expand Down Expand Up @@ -381,15 +381,16 @@ export default function Transaction({ id: rawId, gw, message }: Props) {
<AddContact>
{browser.i18n.getMessage("user_not_in_contacts")}{" "}
<span
onClick={() => {
onClick={(e) => {
e.preventDefault();

trackEvent(EventType.ADD_CONTACT, {
fromSendFlow: true
});
browser.tabs.create({
url: browser.runtime.getURL(
`tabs/dashboard.html#/contacts/new?address=${fromAddress}`
)
});

push(
`/quick-settings/contacts/new?address=${fromAddress}`
);
}}
>
{browser.i18n.getMessage("create_contact")}
Expand Down Expand Up @@ -432,15 +433,16 @@ export default function Transaction({ id: rawId, gw, message }: Props) {
<AddContact>
{browser.i18n.getMessage("user_not_in_contacts")}{" "}
<span
onClick={() => {
onClick={(e) => {
e.preventDefault();

trackEvent(EventType.ADD_CONTACT, {
fromSendFlow: true
});
browser.tabs.create({
url: browser.runtime.getURL(
`tabs/dashboard.html#/contacts/new?address=${toAddress}`
)
});

push(
`/quick-settings/contacts/new?address=${toAddress}`
);
}}
>
{browser.i18n.getMessage("create_contact")}
Expand Down