Format with prettier. Use screen mode for invitation import - dialog mode is broken.
This commit is contained in:
@@ -1,8 +1,22 @@
|
||||
import type { HistoryItem, HistoryInvitationItem, HistoryUtxoItem } from '../services/history.js';
|
||||
import type {
|
||||
HistoryItem,
|
||||
HistoryInvitationItem,
|
||||
HistoryUtxoItem,
|
||||
} from "../services/history.js";
|
||||
|
||||
export type HistoryColorName = 'info' | 'warning' | 'success' | 'error' | 'muted' | 'text';
|
||||
export type HistoryColorName =
|
||||
| "info"
|
||||
| "warning"
|
||||
| "success"
|
||||
| "error"
|
||||
| "muted"
|
||||
| "text";
|
||||
|
||||
export type HistoryRowType = 'invitation' | 'invitation_input' | 'invitation_output' | 'utxo';
|
||||
export type HistoryRowType =
|
||||
| "invitation"
|
||||
| "invitation_input"
|
||||
| "invitation_output"
|
||||
| "utxo";
|
||||
|
||||
export interface HistoryDisplayRow {
|
||||
id: string;
|
||||
@@ -20,14 +34,16 @@ export function formatHistoryDate(timestamp?: number): string | undefined {
|
||||
return new Date(timestamp).toLocaleDateString();
|
||||
}
|
||||
|
||||
export function buildHistoryDisplayRows(items: HistoryItem[]): HistoryDisplayRow[] {
|
||||
export function buildHistoryDisplayRows(
|
||||
items: HistoryItem[],
|
||||
): HistoryDisplayRow[] {
|
||||
const rows: HistoryDisplayRow[] = [];
|
||||
|
||||
for (const item of items) {
|
||||
if (item.kind === 'invitation') {
|
||||
if (item.kind === "invitation") {
|
||||
rows.push({
|
||||
id: item.id,
|
||||
type: 'invitation',
|
||||
type: "invitation",
|
||||
label: item.description,
|
||||
timestamp: item.createdAtTimestamp,
|
||||
isNested: false,
|
||||
@@ -35,10 +51,13 @@ export function buildHistoryDisplayRows(items: HistoryItem[]): HistoryDisplayRow
|
||||
});
|
||||
|
||||
for (const input of item.inputs) {
|
||||
const satsPrefix = input.valueSatoshis !== undefined ? `${input.valueSatoshis.toLocaleString()} sats ` : '';
|
||||
const satsPrefix =
|
||||
input.valueSatoshis !== undefined
|
||||
? `${input.valueSatoshis.toLocaleString()} sats `
|
||||
: "";
|
||||
rows.push({
|
||||
id: `${item.id}-input-${input.id}`,
|
||||
type: 'invitation_input',
|
||||
type: "invitation_input",
|
||||
label: `${satsPrefix}${input.outpoint.txid}:${input.outpoint.index}`,
|
||||
description: input.description,
|
||||
isNested: true,
|
||||
@@ -50,8 +69,11 @@ export function buildHistoryDisplayRows(items: HistoryItem[]): HistoryDisplayRow
|
||||
for (const output of item.outputs) {
|
||||
rows.push({
|
||||
id: `${item.id}-output-${output.id}`,
|
||||
type: 'invitation_output',
|
||||
label: output.valueSatoshis !== undefined ? `${output.valueSatoshis.toLocaleString()} sats` : 'Output',
|
||||
type: "invitation_output",
|
||||
label:
|
||||
output.valueSatoshis !== undefined
|
||||
? `${output.valueSatoshis.toLocaleString()} sats`
|
||||
: "Output",
|
||||
description: output.description,
|
||||
isNested: true,
|
||||
utxo: output,
|
||||
@@ -64,8 +86,11 @@ export function buildHistoryDisplayRows(items: HistoryItem[]): HistoryDisplayRow
|
||||
|
||||
rows.push({
|
||||
id: item.id,
|
||||
type: 'utxo',
|
||||
label: item.valueSatoshis !== undefined ? `${item.valueSatoshis.toLocaleString()} sats` : 'UTXO',
|
||||
type: "utxo",
|
||||
label:
|
||||
item.valueSatoshis !== undefined
|
||||
? `${item.valueSatoshis.toLocaleString()} sats`
|
||||
: "UTXO",
|
||||
description: item.description,
|
||||
isNested: false,
|
||||
utxo: item,
|
||||
@@ -75,18 +100,21 @@ export function buildHistoryDisplayRows(items: HistoryItem[]): HistoryDisplayRow
|
||||
return rows;
|
||||
}
|
||||
|
||||
export function getHistoryItemColorName(row: HistoryDisplayRow, isSelected: boolean = false): HistoryColorName {
|
||||
if (isSelected) return 'info';
|
||||
export function getHistoryItemColorName(
|
||||
row: HistoryDisplayRow,
|
||||
isSelected: boolean = false,
|
||||
): HistoryColorName {
|
||||
if (isSelected) return "info";
|
||||
switch (row.type) {
|
||||
case 'invitation':
|
||||
return 'text';
|
||||
case 'invitation_input':
|
||||
return 'error';
|
||||
case 'invitation_output':
|
||||
return 'success';
|
||||
case 'utxo':
|
||||
return row.utxo?.reserved ? 'warning' : 'success';
|
||||
case "invitation":
|
||||
return "text";
|
||||
case "invitation_input":
|
||||
return "error";
|
||||
case "invitation_output":
|
||||
return "success";
|
||||
case "utxo":
|
||||
return row.utxo?.reserved ? "warning" : "success";
|
||||
default:
|
||||
return 'text';
|
||||
return "text";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user