Skip to content

Commit 1a9a2fd

Browse files
authored
fix: fix broken logout in secret bid auction example (#107)
Fixes the logout in the secret bid auction example, which is broken. In particular, after a logout and re-login, calls to the backend are still made with the old identity. At the same time, the PR also improves the example name on the main page adds a code snipped that makes npm run dev work (which didn't work before) reverses the order of the open and closes lots as they are displayed in the frontend, so that the most recent lots are on top
1 parent 4e4d1d8 commit 1a9a2fd

File tree

1 file changed

+9
-3
lines changed
  • examples/basic_timelock_ibe/frontend/src

1 file changed

+9
-3
lines changed

examples/basic_timelock_ibe/frontend/src/main.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Required to run `npm run dev`.
2+
if (!window.global) {
3+
window.global = window;
4+
}
5+
16
import "./style.css";
27
import { createActor } from "../../src/declarations/basic_timelock_ibe";
38
import { Principal } from "@dfinity/principal";
@@ -76,6 +81,7 @@ export function login(client: AuthClient) {
7681
export function logout() {
7782
void authClient?.logout();
7883
myPrincipal = undefined;
84+
basicTimelockIbeCanister = undefined;
7985
updateUI(false);
8086

8187
// Reset the lots list and form visibility
@@ -126,7 +132,7 @@ function handleLogin() {
126132

127133
document.querySelector<HTMLDivElement>("#app")!.innerHTML = `
128134
<div>
129-
<h1>Basic Timelock IBE Secret Bid Auction using VetKeys</h1>
135+
<h1>Secret Bid Auction using VetKeys (Basic Timelock IBE)</h1>
130136
<div class="principal-container">
131137
<div id="principalDisplay" class="principal-display"></div>
132138
<button id="logoutButton" style="display: none;">Logout</button>
@@ -300,7 +306,7 @@ async function listLots() {
300306
heading.textContent = "Open Lots";
301307
fragment.appendChild(heading);
302308

303-
openLots.lots.forEach((lot, index) => {
309+
openLots.lots.reverse().forEach((lot, index) => {
304310
const lotDiv = document.createElement("div");
305311
lotDiv.className = "lot";
306312
const isCreator =
@@ -365,7 +371,7 @@ async function listLots() {
365371
heading.textContent = "Closed Lots";
366372
fragment.appendChild(heading);
367373

368-
closedLots.lots.forEach((lot, index) => {
374+
closedLots.lots.reverse().forEach((lot, index) => {
369375
const lotDiv = document.createElement("div");
370376
lotDiv.className = "lot";
371377
const isWinner =

0 commit comments

Comments
 (0)