Add owner inbox UI with address release
Web: "My listings" (listings, requests of a listing, conversation) in three panes on wide screens and one at a time on phones, and a sheet or dialog to release the exact address. Sign-in uses a link printed by `node run` (token in the URL fragment, kept in sessionStorage only). API: GET /api/v1/mine (own listings with request counts and whether an address is saved); inbox rows gain last_dir, needs_reply, preview, effort and grant_until, and can be filtered by listing. Docs: PROTOCOL.md and README describe the owner UI and login. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
+23
-2
@@ -4,6 +4,8 @@ import { date, price, rooms, shortKey } from "./format.ts";
|
||||
import { decodeGeohash } from "./geohash.ts";
|
||||
import { lang, t, type Key } from "./i18n.ts";
|
||||
import { contactPanel, showConversation, showInbox } from "./chat.ts";
|
||||
import { showOwner } from "./owner.ts";
|
||||
import { getToken, setToken } from "./ownerApi.ts";
|
||||
import { state, verifyOpts } from "./state.ts";
|
||||
import { verifyListing, type Listing, type Verdict } from "./verify.ts";
|
||||
|
||||
@@ -324,6 +326,16 @@ async function showDetail(author: string, id: string): Promise<void> {
|
||||
|
||||
// --- boot -----------------------------------------------------------------
|
||||
|
||||
/** "My messages" is for buyers; "My listings" only appears once the owner has signed in. */
|
||||
function renderNav(): void {
|
||||
const nav = document.getElementById("nav")!;
|
||||
clear(nav);
|
||||
append(nav, [
|
||||
h("a", { href: "#/messages" }, t("nav.messages")),
|
||||
getToken() && h("a", { href: "#/mine" }, t("nav.owner")),
|
||||
]);
|
||||
}
|
||||
|
||||
function route(): void {
|
||||
state.generation++;
|
||||
const hash = location.hash.replace(/^#/, "") || "/";
|
||||
@@ -332,17 +344,26 @@ function route(): void {
|
||||
const params = new URLSearchParams(q < 0 ? "" : hash.slice(q + 1));
|
||||
const m = /^\/l\/([0-9a-f]{64})\/([0-9a-f]{32})$/.exec(path);
|
||||
const c = /^\/c\/([0-9a-f]{64})\/([0-9a-f]{32})\/([0-9a-f]{64})$/.exec(path);
|
||||
if (m) void showDetail(m[1]!, m[2]!);
|
||||
const login = /^\/login\/([0-9a-f]{16,128})$/.exec(path);
|
||||
const own = /^\/mine(?:\/([0-9a-f]{32})(?:\/([0-9a-f]{64}))?)?$/.exec(path);
|
||||
document.body.classList.remove("wide");
|
||||
if (login) {
|
||||
// The token came in the URL fragment: keep it for this tab and take it out of the address bar.
|
||||
setToken(login[1]!);
|
||||
history.replaceState(null, "", location.pathname + location.search + "#/mine");
|
||||
void showOwner();
|
||||
} else if (m) void showDetail(m[1]!, m[2]!);
|
||||
else if (c) void showConversation(c[1]!, c[2]!, c[3]!);
|
||||
else if (path === "/messages") showInbox();
|
||||
else if (own) void showOwner(own[1], own[2]);
|
||||
else showSearch(params);
|
||||
renderNav();
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
|
||||
async function boot(): Promise<void> {
|
||||
document.documentElement.lang = lang;
|
||||
document.getElementById("foot")!.textContent = t("footer.text");
|
||||
document.getElementById("nav")!.append(h("a", { href: "#/messages" }, t("nav.messages")));
|
||||
try {
|
||||
state.node = await getStatus();
|
||||
statusEl.textContent = t("status.line", {
|
||||
|
||||
Reference in New Issue
Block a user