mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Don't show resolved comments highlighted in the text
This commit is contained in:
parent
32fb317820
commit
12e1b2bc3d
3 changed files with 29 additions and 23 deletions
|
@ -179,15 +179,12 @@ define [
|
||||||
removeCommentId: (comment_id) ->
|
removeCommentId: (comment_id) ->
|
||||||
@rangesTracker.removeCommentId(comment_id)
|
@rangesTracker.removeCommentId(comment_id)
|
||||||
|
|
||||||
RESOLVED_THREADS: {}
|
|
||||||
resolveCommentByThreadId: (thread_id) ->
|
resolveCommentByThreadId: (thread_id) ->
|
||||||
@RESOLVED_THREADS[thread_id] = true
|
|
||||||
for comment in @rangesTracker?.comments or []
|
for comment in @rangesTracker?.comments or []
|
||||||
if comment.op.t == thread_id
|
if comment.op.t == thread_id
|
||||||
@_onCommentRemoved(comment)
|
@_onCommentRemoved(comment)
|
||||||
|
|
||||||
unresolveCommentByThreadId: (thread_id) ->
|
unresolveCommentByThreadId: (thread_id) ->
|
||||||
@RESOLVED_THREADS[thread_id] = false
|
|
||||||
for comment in @rangesTracker?.comments or []
|
for comment in @rangesTracker?.comments or []
|
||||||
if comment.op.t == thread_id
|
if comment.op.t == thread_id
|
||||||
@_onCommentAdded(comment)
|
@_onCommentAdded(comment)
|
||||||
|
@ -332,7 +329,7 @@ define [
|
||||||
@broadcastChange()
|
@broadcastChange()
|
||||||
|
|
||||||
_onCommentAdded: (comment) ->
|
_onCommentAdded: (comment) ->
|
||||||
if @RESOLVED_THREADS[comment.op.t]
|
if @rangesTracker.resolvedThreadIds[comment.op.t]
|
||||||
# Comment is resolved so shouldn't be displayed.
|
# Comment is resolved so shouldn't be displayed.
|
||||||
return
|
return
|
||||||
if !@changeIdToMarkerIdMap[comment.id]?
|
if !@changeIdToMarkerIdMap[comment.id]?
|
||||||
|
|
|
@ -35,7 +35,7 @@ load = (EventEmitter) ->
|
||||||
# * Inserts by another user will not combine with inserts by the first user. If they are in the
|
# * Inserts by another user will not combine with inserts by the first user. If they are in the
|
||||||
# middle of a previous insert by the first user, the original insert will be split into two.
|
# middle of a previous insert by the first user, the original insert will be split into two.
|
||||||
constructor: (@changes = [], @comments = []) ->
|
constructor: (@changes = [], @comments = []) ->
|
||||||
@setIdSeed("")
|
@setIdSeed(RangesTracker.generateIdSeed())
|
||||||
|
|
||||||
getIdSeed: () ->
|
getIdSeed: () ->
|
||||||
return @id_seed
|
return @id_seed
|
||||||
|
@ -44,6 +44,19 @@ load = (EventEmitter) ->
|
||||||
@id_seed = seed
|
@id_seed = seed
|
||||||
@id_increment = 0
|
@id_increment = 0
|
||||||
|
|
||||||
|
@generateIdSeed: () ->
|
||||||
|
# Generate a the first 18 characters of Mongo ObjectId, leaving 6 for the increment part
|
||||||
|
# Reference: https://github.com/dreampulse/ObjectId.js/blob/master/src/main/javascript/Objectid.js
|
||||||
|
pid = Math.floor(Math.random() * (32767)).toString(16)
|
||||||
|
machine = Math.floor(Math.random() * (16777216)).toString(16)
|
||||||
|
timestamp = Math.floor(new Date().valueOf() / 1000).toString(16)
|
||||||
|
return '00000000'.substr(0, 8 - timestamp.length) + timestamp +
|
||||||
|
'000000'.substr(0, 6 - machine.length) + machine +
|
||||||
|
'0000'.substr(0, 4 - pid.length) + pid
|
||||||
|
|
||||||
|
@generateId: () ->
|
||||||
|
@generateId() + "000001"
|
||||||
|
|
||||||
newId: () ->
|
newId: () ->
|
||||||
@id_increment++
|
@id_increment++
|
||||||
increment = @id_increment.toString(16)
|
increment = @id_increment.toString(16)
|
||||||
|
|
|
@ -11,7 +11,7 @@ define [
|
||||||
CUR_FILE : "cur_file"
|
CUR_FILE : "cur_file"
|
||||||
OVERVIEW : "overview"
|
OVERVIEW : "overview"
|
||||||
|
|
||||||
$scope.reviewPanel =
|
window.reviewPanel = $scope.reviewPanel =
|
||||||
entries: {}
|
entries: {}
|
||||||
hasEntries: false
|
hasEntries: false
|
||||||
subView: $scope.SubViews.CUR_FILE
|
subView: $scope.SubViews.CUR_FILE
|
||||||
|
@ -53,13 +53,16 @@ define [
|
||||||
_onCommentReopened(thread_id)
|
_onCommentReopened(thread_id)
|
||||||
|
|
||||||
rangesTrackers = {}
|
rangesTrackers = {}
|
||||||
|
resolvedThreadIds = {}
|
||||||
|
|
||||||
getDocEntries = (doc_id) ->
|
getDocEntries = (doc_id) ->
|
||||||
$scope.reviewPanel.entries[doc_id] ?= {}
|
$scope.reviewPanel.entries[doc_id] ?= {}
|
||||||
return $scope.reviewPanel.entries[doc_id]
|
return $scope.reviewPanel.entries[doc_id]
|
||||||
|
|
||||||
getChangeTracker = (doc_id) ->
|
getChangeTracker = (doc_id) ->
|
||||||
rangesTrackers[doc_id] ?= new RangesTracker()
|
if !rangesTrackers[doc_id]?
|
||||||
|
rangesTrackers[doc_id] = new RangesTracker()
|
||||||
|
rangesTrackers[doc_id].resolvedThreadIds = resolvedThreadIds
|
||||||
return rangesTrackers[doc_id]
|
return rangesTrackers[doc_id]
|
||||||
|
|
||||||
scrollbar = {}
|
scrollbar = {}
|
||||||
|
@ -94,6 +97,7 @@ define [
|
||||||
# The open doc range tracker is kept up to date in real-time so
|
# The open doc range tracker is kept up to date in real-time so
|
||||||
# replace any outdated info with this
|
# replace any outdated info with this
|
||||||
rangesTrackers[doc.doc_id] = doc.ranges
|
rangesTrackers[doc.doc_id] = doc.ranges
|
||||||
|
rangesTrackers[doc.doc_id].resolvedThreadIds = resolvedThreadIds
|
||||||
$scope.reviewPanel.rangesTracker = rangesTrackers[doc.doc_id]
|
$scope.reviewPanel.rangesTracker = rangesTrackers[doc.doc_id]
|
||||||
if old_doc?
|
if old_doc?
|
||||||
old_doc.off "flipped_pending_to_inflight"
|
old_doc.off "flipped_pending_to_inflight"
|
||||||
|
@ -113,22 +117,9 @@ define [
|
||||||
$scope.$broadcast "review-panel:toggle"
|
$scope.$broadcast "review-panel:toggle"
|
||||||
$scope.$broadcast "review-panel:layout"
|
$scope.$broadcast "review-panel:layout"
|
||||||
|
|
||||||
generatePartialMongoId = () ->
|
|
||||||
# Generate a the first 18 characters of Mongo ObjectId, leaving 6 for the increment part
|
|
||||||
# Reference: https://github.com/dreampulse/ObjectId.js/blob/master/src/main/javascript/Objectid.js
|
|
||||||
pid = Math.floor(Math.random() * (32767)).toString(16)
|
|
||||||
machine = Math.floor(Math.random() * (16777216)).toString(16)
|
|
||||||
timestamp = Math.floor(new Date().valueOf() / 1000).toString(16)
|
|
||||||
return '00000000'.substr(0, 8 - timestamp.length) + timestamp +
|
|
||||||
'000000'.substr(0, 6 - machine.length) + machine +
|
|
||||||
'0000'.substr(0, 4 - pid.length) + pid
|
|
||||||
|
|
||||||
generateFullMongoId = () ->
|
|
||||||
return generatePartialMongoId() + "000000"
|
|
||||||
|
|
||||||
regenerateTrackChangesId = (doc) ->
|
regenerateTrackChangesId = (doc) ->
|
||||||
old_id = getChangeTracker(doc.doc_id).getIdSeed()
|
old_id = getChangeTracker(doc.doc_id).getIdSeed()
|
||||||
new_id = generatePartialMongoId()
|
new_id = RangesTracker.generateIdSeed()
|
||||||
getChangeTracker(doc.doc_id).setIdSeed(new_id)
|
getChangeTracker(doc.doc_id).setIdSeed(new_id)
|
||||||
doc.setTrackChangesIdSeeds({pending: new_id, inflight: old_id})
|
doc.setTrackChangesIdSeeds({pending: new_id, inflight: old_id})
|
||||||
|
|
||||||
|
@ -247,7 +238,7 @@ define [
|
||||||
$scope.$broadcast "review-panel:layout"
|
$scope.$broadcast "review-panel:layout"
|
||||||
|
|
||||||
$scope.submitNewComment = (content) ->
|
$scope.submitNewComment = (content) ->
|
||||||
thread_id = generateFullMongoId()
|
thread_id = RangesTracker.generateId()
|
||||||
$scope.$broadcast "comment:add", thread_id
|
$scope.$broadcast "comment:add", thread_id
|
||||||
$http.post("/project/#{$scope.project_id}/thread/#{thread_id}/messages", {content, _csrf: window.csrfToken})
|
$http.post("/project/#{$scope.project_id}/thread/#{thread_id}/messages", {content, _csrf: window.csrfToken})
|
||||||
.error (error) ->
|
.error (error) ->
|
||||||
|
@ -297,6 +288,7 @@ define [
|
||||||
thread.resolved = true
|
thread.resolved = true
|
||||||
thread.resolved_by_user = formatUser(user)
|
thread.resolved_by_user = formatUser(user)
|
||||||
thread.resolved_at = new Date()
|
thread.resolved_at = new Date()
|
||||||
|
resolvedThreadIds[thread_id] = true
|
||||||
$scope.$broadcast "comment:resolve_thread", thread_id
|
$scope.$broadcast "comment:resolve_thread", thread_id
|
||||||
|
|
||||||
_onCommentReopened = (thread_id) ->
|
_onCommentReopened = (thread_id) ->
|
||||||
|
@ -304,6 +296,7 @@ define [
|
||||||
delete thread.resolved
|
delete thread.resolved
|
||||||
delete thread.resolved_by_user
|
delete thread.resolved_by_user
|
||||||
delete thread.resolved_at
|
delete thread.resolved_at
|
||||||
|
delete resolvedThreadIds[thread_id]
|
||||||
$scope.$broadcast "comment:unresolve_thread", thread_id
|
$scope.$broadcast "comment:unresolve_thread", thread_id
|
||||||
|
|
||||||
$scope.deleteComment = (entry_id) ->
|
$scope.deleteComment = (entry_id) ->
|
||||||
|
@ -351,12 +344,15 @@ define [
|
||||||
refreshThreads = () ->
|
refreshThreads = () ->
|
||||||
$http.get "/project/#{$scope.project_id}/threads"
|
$http.get "/project/#{$scope.project_id}/threads"
|
||||||
.success (threads) ->
|
.success (threads) ->
|
||||||
|
for thread_id, _ of resolvedThreadIds
|
||||||
|
delete resolvedThreadIds[thread_id]
|
||||||
for thread_id, thread of threads
|
for thread_id, thread of threads
|
||||||
for comment in thread.messages
|
for comment in thread.messages
|
||||||
formatComment(comment)
|
formatComment(comment)
|
||||||
if thread.resolved_by_user?
|
if thread.resolved_by_user?
|
||||||
$scope.$broadcast "comment:resolve_thread", thread_id
|
$scope.$broadcast "comment:resolve_thread", thread_id
|
||||||
thread.resolved_by_user = formatUser(thread.resolved_by_user)
|
thread.resolved_by_user = formatUser(thread.resolved_by_user)
|
||||||
|
resolvedThreadIds[thread_id] = true
|
||||||
$scope.reviewPanel.commentThreads = threads
|
$scope.reviewPanel.commentThreads = threads
|
||||||
|
|
||||||
refreshThreads()
|
refreshThreads()
|
||||||
|
|
Loading…
Reference in a new issue