Bladeren bron

updated online user management to only send cursor position when people are collaborate

if someone is in the project with them cursor info is sent every 500ms, if they are
by themself it is sent every 5mins so they are still marked as online.
Henry Oswald 11 jaren geleden
bovenliggende
commit
dbd076849b
1 gewijzigde bestanden met toevoegingen van 12 en 2 verwijderingen
  1. 12 2
      services/web/public/coffee/ide/online-users/OnlineUsersManager.coffee

+ 12 - 2
services/web/public/coffee/ide/online-users/OnlineUsersManager.coffee

@@ -3,6 +3,9 @@ define [
 	"ide/online-users/controllers/OnlineUsersController"
 	"ide/online-users/controllers/OnlineUsersController"
 ], () ->
 ], () ->
 	class OnlineUsersManager
 	class OnlineUsersManager
+
+		cursorUpdateInterval:500
+
 		constructor: (@ide, @$scope) ->
 		constructor: (@ide, @$scope) ->
 			@$scope.onlineUsers = {}
 			@$scope.onlineUsers = {}
 			@$scope.onlineUserCursorHighlights = {}
 			@$scope.onlineUserCursorHighlights = {}
@@ -70,7 +73,14 @@ define [
 					hue: @getHueForUserId(client.user_id)
 					hue: @getHueForUserId(client.user_id)
 				}
 				}
 
 
-		UPDATE_INTERVAL: 500
+			if @$scope.onlineUsersArray.length > 0
+				delete @cursorUpdateTimeout
+				@cursorUpdateInterval = 500
+			else
+				delete @cursorUpdateTimeout
+				@cursorUpdateInterval = 60 * 1000 * 5
+
+
 		sendCursorPositionUpdate: (position) ->
 		sendCursorPositionUpdate: (position) ->
 			if !@cursorUpdateTimeout?
 			if !@cursorUpdateTimeout?
 				@cursorUpdateTimeout = setTimeout ()=>
 				@cursorUpdateTimeout = setTimeout ()=>
@@ -83,7 +93,7 @@ define [
 					}
 					}
 
 
 					delete @cursorUpdateTimeout
 					delete @cursorUpdateTimeout
-				, @UPDATE_INTERVAL
+				, @cursorUpdateInterval
 
 
 		OWN_HUE: 200 # We will always appear as this color to ourselves
 		OWN_HUE: 200 # We will always appear as this color to ourselves
 		ANONYMOUS_HUE: 100
 		ANONYMOUS_HUE: 100