Browse code
Bugs squashed
- Fix CPU usage in uwsgi (0.1s sleep)
- Fix user list not updating on post
Showing 2 changed files
... | ... |
@@ -175,8 +175,8 @@ def active(): |
175 | 175 |
data = get_event() |
176 | 176 |
ev = ServerSentEvent(id, "active", data).encode() |
177 | 177 |
yield ev |
178 |
- time.sleep(0.1) |
|
179 | 178 |
t0 = t1 |
179 |
+ time.sleep(0.1) |
|
180 | 180 |
except GeneratorExit: |
181 | 181 |
print 'GeneratorExit!' |
182 | 182 |
response = flask.Response(stream_with_context(poll()), mimetype="text/event-stream") |
... | ... |
@@ -267,9 +267,10 @@ marrowApp.controller('UserSettingCtrl', function ($scope,$http,$location) { |
267 | 267 |
marrowApp.controller('SidebarCtrl', function ($scope,$http,$location,$route, $window, UserService) { |
268 | 268 |
eventSource = new EventSource("/api/user/active"); |
269 | 269 |
$scope.activeUsers = Object.create(null); |
270 |
+ $scope.activeUsers.users = [] |
|
270 | 271 |
eventSource.addEventListener("active", function(event) { |
271 |
- console.log(event); |
|
272 |
- $scope.activeUsers.users = JSON.parse(event.data).data; |
|
272 |
+ var users = $scope.activeUsers.users; |
|
273 |
+ Array.prototype.splice.apply(users, [0, users.length].concat(JSON.parse(event.data).data)); |
|
273 | 274 |
}); |
274 | 275 |
|
275 | 276 |
$scope.subscriptions = function() { |