Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6032f542ee | ||
|
|
21d5e42528 |
@@ -45,6 +45,11 @@ function renderTop10() {
|
||||
el.querySelectorAll(".settings-addtoken-quick:not([disabled])").forEach(
|
||||
(btn) => {
|
||||
btn.addEventListener("click", async () => {
|
||||
// The button stays enabled until the first click's save ends.
|
||||
if (isTracked(btn.dataset.address)) {
|
||||
showFlash("Already tracked.");
|
||||
return;
|
||||
}
|
||||
const token = {
|
||||
address: btn.dataset.address,
|
||||
symbol: btn.dataset.symbol,
|
||||
|
||||
@@ -76,13 +76,18 @@ function toAddressHtml(address, chainId) {
|
||||
// The amount of each `Moved from the sender` line of a decoded swap, for the
|
||||
// wait and error screens to show under the Amount figure. That figure can leave
|
||||
// these amounts out, so alone it can read as less than can have left the
|
||||
// wallet. `decoded` can come back from storage in any shape, and a shape the
|
||||
// decoder does not write shows no line here.
|
||||
// wallet. `decoded` can come back from storage in any shape, so this shows only
|
||||
// the lines whose value is text.
|
||||
function movedFromSenderHtml(decoded) {
|
||||
if (!decoded || !Array.isArray(decoded.details)) return "";
|
||||
let html = "";
|
||||
for (const d of decoded.details) {
|
||||
if (!d || d.label !== "Moved from the sender") continue;
|
||||
if (
|
||||
!d ||
|
||||
d.label !== "Moved from the sender" ||
|
||||
typeof d.value !== "string"
|
||||
)
|
||||
continue;
|
||||
html += `<div class="mt-2">`;
|
||||
html += `<div class="text-xs text-muted mb-1">${escapeHtml(d.label)}</div>`;
|
||||
html += `<div class="font-bold">${escapeHtml(d.value)}</div>`;
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
// (https://git.eeqj.de/sneak/AutistMask/issues/603). An answer while AddToken
|
||||
// still shows goes to AddressDetail. On either add-token screen, an answer for a
|
||||
// token tracked while the lookup waited tracks nothing
|
||||
// (https://git.eeqj.de/sneak/AutistMask/issues/727). Driven through the real
|
||||
// (https://git.eeqj.de/sneak/AutistMask/issues/727). A second click on a "Top
|
||||
// tokens:" button tracks nothing
|
||||
// (https://git.eeqj.de/sneak/AutistMask/issues/729). Driven through the real
|
||||
// popup over a stored profile.
|
||||
|
||||
const {
|
||||
@@ -197,6 +199,8 @@ describe.each([
|
||||
await answerSecondClick();
|
||||
expect(boot.text("flash-msg")).toBe(alreadyTrackedFlash);
|
||||
expect(boot.storage.read("autistmask").trackedTokens).toEqual([TOKEN]);
|
||||
const { state } = require("../src/shared/state");
|
||||
expect(state.trackedTokens).toEqual([TOKEN]);
|
||||
});
|
||||
|
||||
test("an answer for a token tracked while the lookup waited clears the status line", async () => {
|
||||
@@ -213,3 +217,44 @@ describe.each([
|
||||
expect(state.trackedTokens).toEqual([TOKEN]);
|
||||
});
|
||||
});
|
||||
|
||||
test('a double click on a "Top tokens:" button tracks the token once', async () => {
|
||||
const boot = await bootPopup(
|
||||
unversionedValidProfile({
|
||||
currentView: "address",
|
||||
selectedWallet: 0,
|
||||
selectedAddress: 0,
|
||||
}),
|
||||
);
|
||||
expect(boot.pageErrors).toEqual([]);
|
||||
// The page stub does not turn the markup the screen draws into elements.
|
||||
// So the list hands the screen a stand-in for TOKEN's button.
|
||||
let press;
|
||||
boot.node("settings-addtoken-top10").querySelectorAll = () => [
|
||||
{
|
||||
dataset: {
|
||||
address: TOKEN.address,
|
||||
symbol: TOKEN.symbol,
|
||||
decimals: String(TOKEN.decimals),
|
||||
name: TOKEN.name,
|
||||
},
|
||||
addEventListener: (name, fn) => {
|
||||
press = fn;
|
||||
},
|
||||
},
|
||||
];
|
||||
await boot.click("btn-settings");
|
||||
await boot.click("btn-settings-add-token");
|
||||
|
||||
const firstClick = press();
|
||||
const secondClick = press();
|
||||
const { state } = require("../src/shared/state");
|
||||
expect(state.trackedTokens).toEqual([TOKEN]);
|
||||
// Read before the first click's save ends, when "Added TST" replaces it.
|
||||
expect(boot.text("flash-msg")).toBe("Already tracked.");
|
||||
|
||||
await Promise.all([firstClick, secondClick]);
|
||||
await boot.settle();
|
||||
expect(state.trackedTokens).toEqual([TOKEN]);
|
||||
expect(boot.storage.read("autistmask").trackedTokens).toEqual([TOKEN]);
|
||||
});
|
||||
|
||||
@@ -735,7 +735,15 @@ describe("the Moved from the sender lines of a swap on WaitTx and ErrorTx", () =
|
||||
return waitNote;
|
||||
}
|
||||
|
||||
for (const saved of [7, "text", { details: 7 }, { details: [null] }]) {
|
||||
for (const saved of [
|
||||
7,
|
||||
"text",
|
||||
{ details: 7 },
|
||||
{ details: [null] },
|
||||
{ details: [{ label: "Moved from the sender" }] },
|
||||
{ details: [moved(7)] },
|
||||
{ details: [moved({ toString: 1 })] },
|
||||
]) {
|
||||
expect(noteOnReopen(saved)).toBe("");
|
||||
}
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user