Skip to content

Commit 6d92c17

Browse files
committed
Merge branch 'beta'
2 parents a9e4c93 + 92e672a commit 6d92c17

File tree

14 files changed

+49
-7
lines changed

14 files changed

+49
-7
lines changed

src/botPage/view/blockly/relationChecker.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/* eslint-disable no-underscore-dangle */
22
import { observer } from 'binary-common-utils/lib/observer'
3-
import { durationAccepted, expandDuration } from 'binary-common-utils/lib/tools'
43
import config from '../../../common/const'
54
import { bot } from '../../bot'
65
import { translator } from '../../../common/translator'
76
import { findTopParentBlock, addPurchaseOptions,
8-
disable, enable } from './utils'
7+
disable, enable, durationToSecond, expandDuration } from './utils'
98

109
const isInteger = (amount) => !isNaN(+amount) && parseInt(amount, 10) === parseFloat(amount)
1110
const isInRange = (amount, min, max) => !isNaN(+amount) && +amount >= min && +amount <= max
@@ -38,13 +37,13 @@ const conditionFields = (blockObj, ev, calledByParent) => {
3837
if (duration !== '') {
3938
const minDuration = bot.symbol.getLimitation(
4039
blockObj.parentBlock_.type, blockObj.type).minDuration
41-
if (!durationAccepted(duration + durationType, minDuration)) {
40+
const durationInSeconds = durationToSecond(duration + durationType)
41+
if (!durationInSeconds) {
42+
observer.emit('ui.log.warn', translator.translateText('Duration must be a positive integer'))
43+
} else if (durationInSeconds < durationToSecond(minDuration)) {
4244
observer.emit('ui.log.warn',
4345
`${translator.translateText('Minimum duration is')} ${expandDuration(minDuration)}`)
44-
} else {
45-
observer.emit('tour:ticks')
46-
}
47-
if (durationType === 't') {
46+
} else if (durationType === 't') {
4847
if (!isInteger(duration) || !isInRange(duration, 5, 10)) {
4948
observer.emit('ui.log.warn',
5049
translator.translateText('Number of ticks must be between 5 and 10'))

src/botPage/view/blockly/utils.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,34 @@ export const enable = (blockObj) => {
162162
blockObj.setDisabled(false)
163163
Blockly.Events.recordUndo = true
164164
}
165+
166+
export const expandDuration = (duration) => `${duration.replace(/t/g, ' tick')
167+
.replace(/s/g, ' second')
168+
.replace(/m/g, ' minute')
169+
.replace(/h/g, ' hour')
170+
.replace(/d/g, ' day')}(s)`
171+
172+
export const durationToSecond = (duration) => {
173+
const parsedDuration = duration.match(/^([0-9]+)([stmhd])$/)
174+
if (!parsedDuration) {
175+
return null
176+
}
177+
const durationValue = parseFloat(parsedDuration[1])
178+
const durationType = parsedDuration[2]
179+
if (durationType === 's') {
180+
return durationValue
181+
}
182+
if (durationType === 't') {
183+
return durationValue * 2
184+
}
185+
if (durationType === 'm') {
186+
return durationValue * 60
187+
}
188+
if (durationType === 'h') {
189+
return durationValue * 60 * 60
190+
}
191+
if (durationType === 'd') {
192+
return durationValue * 60 * 60 * 24
193+
}
194+
return null
195+
}

src/common/translations/de.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ module.exports = {
136136
"af145748c9cf765a3b059eec20cb1dbb899297d8": "Blocks are loaded successfully",
137137
"da162a909c2981ed318d23cd9a6be1d66e0a8400": "Unrecognized file format.",
138138
"c3c49d3e838c8fe813d360aea7dc6b792948afde": "Markets",
139+
"2f9f9096be1a1c0569a9ce54e57f0420f6b3c2e9": "Duration must be a positive integer",
139140
"11ee9c5d534cc8d22651092222b532917594161a": "Minimum duration is",
140141
"5283ac04c9a8ba8a937d1edb4ba986aeefce8bf1": "Number of ticks must be between 5 and 10",
141142
"ace1342bc3720b77ce510b93074041e7386d209e": "Expiry time cannot be equal to start time",

src/common/translations/en.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ module.exports = {
136136
"af145748c9cf765a3b059eec20cb1dbb899297d8": "Blocks are loaded successfully",
137137
"da162a909c2981ed318d23cd9a6be1d66e0a8400": "Unrecognized file format.",
138138
"c3c49d3e838c8fe813d360aea7dc6b792948afde": "Markets",
139+
"2f9f9096be1a1c0569a9ce54e57f0420f6b3c2e9": "Duration must be a positive integer",
139140
"11ee9c5d534cc8d22651092222b532917594161a": "Minimum duration is",
140141
"5283ac04c9a8ba8a937d1edb4ba986aeefce8bf1": "Number of ticks must be between 5 and 10",
141142
"ace1342bc3720b77ce510b93074041e7386d209e": "Expiry time cannot be equal to start time",

src/common/translations/es.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ module.exports = {
136136
"af145748c9cf765a3b059eec20cb1dbb899297d8": "Blocks are loaded successfully",
137137
"da162a909c2981ed318d23cd9a6be1d66e0a8400": "Unrecognized file format.",
138138
"c3c49d3e838c8fe813d360aea7dc6b792948afde": "Markets",
139+
"2f9f9096be1a1c0569a9ce54e57f0420f6b3c2e9": "Duration must be a positive integer",
139140
"11ee9c5d534cc8d22651092222b532917594161a": "Minimum duration is",
140141
"5283ac04c9a8ba8a937d1edb4ba986aeefce8bf1": "Number of ticks must be between 5 and 10",
141142
"ace1342bc3720b77ce510b93074041e7386d209e": "Expiry time cannot be equal to start time",

src/common/translations/fr.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ module.exports = {
136136
"af145748c9cf765a3b059eec20cb1dbb899297d8": "Blocks are loaded successfully",
137137
"da162a909c2981ed318d23cd9a6be1d66e0a8400": "Unrecognized file format.",
138138
"c3c49d3e838c8fe813d360aea7dc6b792948afde": "Markets",
139+
"2f9f9096be1a1c0569a9ce54e57f0420f6b3c2e9": "Duration must be a positive integer",
139140
"11ee9c5d534cc8d22651092222b532917594161a": "Minimum duration is",
140141
"5283ac04c9a8ba8a937d1edb4ba986aeefce8bf1": "Number of ticks must be between 5 and 10",
141142
"ace1342bc3720b77ce510b93074041e7386d209e": "Expiry time cannot be equal to start time",

src/common/translations/id.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ module.exports = {
136136
"af145748c9cf765a3b059eec20cb1dbb899297d8": "Blocks are loaded successfully",
137137
"da162a909c2981ed318d23cd9a6be1d66e0a8400": "Unrecognized file format.",
138138
"c3c49d3e838c8fe813d360aea7dc6b792948afde": "Markets",
139+
"2f9f9096be1a1c0569a9ce54e57f0420f6b3c2e9": "Duration must be a positive integer",
139140
"11ee9c5d534cc8d22651092222b532917594161a": "Minimum duration is",
140141
"5283ac04c9a8ba8a937d1edb4ba986aeefce8bf1": "Number of ticks must be between 5 and 10",
141142
"ace1342bc3720b77ce510b93074041e7386d209e": "Expiry time cannot be equal to start time",

src/common/translations/it.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ module.exports = {
136136
"af145748c9cf765a3b059eec20cb1dbb899297d8": "Blocks are loaded successfully",
137137
"da162a909c2981ed318d23cd9a6be1d66e0a8400": "Unrecognized file format.",
138138
"c3c49d3e838c8fe813d360aea7dc6b792948afde": "Markets",
139+
"2f9f9096be1a1c0569a9ce54e57f0420f6b3c2e9": "Duration must be a positive integer",
139140
"11ee9c5d534cc8d22651092222b532917594161a": "Minimum duration is",
140141
"5283ac04c9a8ba8a937d1edb4ba986aeefce8bf1": "Number of ticks must be between 5 and 10",
141142
"ace1342bc3720b77ce510b93074041e7386d209e": "Expiry time cannot be equal to start time",

src/common/translations/pl.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ module.exports = {
136136
"af145748c9cf765a3b059eec20cb1dbb899297d8": "Blocks are loaded successfully",
137137
"da162a909c2981ed318d23cd9a6be1d66e0a8400": "Unrecognized file format.",
138138
"c3c49d3e838c8fe813d360aea7dc6b792948afde": "Markets",
139+
"2f9f9096be1a1c0569a9ce54e57f0420f6b3c2e9": "Duration must be a positive integer",
139140
"11ee9c5d534cc8d22651092222b532917594161a": "Minimum duration is",
140141
"5283ac04c9a8ba8a937d1edb4ba986aeefce8bf1": "Number of ticks must be between 5 and 10",
141142
"ace1342bc3720b77ce510b93074041e7386d209e": "Expiry time cannot be equal to start time",

src/common/translations/pt.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ module.exports = {
136136
"af145748c9cf765a3b059eec20cb1dbb899297d8": "Blocks are loaded successfully",
137137
"da162a909c2981ed318d23cd9a6be1d66e0a8400": "Unrecognized file format.",
138138
"c3c49d3e838c8fe813d360aea7dc6b792948afde": "Markets",
139+
"2f9f9096be1a1c0569a9ce54e57f0420f6b3c2e9": "Duration must be a positive integer",
139140
"11ee9c5d534cc8d22651092222b532917594161a": "Minimum duration is",
140141
"5283ac04c9a8ba8a937d1edb4ba986aeefce8bf1": "Number of ticks must be between 5 and 10",
141142
"ace1342bc3720b77ce510b93074041e7386d209e": "Expiry time cannot be equal to start time",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy