mirror of
https://github.com/Radarr/Radarr
synced 2025-02-28 00:45:50 +00:00
Prevent double clicking of commands
This commit is contained in:
parent
35c618d81b
commit
d43e9785d5
1 changed files with 25 additions and 3 deletions
|
@ -6,8 +6,10 @@ define(
|
||||||
'Commands/CommandCollection',
|
'Commands/CommandCollection',
|
||||||
'Commands/CommandMessengerCollectionView',
|
'Commands/CommandMessengerCollectionView',
|
||||||
'underscore',
|
'underscore',
|
||||||
|
'moment',
|
||||||
|
'Shared/Messenger',
|
||||||
'jQuery/jquery.spin'
|
'jQuery/jquery.spin'
|
||||||
], function (vent, CommandModel, CommandCollection, CommandMessengerCollectionView, _) {
|
], function (vent, CommandModel, CommandCollection, CommandMessengerCollectionView, _, moment, Messenger) {
|
||||||
|
|
||||||
|
|
||||||
CommandMessengerCollectionView.render();
|
CommandMessengerCollectionView.render();
|
||||||
|
@ -16,15 +18,35 @@ define(
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
||||||
|
_lastCommand: {},
|
||||||
|
|
||||||
Execute: function (name, properties) {
|
Execute: function (name, properties) {
|
||||||
|
|
||||||
var attr = _.extend({name: name.toLocaleLowerCase()}, properties);
|
var attr = _.extend({name: name.toLocaleLowerCase()}, properties);
|
||||||
|
|
||||||
var commandModel = new CommandModel(attr);
|
var commandModel = new CommandModel(attr);
|
||||||
|
|
||||||
return commandModel.save().success(function () {
|
if (this._lastCommand.command && this._lastCommand.command.isSameCommand(attr) && moment().add('seconds', -5).isBefore(this._lastCommand.time)) {
|
||||||
|
|
||||||
|
Messenger.show({
|
||||||
|
message: 'Please wait at least 5 seconds before running this command again',
|
||||||
|
hideAfter: 5,
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
|
|
||||||
|
return this._lastCommand.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
var promise = commandModel.save().success(function () {
|
||||||
CommandCollection.add(commandModel);
|
CommandCollection.add(commandModel);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._lastCommand = {
|
||||||
|
command : commandModel,
|
||||||
|
promise : promise,
|
||||||
|
time : moment()
|
||||||
|
};
|
||||||
|
|
||||||
|
return promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
bindToCommand: function (options) {
|
bindToCommand: function (options) {
|
||||||
|
|
Loading…
Reference in a new issue