Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
retypos-webclient
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eterfund
retypos-webclient
Commits
040cea16
Commit
040cea16
authored
Jun 29, 2018
by
Георгий Попов
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add request timeout to corrections
parent
466bf059
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
8 deletions
+29
-8
index.js
src/App/index.js
+16
-3
Localization.js
src/Localization.js
+1
-0
index.js
src/Modal/index.js
+8
-5
config.js
src/config.js
+4
-0
No files found.
src/App/index.js
View file @
040cea16
...
...
@@ -14,7 +14,8 @@ class App extends Component {
super
(
props
,
context
);
this
.
state
=
{
correctionMode
:
false
correctionMode
:
false
,
isTimeout
:
false
,
}
this
.
typo
=
""
;
...
...
@@ -33,6 +34,11 @@ class App extends Component {
registerHandlers
()
{
$
(
document
).
keydown
(
event
=>
{
if
(
event
.
ctrlKey
&&
event
.
keyCode
===
13
)
{
if
(
this
.
state
.
isTimeout
)
{
alertify
.
error
(
i18n
.
errorTooOften
);
return
;
}
const
selection
=
this
.
getSelectedText
();
if
(
selection
===
""
)
{
...
...
@@ -71,8 +77,15 @@ class App extends Component {
// This method is invoked when a modal has been closed
modalClosedCallback
=
()
=>
{
this
.
setState
({
correctionMode
:
false
})
correctionMode
:
false
,
isTimeout
:
true
,
});
window
.
setTimeout
(()
=>
{
console
.
log
(
"state"
,
this
.
state
);
this
.
setState
({
isTimeout
:
false
});
console
.
log
(
"afterstate"
,
this
.
state
);
},
config
.
requestTimeout
);
}
}
...
...
src/Localization.js
View file @
040cea16
...
...
@@ -13,6 +13,7 @@ export const i18n = new LocalizedStrings({
errorSelectionLength
:
"Опечатка должна быть длиной от {0} до {1} символов"
,
errorCorrectLength
:
"Исправление должно быть длиной от {0} до {1} символов"
,
errorDoesNotDistinct
:
"Исправленный вариант идентичен исходному"
,
errorTooOften
:
"Вы отправляете исправления слишком часто"
,
close
:
"Закрыть"
,
saveChanges
:
"Сохранить изменения"
,
messageSuccess
:
"Благодарим за отправку. Опечатка будет исправлена"
,
...
...
src/Modal/index.js
View file @
040cea16
...
...
@@ -18,7 +18,7 @@ class TypoModal extends Component {
text
:
this
.
props
.
text
,
correct
:
this
.
props
.
text
,
comment
:
""
,
error
:
""
,
error
:
""
}
this
.
closeCallback
=
props
.
closeCallback
;
...
...
@@ -71,13 +71,16 @@ class TypoModal extends Component {
// Send typo to the typos server
submitTypo
=
(
corrected
,
comment
)
=>
{
if
(
this
.
checkData
())
{
this
.
handleClose
();
alertify
.
success
(
i18n
.
messageSuccess
);
if
(
!
this
.
checkData
())
{
alertify
.
error
(
i18n
.
messageFailture
);
return
;
}
alertify
.
error
(
i18n
.
messageFailture
)
this
.
handleClose
();
alertify
.
success
(
i18n
.
messageSuccess
);
return
;
}
render
()
{
...
...
src/config.js
View file @
040cea16
...
...
@@ -3,4 +3,7 @@ export const config = {
minTypoLength
:
4
,
maxCorrectLength
:
100
,
minCorrectLength
:
1
,
serverUrl
:
"//eterfund.ru/api/typos/server.php"
,
requestTimeout
:
10000
,
};
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment