summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/wallet
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-03-18 15:32:41 +0100
committerFlorian Dold <florian@dold.me>2022-03-21 19:20:48 +0100
commitf8d12f7b0d4af1b1769b89e80c87f9c169678564 (patch)
tree2478696c7bc1efc6d090b93aa340de542a7dccd9 /packages/taler-wallet-webextension/src/wallet
parent32cd54e11d80bde0274b3c0238f8f5bd00ff83cb (diff)
downloadwallet-core-f8d12f7b0d4af1b1769b89e80c87f9c169678564.tar.gz
wallet-core-f8d12f7b0d4af1b1769b89e80c87f9c169678564.tar.bz2
wallet-core-f8d12f7b0d4af1b1769b89e80c87f9c169678564.zip
wallet: t_s/d_us migration
Diffstat (limited to 'packages/taler-wallet-webextension/src/wallet')
-rw-r--r--packages/taler-wallet-webextension/src/wallet/Backup.stories.tsx16
-rw-r--r--packages/taler-wallet-webextension/src/wallet/BackupPage.tsx18
-rw-r--r--packages/taler-wallet-webextension/src/wallet/History.stories.tsx7
-rw-r--r--packages/taler-wallet-webextension/src/wallet/History.tsx2
-rw-r--r--packages/taler-wallet-webextension/src/wallet/ProviderDetail.stories.tsx26
-rw-r--r--packages/taler-wallet-webextension/src/wallet/ProviderDetailPage.tsx5
-rw-r--r--packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx13
-rw-r--r--packages/taler-wallet-webextension/src/wallet/Transaction.tsx20
8 files changed, 55 insertions, 52 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/Backup.stories.tsx b/packages/taler-wallet-webextension/src/wallet/Backup.stories.tsx
index b2771bc2a..92536db85 100644
--- a/packages/taler-wallet-webextension/src/wallet/Backup.stories.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Backup.stories.tsx
@@ -23,6 +23,7 @@ import { ProviderPaymentType } from "@gnu-taler/taler-wallet-core";
import { addDays } from "date-fns";
import { BackupView as TestedComponent } from "./BackupPage";
import { createExample } from "../test-utils";
+import { TalerProtocolTimestamp } from "@gnu-taler/taler-util";
export default {
title: "wallet/backup/list",
@@ -40,9 +41,8 @@ export const LotOfProviders = createExample(TestedComponent, {
active: true,
name: "sync.demo",
syncProviderBaseUrl: "http://sync.taler:9967/",
- lastSuccessfulBackupTimestamp: {
- t_ms: 1625063925078,
- },
+ lastSuccessfulBackupTimestamp:
+ TalerProtocolTimestamp.fromSeconds(1625063925),
paymentProposalIds: [
"43Q5WWRJPNS4SE9YKS54H9THDS94089EDGXW9EHBPN6E7M184XEG",
],
@@ -62,9 +62,8 @@ export const LotOfProviders = createExample(TestedComponent, {
active: true,
name: "sync.demo",
syncProviderBaseUrl: "http://sync.taler:9967/",
- lastSuccessfulBackupTimestamp: {
- t_ms: 1625063925078,
- },
+ lastSuccessfulBackupTimestamp:
+ TalerProtocolTimestamp.fromSeconds(1625063925),
paymentProposalIds: [
"43Q5WWRJPNS4SE9YKS54H9THDS94089EDGXW9EHBPN6E7M184XEG",
],
@@ -172,9 +171,8 @@ export const OneProvider = createExample(TestedComponent, {
active: true,
name: "sync.demo",
syncProviderBaseUrl: "http://sync.taler:9967/",
- lastSuccessfulBackupTimestamp: {
- t_ms: 1625063925078,
- },
+ lastSuccessfulBackupTimestamp:
+ TalerProtocolTimestamp.fromSeconds(1625063925),
paymentProposalIds: [
"43Q5WWRJPNS4SE9YKS54H9THDS94089EDGXW9EHBPN6E7M184XEG",
],
diff --git a/packages/taler-wallet-webextension/src/wallet/BackupPage.tsx b/packages/taler-wallet-webextension/src/wallet/BackupPage.tsx
index e1d34748b..8c12201b9 100644
--- a/packages/taler-wallet-webextension/src/wallet/BackupPage.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/BackupPage.tsx
@@ -14,7 +14,7 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { Timestamp, Translate } from "@gnu-taler/taler-util";
+import { AbsoluteTime, Translate } from "@gnu-taler/taler-util";
import {
ProviderInfo,
ProviderPaymentPaid,
@@ -104,7 +104,13 @@ export function BackupView({
<BackupLayout
key={idx}
status={provider.paymentStatus}
- timestamp={provider.lastSuccessfulBackupTimestamp}
+ timestamp={
+ provider.lastSuccessfulBackupTimestamp
+ ? AbsoluteTime.fromTimestamp(
+ provider.lastSuccessfulBackupTimestamp,
+ )
+ : undefined
+ }
id={provider.syncProviderBaseUrl}
active={provider.active}
title={provider.name}
@@ -144,7 +150,7 @@ export function BackupView({
interface TransactionLayoutProps {
status: ProviderPaymentStatus;
- timestamp?: Timestamp;
+ timestamp?: AbsoluteTime;
title: string;
id: string;
active: boolean;
@@ -192,7 +198,7 @@ function BackupLayout(props: TransactionLayoutProps): VNode {
);
}
-function ExpirationText({ until }: { until: Timestamp }): VNode {
+function ExpirationText({ until }: { until: AbsoluteTime }): VNode {
const { i18n } = useTranslationContext();
return (
<Fragment>
@@ -207,13 +213,13 @@ function ExpirationText({ until }: { until: Timestamp }): VNode {
);
}
-function colorByTimeToExpire(d: Timestamp): string {
+function colorByTimeToExpire(d: AbsoluteTime): string {
if (d.t_ms === "never") return "rgb(28, 184, 65)";
const months = differenceInMonths(d.t_ms, new Date());
return months > 1 ? "rgb(28, 184, 65)" : "rgb(223, 117, 20)";
}
-function daysUntil(d: Timestamp): string {
+function daysUntil(d: AbsoluteTime): string {
if (d.t_ms === "never") return "";
const duration = intervalToDuration({
start: d.t_ms,
diff --git a/packages/taler-wallet-webextension/src/wallet/History.stories.tsx b/packages/taler-wallet-webextension/src/wallet/History.stories.tsx
index bd52995d9..8138e63dd 100644
--- a/packages/taler-wallet-webextension/src/wallet/History.stories.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/History.stories.tsx
@@ -21,6 +21,7 @@
import {
PaymentStatus,
+ TalerProtocolTimestamp,
TransactionCommon,
TransactionDeposit,
TransactionPayment,
@@ -45,9 +46,9 @@ const commonTransaction = () =>
amountRaw: "USD:10",
amountEffective: "USD:9",
pending: false,
- timestamp: {
- t_ms: new Date().getTime() - count++ * 1000 * 60 * 60 * 7,
- },
+ timestamp: TalerProtocolTimestamp.fromSeconds(
+ new Date().getTime() - count++ * 60 * 60 * 7,
+ ),
transactionId: "12",
} as TransactionCommon);
diff --git a/packages/taler-wallet-webextension/src/wallet/History.tsx b/packages/taler-wallet-webextension/src/wallet/History.tsx
index 02fc0a76c..5d00e2e01 100644
--- a/packages/taler-wallet-webextension/src/wallet/History.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/History.tsx
@@ -126,7 +126,7 @@ export function HistoryView({
.filter((t) => t.amountRaw.split(":")[0] === selectedCurrency)
.reduce((rv, x) => {
const theDate =
- x.timestamp.t_ms === "never" ? 0 : normalizeToDay(x.timestamp.t_ms);
+ x.timestamp.t_s === "never" ? 0 : normalizeToDay(x.timestamp.t_s * 1000);
if (theDate) {
(rv[theDate] = rv[theDate] || []).push(x);
}
diff --git a/packages/taler-wallet-webextension/src/wallet/ProviderDetail.stories.tsx b/packages/taler-wallet-webextension/src/wallet/ProviderDetail.stories.tsx
index a170620a3..c4c070fa8 100644
--- a/packages/taler-wallet-webextension/src/wallet/ProviderDetail.stories.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/ProviderDetail.stories.tsx
@@ -19,6 +19,7 @@
* @author Sebastian Javier Marchano (sebasjm)
*/
+import { TalerProtocolTimestamp } from "@gnu-taler/taler-util";
import { ProviderPaymentType } from "@gnu-taler/taler-wallet-core";
import { createExample } from "../test-utils";
import { ProviderView as TestedComponent } from "./ProviderDetailPage";
@@ -38,9 +39,8 @@ export const Active = createExample(TestedComponent, {
active: true,
name: "sync.demo",
syncProviderBaseUrl: "http://sync.taler:9967/",
- lastSuccessfulBackupTimestamp: {
- t_ms: 1625063925078,
- },
+ lastSuccessfulBackupTimestamp:
+ TalerProtocolTimestamp.fromSeconds(1625063925),
paymentProposalIds: [
"43Q5WWRJPNS4SE9YKS54H9THDS94089EDGXW9EHBPN6E7M184XEG",
],
@@ -63,12 +63,10 @@ export const ActiveErrorSync = createExample(TestedComponent, {
active: true,
name: "sync.demo",
syncProviderBaseUrl: "http://sync.taler:9967/",
- lastSuccessfulBackupTimestamp: {
- t_ms: 1625063925078,
- },
- lastAttemptedBackupTimestamp: {
- t_ms: 1625063925078,
- },
+ lastSuccessfulBackupTimestamp:
+ TalerProtocolTimestamp.fromSeconds(1625063925),
+ lastAttemptedBackupTimestamp:
+ TalerProtocolTimestamp.fromSeconds(1625063925078),
paymentProposalIds: [
"43Q5WWRJPNS4SE9YKS54H9THDS94089EDGXW9EHBPN6E7M184XEG",
],
@@ -97,9 +95,8 @@ export const ActiveBackupProblemUnreadable = createExample(TestedComponent, {
active: true,
name: "sync.demo",
syncProviderBaseUrl: "http://sync.taler:9967/",
- lastSuccessfulBackupTimestamp: {
- t_ms: 1625063925078,
- },
+ lastSuccessfulBackupTimestamp:
+ TalerProtocolTimestamp.fromSeconds(1625063925),
paymentProposalIds: [
"43Q5WWRJPNS4SE9YKS54H9THDS94089EDGXW9EHBPN6E7M184XEG",
],
@@ -125,9 +122,8 @@ export const ActiveBackupProblemDevice = createExample(TestedComponent, {
active: true,
name: "sync.demo",
syncProviderBaseUrl: "http://sync.taler:9967/",
- lastSuccessfulBackupTimestamp: {
- t_ms: 1625063925078,
- },
+ lastSuccessfulBackupTimestamp:
+ TalerProtocolTimestamp.fromSeconds(1625063925078),
paymentProposalIds: [
"43Q5WWRJPNS4SE9YKS54H9THDS94089EDGXW9EHBPN6E7M184XEG",
],
diff --git a/packages/taler-wallet-webextension/src/wallet/ProviderDetailPage.tsx b/packages/taler-wallet-webextension/src/wallet/ProviderDetailPage.tsx
index 765f34a02..afd9612ee 100644
--- a/packages/taler-wallet-webextension/src/wallet/ProviderDetailPage.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/ProviderDetailPage.tsx
@@ -15,6 +15,7 @@
*/
import * as utils from "@gnu-taler/taler-util";
+import { AbsoluteTime } from "@gnu-taler/taler-util";
import {
ProviderInfo,
ProviderPaymentStatus,
@@ -122,7 +123,9 @@ export function ProviderView({
</Fragment>
);
}
- const lb = info.lastSuccessfulBackupTimestamp;
+ const lb = info.lastSuccessfulBackupTimestamp
+ ? AbsoluteTime.fromTimestamp(info.lastSuccessfulBackupTimestamp)
+ : undefined;
const isPaid =
info.paymentStatus.type === ProviderPaymentType.Paid ||
info.paymentStatus.type === ProviderPaymentType.TermsChanged;
diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx
index 7b6ac1fdc..f02938420 100644
--- a/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx
@@ -21,6 +21,7 @@
import {
PaymentStatus,
+ TalerProtocolTimestamp,
TransactionCommon,
TransactionDeposit,
TransactionPayment,
@@ -53,9 +54,7 @@ const commonTransaction = {
amountRaw: "KUDOS:11",
amountEffective: "KUDOS:9.2",
pending: false,
- timestamp: {
- t_ms: new Date().getTime(),
- },
+ timestamp: TalerProtocolTimestamp.now(),
transactionId: "12",
} as TransactionCommon;
@@ -144,18 +143,14 @@ export const Withdraw = createExample(TestedComponent, {
export const WithdrawOneMinuteAgo = createExample(TestedComponent, {
transaction: {
...exampleData.withdraw,
- timestamp: {
- t_ms: new Date().getTime() - 60 * 1000,
- },
+ timestamp: TalerProtocolTimestamp.fromSeconds(new Date().getTime() - 60),
},
});
export const WithdrawOneMinuteAgoAndPending = createExample(TestedComponent, {
transaction: {
...exampleData.withdraw,
- timestamp: {
- t_ms: new Date().getTime() - 60 * 1000,
- },
+ timestamp: TalerProtocolTimestamp.fromSeconds(new Date().getTime() - 60),
pending: true,
},
});
diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
index b367416fa..0e58aaf61 100644
--- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
@@ -15,6 +15,7 @@
*/
import {
+ AbsoluteTime,
AmountLike,
Amounts,
NotificationType,
@@ -137,9 +138,9 @@ export function TransactionView({
}): VNode {
const showRetry =
transaction.error !== undefined ||
- transaction.timestamp.t_ms === "never" ||
+ transaction.timestamp.t_s === "never" ||
(transaction.pending &&
- differenceInSeconds(new Date(), transaction.timestamp.t_ms) > 10);
+ differenceInSeconds(new Date(), transaction.timestamp.t_s * 1000) > 10);
return (
<Fragment>
@@ -218,7 +219,7 @@ export function TransactionView({
<h2>
<i18n.Translate>Withdrawal</i18n.Translate>
</h2>
- <Time timestamp={transaction.timestamp} format="dd MMMM yyyy, HH:mm" />
+ <Time timestamp={AbsoluteTime.fromTimestamp(transaction.timestamp)} format="dd MMMM yyyy, HH:mm" />
{transaction.pending ? (
transaction.withdrawalDetails.type ===
WithdrawalType.ManualTransfer ? (
@@ -342,7 +343,7 @@ export function TransactionView({
<h2>
<i18n.Translate>Payment</i18n.Translate>
</h2>
- <Time timestamp={transaction.timestamp} format="dd MMMM yyyy, HH:mm" />
+ <Time timestamp={AbsoluteTime.fromTimestamp(transaction.timestamp)} format="dd MMMM yyyy, HH:mm" />
<br />
<Part
big
@@ -425,7 +426,7 @@ export function TransactionView({
<h2>
<i18n.Translate>Deposit</i18n.Translate>
</h2>
- <Time timestamp={transaction.timestamp} format="dd MMMM yyyy, HH:mm" />
+ <Time timestamp={AbsoluteTime.fromTimestamp(transaction.timestamp)} format="dd MMMM yyyy, HH:mm" />
<br />
<Part
big
@@ -459,7 +460,7 @@ export function TransactionView({
<h2>
<i18n.Translate>Refresh</i18n.Translate>
</h2>
- <Time timestamp={transaction.timestamp} format="dd MMMM yyyy, HH:mm" />
+ <Time timestamp={AbsoluteTime.fromTimestamp(transaction.timestamp)} format="dd MMMM yyyy, HH:mm" />
<br />
<Part
big
@@ -493,7 +494,7 @@ export function TransactionView({
<h2>
<i18n.Translate>Tip</i18n.Translate>
</h2>
- <Time timestamp={transaction.timestamp} format="dd MMMM yyyy, HH:mm" />
+ <Time timestamp={AbsoluteTime.fromTimestamp(transaction.timestamp)} format="dd MMMM yyyy, HH:mm" />
<br />
<Part
big
@@ -527,7 +528,10 @@ export function TransactionView({
<h2>
<i18n.Translate>Refund</i18n.Translate>
</h2>
- <Time timestamp={transaction.timestamp} format="dd MMMM yyyy, HH:mm" />
+ <Time
+ timestamp={AbsoluteTime.fromTimestamp(transaction.timestamp)}
+ format="dd MMMM yyyy, HH:mm"
+ />
<br />
<Part
big