signal-desktop/ts/services/donationsLoader.ts

32 lines
913 B
TypeScript
Raw Normal View History

2025-06-25 18:16:46 -05:00
// Copyright 2025 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { DataReader } from '../sql/Client';
import { strictAssert } from '../util/assert';
2025-07-10 07:34:42 +10:00
import { _getWorkflowFromStorage } from './donations';
2025-06-25 18:16:46 -05:00
import type { DonationReceipt } from '../types/Donations';
import type { DonationsStateType } from '../state/ducks/donations';
let donationReceipts: Array<DonationReceipt> | undefined;
export async function loadDonationReceipts(): Promise<void> {
donationReceipts = await DataReader.getAllDonationReceipts();
}
export function getDonationsForRedux(): DonationsStateType {
2025-06-25 18:16:46 -05:00
strictAssert(
donationReceipts != null,
'donation receipts have not been loaded'
);
const currentWorkflow = _getWorkflowFromStorage();
2025-06-25 18:16:46 -05:00
return {
currentWorkflow,
didResumeWorkflowAtStartup: Boolean(currentWorkflow),
2025-07-10 07:34:42 +10:00
lastError: undefined,
2025-06-25 18:16:46 -05:00
receipts: donationReceipts,
};
}