mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-22 17:04:59 -05:00
Show notifications only when the user is detected as idle
This commit is contained in:
parent
47fb286184
commit
eab463fda5
@ -15,8 +15,8 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
angular.module('RoomController', ['ngSanitize', 'mFileInput'])
|
angular.module('RoomController', ['ngSanitize', 'mFileInput'])
|
||||||
.controller('RoomController', ['$scope', '$timeout', '$routeParams', '$location', '$rootScope', 'matrixService', 'eventHandlerService', 'mFileUpload', 'matrixPhoneService', 'MatrixCall',
|
.controller('RoomController', ['$scope', '$timeout', '$routeParams', '$location', '$rootScope', 'matrixService', 'eventHandlerService', 'mFileUpload', 'mPresence', 'matrixPhoneService', 'MatrixCall',
|
||||||
function($scope, $timeout, $routeParams, $location, $rootScope, matrixService, eventHandlerService, mFileUpload, matrixPhoneService, MatrixCall) {
|
function($scope, $timeout, $routeParams, $location, $rootScope, matrixService, eventHandlerService, mFileUpload, mPresence, matrixPhoneService, MatrixCall) {
|
||||||
'use strict';
|
'use strict';
|
||||||
var MESSAGES_PER_PAGINATION = 30;
|
var MESSAGES_PER_PAGINATION = 30;
|
||||||
var THUMBNAIL_SIZE = 320;
|
var THUMBNAIL_SIZE = 320;
|
||||||
@ -57,15 +57,14 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
|
|||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
|
|
||||||
if (window.Notification) {
|
if (window.Notification) {
|
||||||
// FIXME: we should also notify based on a timer or other heuristics
|
// Show notification when the user is idle
|
||||||
// rather than the window being minimised
|
if (matrixService.presence.offline === mPresence.getState()) {
|
||||||
if (document.hidden) {
|
|
||||||
var notification = new window.Notification(
|
var notification = new window.Notification(
|
||||||
($scope.members[event.user_id].displayname || event.user_id) +
|
($scope.members[event.user_id].displayname || event.user_id) +
|
||||||
" (" + ($scope.room_alias || $scope.room_id) + ")", // FIXME: don't leak room_ids here
|
" (" + ($scope.room_alias || $scope.room_id) + ")", // FIXME: don't leak room_ids here
|
||||||
{
|
{
|
||||||
"body": event.content.body,
|
"body": event.content.body,
|
||||||
"icon": $scope.members[event.user_id].avatar_url,
|
"icon": $scope.members[event.user_id].avatar_url
|
||||||
});
|
});
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
notification.close();
|
notification.close();
|
||||||
@ -230,7 +229,7 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
|
|||||||
var member = $scope.members[target_user_id];
|
var member = $scope.members[target_user_id];
|
||||||
member.content.membership = chunk.content.membership;
|
member.content.membership = chunk.content.membership;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
var updatePresence = function(chunk) {
|
var updatePresence = function(chunk) {
|
||||||
if (!(chunk.content.user_id in $scope.members)) {
|
if (!(chunk.content.user_id in $scope.members)) {
|
||||||
@ -257,10 +256,10 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
|
|||||||
if ("avatar_url" in chunk.content) {
|
if ("avatar_url" in chunk.content) {
|
||||||
member.avatar_url = chunk.content.avatar_url;
|
member.avatar_url = chunk.content.avatar_url;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
$scope.send = function() {
|
$scope.send = function() {
|
||||||
if ($scope.textInput == "") {
|
if ($scope.textInput === "") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +268,7 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
|
|||||||
// Send the text message
|
// Send the text message
|
||||||
var promise;
|
var promise;
|
||||||
// FIXME: handle other commands too
|
// FIXME: handle other commands too
|
||||||
if ($scope.textInput.indexOf("/me") == 0) {
|
if ($scope.textInput.indexOf("/me") === 0) {
|
||||||
promise = matrixService.sendEmoteMessage($scope.room_id, $scope.textInput.substr(4));
|
promise = matrixService.sendEmoteMessage($scope.room_id, $scope.textInput.substr(4));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user