SPB Git

Repository Public

nav.ts 3.3 KB 63 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : SP Mail8 * File             : web/src/next/nav.ts9 * Module           : next10 * Repository       : https://git.spboucher.ai/sp-mail11 * Project Website  : https://mail.spboucher.ai12 * Created          : 2026-11-2013 * Last Modified    : 2026-11-2014 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: support@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243// SP Mail Next — adresses internes communes aux modules : ouvrir une conversation d'une boîte donnée, lancer une recherche, un écran « Next ».44import { S, routeHref, type NextPage } from "../state/app"4546export const mailboxIndex = (mailboxId: string): number => Math.max(0, S.get().me?.mailboxes.findIndex((m) => m.id === mailboxId) ?? 0)47export const mailboxAddress = (mailboxId: string): string => S.get().me?.mailboxes.find((m) => m.id === mailboxId)?.address ?? ""4849/** Conversation d'une boîte, ouverte dans la vue donnée (rôle de dossier, `f:<id>` ou vue virtuelle ; boîte de réception par défaut). */50export function messageHref(mailboxId: string, threadId: string, view = "inbox"): string {51  return routeHref({ name: "mail", mbIndex: mailboxIndex(mailboxId), view, threadId, q: "" })52}53/** Recherche (syntaxe du serveur, docs/next/SEARCH.md) dans la boîte donnée (à défaut la boîte courante) ou dans toutes (`all`). */54export function searchHref(q: string, opts: { all?: boolean; mailboxId?: string } = {}): string {55  if (opts.all) return routeHref({ name: "mail", all: true, mbIndex: 0, view: "search", threadId: null, q })56  const s = S.get()57  const mbIndex = opts.mailboxId ? mailboxIndex(opts.mailboxId) : s.route.name === "mail" && !s.route.all ? s.route.mbIndex : mailboxIndex(s.mb ?? "")58  return routeHref({ name: "mail", mbIndex, view: "search", threadId: null, q })59}60/** Valeur d'un opérateur, entre guillemets si elle contient une espace : `label:"À suivre"`. */61export const operator = (key: string, value: string): string => `${key}:${/\s/.test(value) ? `"${value.replace(/"/g, "")}"` : value}`62export const nextHref = (page: NextPage, id: string | null = null, q = ""): string => routeHref({ name: "next", page, id, q })63
Files main
Menu

Theme