track changes for anonymous users

This commit is contained in:
James Allen 2017-01-12 13:29:57 +01:00
parent 0d02b860d9
commit f9b8ada215
3 changed files with 9 additions and 6 deletions

View file

@ -20,6 +20,8 @@ module.exports = TrackChangesController =
RangesManager.getAllChangesUsers project_id, (error, users) ->
return next(error) if error?
users = (UserInfoController.formatPersonalInfo(user) for user in users)
# Get rid of any anonymous/deleted user objects
users = users.filter (u) -> u?.id?
res.json users
acceptChange: (req, res, next) ->

View file

@ -93,7 +93,7 @@ define [
setTrackChanges: (value) ->
if value
@$scope.sharejsDoc?.track_changes_as = window.user.id
@$scope.sharejsDoc?.track_changes_as = window.user.id or "anonymous"
else
@$scope.sharejsDoc?.track_changes_as = null
@ -230,10 +230,6 @@ define [
if marker.clazz.match("track-changes")
console.error "Orphaned ace marker", marker
applyChange: (delta, metadata) ->
op = @_aceChangeToShareJs(delta)
@rangesTracker.applyOp(op, metadata)
updateFocus: () ->
selection = @editor.getSelectionRange()
cursor_offset = @_aceRangeToShareJs(selection.start)

View file

@ -346,8 +346,13 @@ define [
.success (users) ->
_refreshingRangeUsers = false
$scope.users = {}
# Always include ourself, since if we submit an op, we might need to display info
# about it locally before it has been flushed through the server
if ide.$scope.user?.id?
$scope.users[ide.$scope.user.id] = formatUser(ide.$scope.user)
for user in users
$scope.users[user.id] = formatUser(user)
if user.id?
$scope.users[user.id] = formatUser(user)
.error () ->
_refreshingRangeUsers = false