mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Disabled sending buttons while a message is being sent. Useful on bad Internet connection.
This commit is contained in:
parent
849627b82e
commit
955662d64c
@ -30,7 +30,8 @@ angular.module('RoomController', ['ngSanitize'])
|
|||||||
earliest_token: "END", // stores how far back we've paginated.
|
earliest_token: "END", // stores how far back we've paginated.
|
||||||
can_paginate: true, // this is toggled off when we run out of items
|
can_paginate: true, // this is toggled off when we run out of items
|
||||||
paginating: false, // used to avoid concurrent pagination requests pulling in dup contents
|
paginating: false, // used to avoid concurrent pagination requests pulling in dup contents
|
||||||
stream_failure: undefined // the response when the stream fails
|
stream_failure: undefined, // the response when the stream fails
|
||||||
|
sending: false // true when a message is being sent. It helps to disable the UI when a process is running
|
||||||
};
|
};
|
||||||
$scope.members = {};
|
$scope.members = {};
|
||||||
$scope.autoCompleting = false;
|
$scope.autoCompleting = false;
|
||||||
@ -233,6 +234,8 @@ angular.module('RoomController', ['ngSanitize'])
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.state.sending = true;
|
||||||
|
|
||||||
// Send the text message
|
// Send the text message
|
||||||
var promise;
|
var promise;
|
||||||
// FIXME: handle other commands too
|
// FIXME: handle other commands too
|
||||||
@ -247,9 +250,11 @@ angular.module('RoomController', ['ngSanitize'])
|
|||||||
function() {
|
function() {
|
||||||
console.log("Sent message");
|
console.log("Sent message");
|
||||||
$scope.textInput = "";
|
$scope.textInput = "";
|
||||||
|
$scope.state.sending = false;
|
||||||
},
|
},
|
||||||
function(error) {
|
function(error) {
|
||||||
$scope.feedback = "Failed to send: " + error.data.error;
|
$scope.feedback = "Failed to send: " + error.data.error;
|
||||||
|
$scope.state.sending = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -362,18 +367,24 @@ angular.module('RoomController', ['ngSanitize'])
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.sendImage = function(url) {
|
$scope.sendImage = function(url) {
|
||||||
|
$scope.state.sending = true;
|
||||||
|
|
||||||
matrixService.sendImageMessage($scope.room_id, url).then(
|
matrixService.sendImageMessage($scope.room_id, url).then(
|
||||||
function() {
|
function() {
|
||||||
console.log("Image sent");
|
console.log("Image sent");
|
||||||
},
|
},
|
||||||
function(error) {
|
function(error) {
|
||||||
$scope.feedback = "Failed to send image: " + error.data.error;
|
$scope.feedback = "Failed to send image: " + error.data.error;
|
||||||
|
$scope.state.sending = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.imageFileToSend;
|
$scope.imageFileToSend;
|
||||||
$scope.$watch("imageFileToSend", function(newValue, oldValue) {
|
$scope.$watch("imageFileToSend", function(newValue, oldValue) {
|
||||||
if ($scope.imageFileToSend) {
|
if ($scope.imageFileToSend) {
|
||||||
|
|
||||||
|
$scope.state.sending = true;
|
||||||
|
|
||||||
// First download the image to the Internet
|
// First download the image to the Internet
|
||||||
console.log("Uploading image...");
|
console.log("Uploading image...");
|
||||||
mFileUpload.uploadFile($scope.imageFileToSend).then(
|
mFileUpload.uploadFile($scope.imageFileToSend).then(
|
||||||
@ -383,6 +394,7 @@ angular.module('RoomController', ['ngSanitize'])
|
|||||||
},
|
},
|
||||||
function(error) {
|
function(error) {
|
||||||
$scope.feedback = "Can't upload image";
|
$scope.feedback = "Can't upload image";
|
||||||
|
$scope.state.sending = false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -63,10 +63,10 @@
|
|||||||
{{ state.user_id }}
|
{{ state.user_id }}
|
||||||
</td>
|
</td>
|
||||||
<td width="*" style="min-width: 100px">
|
<td width="*" style="min-width: 100px">
|
||||||
<input id="mainInput" ng-model="textInput" ng-enter="send()" ng-focus="true" auto-complete/>
|
<input id="mainInput" ng-model="textInput" ng-enter="send()" ng-disabled="state.sending" ng-focus="true" auto-complete/>
|
||||||
</td>
|
</td>
|
||||||
<td width="1">
|
<td width="1">
|
||||||
<button ng-click="send()">Send</button>
|
<button ng-click="send()" ng-disabled="state.sending">Send</button>
|
||||||
</td>
|
</td>
|
||||||
<td width="1">
|
<td width="1">
|
||||||
|
|
||||||
@ -79,7 +79,7 @@
|
|||||||
<input id="mainInput" ng-model="imageURLToSend" ng-enter="sendImage(imageURLToSend)" placeholder="Image URL"/>
|
<input id="mainInput" ng-model="imageURLToSend" ng-enter="sendImage(imageURLToSend)" placeholder="Image URL"/>
|
||||||
</td>
|
</td>
|
||||||
<td width="100px">
|
<td width="100px">
|
||||||
<button ng-click="sendImage(imageURLToSend)">Send URL</button>
|
<button ng-click="sendImage(imageURLToSend)" ng-disabled="state.sending">Send URL</button>
|
||||||
</td>
|
</td>
|
||||||
<!-- TODO: To enable once we have an upload server
|
<!-- TODO: To enable once we have an upload server
|
||||||
<td width="100px">
|
<td width="100px">
|
||||||
|
Loading…
Reference in New Issue
Block a user