summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/attention.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/attention.ts')
-rw-r--r--packages/taler-wallet-core/src/attention.ts70
1 files changed, 38 insertions, 32 deletions
diff --git a/packages/taler-wallet-core/src/attention.ts b/packages/taler-wallet-core/src/attention.ts
index 60d2117f1..7a52ceaa3 100644
--- a/packages/taler-wallet-core/src/attention.ts
+++ b/packages/taler-wallet-core/src/attention.ts
@@ -29,7 +29,7 @@ import {
UserAttentionsResponse,
} from "@gnu-taler/taler-util";
import { timestampPreciseFromDb, timestampPreciseToDb } from "./db.js";
-import { InternalWalletState, WalletExecutionContext } from "./wallet.js";
+import { WalletExecutionContext } from "./wallet.js";
const logger = new Logger("operations/attention.ts");
@@ -37,20 +37,23 @@ export async function getUserAttentionsUnreadCount(
wex: WalletExecutionContext,
req: UserAttentionsRequest,
): Promise<UserAttentionsCountResponse> {
- const total = await wex.db.runReadOnlyTx(["userAttention"], async (tx) => {
- let count = 0;
- await tx.userAttention.iter().forEach((x) => {
- if (
- req.priority !== undefined &&
- UserAttentionPriority[x.info.type] !== req.priority
- )
- return;
- if (x.read !== undefined) return;
- count++;
- });
+ const total = await wex.db.runReadOnlyTx(
+ { storeNames: ["userAttention"] },
+ async (tx) => {
+ let count = 0;
+ await tx.userAttention.iter().forEach((x) => {
+ if (
+ req.priority !== undefined &&
+ UserAttentionPriority[x.info.type] !== req.priority
+ )
+ return;
+ if (x.read !== undefined) return;
+ count++;
+ });
- return count;
- });
+ return count;
+ },
+ );
return { total };
}
@@ -59,30 +62,33 @@ export async function getUserAttentions(
wex: WalletExecutionContext,
req: UserAttentionsRequest,
): Promise<UserAttentionsResponse> {
- return await wex.db.runReadOnlyTx(["userAttention"], async (tx) => {
- const pending: UserAttentionUnreadList = [];
- await tx.userAttention.iter().forEach((x) => {
- if (
- req.priority !== undefined &&
- UserAttentionPriority[x.info.type] !== req.priority
- )
- return;
- pending.push({
- info: x.info,
- when: timestampPreciseFromDb(x.created),
- read: x.read !== undefined,
+ return await wex.db.runReadOnlyTx(
+ { storeNames: ["userAttention"] },
+ async (tx) => {
+ const pending: UserAttentionUnreadList = [];
+ await tx.userAttention.iter().forEach((x) => {
+ if (
+ req.priority !== undefined &&
+ UserAttentionPriority[x.info.type] !== req.priority
+ )
+ return;
+ pending.push({
+ info: x.info,
+ when: timestampPreciseFromDb(x.created),
+ read: x.read !== undefined,
+ });
});
- });
- return { pending };
- });
+ return { pending };
+ },
+ );
}
export async function markAttentionRequestAsRead(
wex: WalletExecutionContext,
req: UserAttentionByIdRequest,
): Promise<void> {
- await wex.db.runReadWriteTx(["userAttention"], async (tx) => {
+ await wex.db.runReadWriteTx({ storeNames: ["userAttention"] }, async (tx) => {
const ua = await tx.userAttention.get([req.entityId, req.type]);
if (!ua) throw Error("attention request not found");
tx.userAttention.put({
@@ -104,7 +110,7 @@ export async function addAttentionRequest(
info: AttentionInfo,
entityId: string,
): Promise<void> {
- await wex.db.runReadWriteTx(["userAttention"], async (tx) => {
+ await wex.db.runReadWriteTx({ storeNames: ["userAttention"] }, async (tx) => {
await tx.userAttention.put({
info,
entityId,
@@ -125,7 +131,7 @@ export async function removeAttentionRequest(
wex: WalletExecutionContext,
req: UserAttentionByIdRequest,
): Promise<void> {
- await wex.db.runReadWriteTx(["userAttention"], async (tx) => {
+ await wex.db.runReadWriteTx({ storeNames: ["userAttention"] }, async (tx) => {
const ua = await tx.userAttention.get([req.entityId, req.type]);
if (!ua) throw Error("attention request not found");
await tx.userAttention.delete([req.entityId, req.type]);