Skip to content

Commit 251eaf9

Browse files
mfix22briandennis
authored andcommitted
Use getRandomElement function
1 parent 203eac1 commit 251eaf9

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/helpers/notifier/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,24 @@ function notify ({ didSucceed, operation }) {
2828
}
2929

3030
function genInfo (didSucceed, operation) {
31-
const index = getIndex()
3231
const operationText = operation === MERGE ? 'Merge' : 'Conversion'
3332

3433
if (didSucceed) {
3534
return {
3635
title: `${operationText} complete!`,
37-
body: text.success[index],
36+
body: getRandomElement(text.success),
3837
icon: `${imgPath}/success.png`
3938
}
4039
}
4140

4241
return {
4342
title: `Oh no! ${operationText} failed.`,
44-
body: text.failure[index],
43+
body: getRandomElement(text.failure),
4544
icon: `${imgPath}/failure.png`
4645
}
4746
}
4847

49-
function getIndex () {
48+
function getRandomElement (array) {
5049
const rnd = Math.random()
51-
return Math.floor(rnd * text.messageCount)
50+
return array[Math.floor(rnd * array.length)]
5251
}

src/helpers/notifier/text.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"messageCount": 5,
32
"success": [
43
"Your images are done a'brewin.",
54
"The transmutation was a success.",
@@ -14,4 +13,4 @@
1413
"Another deception of the photo sorcerer.",
1514
"The night is dark and full of terrors."
1615
]
17-
}
16+
}

0 commit comments

Comments
 (0)