Skip to content

Commit ce82610

Browse files
author
Marcin Mazurek
committed
Address PR feedback
1 parent 49c1427 commit ce82610

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

source/renderer/app/stores/VotingStore.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ import { formattedArrayBufferToHexString } from '../utils/formatters';
1111
import walletUtils from '../utils/walletUtils';
1212
import {
1313
VOTING_PHASE_CHECK_INTERVAL,
14-
VOTING_REGISTRATION_TRANSACTION_POLLING_INTERVAL,
1514
VOTING_REGISTRATION_MIN_TRANSACTION_CONFIRMATIONS,
15+
VOTING_REGISTRATION_TRANSACTION_POLLING_INTERVAL,
1616
} from '../config/votingConfig';
17-
import { votingPDFGenerator } from '../utils/votingPDFGenerator';
17+
import {
18+
votingPDFGenerator,
19+
VotingPDFGeneratorResult,
20+
} from '../utils/votingPDFGenerator';
1821
import { i18nContext } from '../utils/i18nContext';
1922
import type { PathRoleIdentityType } from '../utils/hardwareWalletUtils';
2023
import type {
@@ -423,7 +426,7 @@ export default class VotingStore extends Store {
423426
const { network, isMainnet } = this.environment;
424427
const intl = i18nContext(currentLocale);
425428

426-
const wasSaved = await votingPDFGenerator({
429+
const result = await votingPDFGenerator({
427430
nextVotingFundNumber,
428431
qrCode,
429432
walletName,
@@ -436,7 +439,7 @@ export default class VotingStore extends Store {
436439
intl,
437440
});
438441

439-
if (wasSaved) {
442+
if (result === VotingPDFGeneratorResult.FileSaved) {
440443
this.actions.voting.saveAsPDFSuccess.trigger();
441444
}
442445
};

source/renderer/app/utils/votingPDFGenerator.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const messages = defineMessages({
3434
description: 'PDF author',
3535
},
3636
});
37+
3738
type Params = {
3839
nextVotingFundNumber: number;
3940
qrCode: string;
@@ -46,6 +47,12 @@ type Params = {
4647
isMainnet: boolean;
4748
intl: Record<string, any>;
4849
};
50+
51+
export enum VotingPDFGeneratorResult {
52+
FileSaved = 'FileSaved',
53+
CancelledByUser = 'CancelledByUser',
54+
}
55+
4956
export const votingPDFGenerator = async ({
5057
nextVotingFundNumber,
5158
qrCode,
@@ -57,7 +64,7 @@ export const votingPDFGenerator = async ({
5764
network,
5865
isMainnet,
5966
intl,
60-
}: Params): Promise<boolean> => {
67+
}: Params): Promise<VotingPDFGeneratorResult> => {
6168
// Consolidate data
6269
const title = intl.formatMessage(messages.title, {
6370
nextVotingFundNumber,
@@ -95,7 +102,7 @@ export const votingPDFGenerator = async ({
95102
const filePath = dialogPath.filePath || '';
96103

97104
if (dialogPath.canceled || !!filePath) {
98-
return false;
105+
return VotingPDFGeneratorResult.CancelledByUser;
99106
}
100107

101108
await generateVotingPDFChannel.send({
@@ -112,5 +119,5 @@ export const votingPDFGenerator = async ({
112119
author,
113120
});
114121

115-
return true;
122+
return VotingPDFGeneratorResult.FileSaved;
116123
};

0 commit comments

Comments
 (0)