Skip to content

Commit

Permalink
fix: typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanjoshi914 committed Dec 24, 2024
1 parent 14060de commit f5aa8be
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/common/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function mergeTransactions(
payments: ConnectorTransaction[]
): ConnectorTransaction[] {
const mergedTransactions = [...invoices, ...payments].sort((a, b) => {
return (b.settleDate ?? Date.now()) - (a.settleDate ?? Date.now());
return (b.settleDate ?? 0) - (a.settleDate ?? 0);
});

return mergedTransactions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface ConnectorTransaction {
/**
* Settle date in UNIX milliseconds
*/
settleDate?: number;
settleDate: number | null;
creationDate?: number;
totalAmount: number;
displayAmount?: [number, ACCOUNT_CURRENCIES];
Expand Down
2 changes: 1 addition & 1 deletion src/extension/background-script/connectors/lawallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default class LaWallet implements Connector {
return {
data: {
transactions: parsedTransactions.sort(
(a, b) => (b.settleDate ?? Date.now()) - (a.settleDate ?? Date.now())
(a, b) => (b.settleDate ?? 0) - (a.settleDate ?? 0)
),
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/extension/background-script/connectors/lndhub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default class LndHub implements Connector {
})
)
.sort((a, b) => {
return (b.settleDate ?? Date.now()) - (a.settleDate ?? Date.now());
return (b.settleDate ?? 0) - (a.settleDate ?? 0);
});

return invoices;
Expand Down
4 changes: 1 addition & 3 deletions src/extension/background-script/connectors/nwc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ class NWCConnector implements Connector {
preimage: transaction.preimage,
payment_hash: transaction.payment_hash,
settled: transaction.state == "settled",
...(transaction.state == "settled" && transaction.settled_at
? { settleDate: transaction.settled_at * 1000 }
: {}),
settleDate: transaction.settled_at * 1000,
creationDate: transaction.created_at * 1000,
totalAmount: Math.floor(transaction.amount / 1000),
type: transaction.type == "incoming" ? "received" : "sent",
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ export interface Invoice {
memo?: string;
type: "received" | "sent";
settled: boolean;
settleDate?: number;
settleDate: number | null;
creationDate?: number;
totalAmount: number;
totalAmountFiat?: string;
Expand Down

0 comments on commit f5aa8be

Please sign in to comment.