Prevent slowdown on firefox when deleting lots of shape messages
By creating a new collection called WhiteboardCleanStatus which is used to alert the clients that the server is cleaning shapes. When shapes are being cleaned they are not drawn and so things don't slow down on firefox or chrome
This commit is contained in:
parent
9261791fc9
commit
6b04a86e7e
@ -26,6 +26,9 @@ Template.slide.rendered = ->
|
|||||||
wpm.scale(adjustedDimensions.width, adjustedDimensions.height)
|
wpm.scale(adjustedDimensions.width, adjustedDimensions.height)
|
||||||
|
|
||||||
@manuallyDisplayShapes = ->
|
@manuallyDisplayShapes = ->
|
||||||
|
|
||||||
|
return if Meteor.WhiteboardCleanStatus.findOne({in_progress: true})?
|
||||||
|
|
||||||
currentSlide = getCurrentSlideDoc()
|
currentSlide = getCurrentSlideDoc()
|
||||||
wpm = @whiteboardPaperModel
|
wpm = @whiteboardPaperModel
|
||||||
shapes = Meteor.Shapes.find({whiteboardId: currentSlide?.slide?.id}).fetch()
|
shapes = Meteor.Shapes.find({whiteboardId: currentSlide?.slide?.id}).fetch()
|
||||||
|
@ -4,3 +4,5 @@ Meteor.Meetings = new Meteor.Collection("meetings")
|
|||||||
Meteor.Presentations = new Meteor.Collection("presentations")
|
Meteor.Presentations = new Meteor.Collection("presentations")
|
||||||
Meteor.Shapes = new Meteor.Collection("shapes")
|
Meteor.Shapes = new Meteor.Collection("shapes")
|
||||||
Meteor.Slides = new Meteor.Collection("slides")
|
Meteor.Slides = new Meteor.Collection("slides")
|
||||||
|
|
||||||
|
Meteor.WhiteboardCleanStatus = new Meteor.Collection("whiteboard-clean-status")
|
@ -55,6 +55,7 @@
|
|||||||
Meteor.subscribe 'meetings', meetingId, onReady: =>
|
Meteor.subscribe 'meetings', meetingId, onReady: =>
|
||||||
Meteor.subscribe 'presentations', meetingId, onReady: =>
|
Meteor.subscribe 'presentations', meetingId, onReady: =>
|
||||||
Meteor.subscribe 'users', meetingId, userId, authToken, onError: onErrorFunction, onReady: =>
|
Meteor.subscribe 'users', meetingId, userId, authToken, onError: onErrorFunction, onReady: =>
|
||||||
|
Meteor.subscribe 'whiteboard-clean-status', meetingId, onReady: =>
|
||||||
# done subscribing
|
# done subscribing
|
||||||
onLoadComplete()
|
onLoadComplete()
|
||||||
|
|
||||||
|
@ -67,15 +67,13 @@
|
|||||||
@removeAllShapesFromSlide = (meetingId, whiteboardId) ->
|
@removeAllShapesFromSlide = (meetingId, whiteboardId) ->
|
||||||
Meteor.log.info "removeAllShapesFromSlide__" + whiteboardId
|
Meteor.log.info "removeAllShapesFromSlide__" + whiteboardId
|
||||||
if meetingId? and whiteboardId? and Meteor.Shapes.find({meetingId: meetingId, whiteboardId: whiteboardId})?
|
if meetingId? and whiteboardId? and Meteor.Shapes.find({meetingId: meetingId, whiteboardId: whiteboardId})?
|
||||||
shapesOnSlide = Meteor.Shapes.find({meetingId: meetingId, whiteboardId: whiteboardId}).fetch()
|
Meteor.Shapes.remove {meetingId: meetingId, whiteboardId: whiteboardId}, ->
|
||||||
Meteor.log.info "number of shapes:" + shapesOnSlide.length
|
Meteor.log.info "clearing all shapes from slide"
|
||||||
for s in shapesOnSlide
|
|
||||||
Meteor.log.info "shape=" + s.shape.id
|
# After shapes are cleared, wait 1 second and set cleaning off
|
||||||
id = Meteor.Shapes.findOne({meetingId: meetingId, whiteboardId: whiteboardId, "shape.id": s.shape.id})
|
Meteor.setTimeout ->
|
||||||
if id?
|
Meteor.WhiteboardCleanStatus.update({meetingId: meetingId}, {$set: {in_progress: false}})
|
||||||
Meteor.Shapes.remove(id._id)
|
, 1000
|
||||||
Meteor.log.info "----removed shape[" + s.shape.id + "] from " + whiteboardId
|
|
||||||
Meteor.log.info "remaining shapes on the slide:" + Meteor.Shapes.find({meetingId: meetingId, whiteboardId: whiteboardId}).fetch().length
|
|
||||||
|
|
||||||
@removeShapeFromSlide = (meetingId, whiteboardId, shapeId) ->
|
@removeShapeFromSlide = (meetingId, whiteboardId, shapeId) ->
|
||||||
shapeToRemove = Meteor.Shapes.findOne({meetingId: meetingId, whiteboardId: whiteboardId, "shape.id": shapeId})
|
shapeToRemove = Meteor.Shapes.findOne({meetingId: meetingId, whiteboardId: whiteboardId, "shape.id": shapeId})
|
||||||
@ -88,9 +86,13 @@
|
|||||||
# called on server start and meeting end
|
# called on server start and meeting end
|
||||||
@clearShapesCollection = (meetingId) ->
|
@clearShapesCollection = (meetingId) ->
|
||||||
if meetingId?
|
if meetingId?
|
||||||
Meteor.Shapes.remove({meetingId: meetingId}, Meteor.log.info "cleared Shapes Collection (meetingId: #{meetingId}!")
|
Meteor.Shapes.remove {}, ->
|
||||||
|
Meteor.log.info "cleared Shapes Collection (meetingId: #{meetingId}!"
|
||||||
|
Meteor.WhiteboardCleanStatus.update({meetingId: meetingId}, {$set: {in_progress: false}})
|
||||||
else
|
else
|
||||||
Meteor.Shapes.remove({}, Meteor.log.info "cleared Shapes Collection (all meetings)!")
|
Meteor.Shapes.remove {}, ->
|
||||||
|
Meteor.log.info "cleared Shapes Collection (all meetings)!"
|
||||||
|
Meteor.WhiteboardCleanStatus.update({meetingId: meetingId}, {$set: {in_progress: false}})
|
||||||
|
|
||||||
# --------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------------
|
||||||
# end Private methods on server
|
# end Private methods on server
|
||||||
|
@ -70,3 +70,7 @@ Meteor.publish 'meetings', (meetingId) ->
|
|||||||
Meteor.publish 'presentations', (meetingId) ->
|
Meteor.publish 'presentations', (meetingId) ->
|
||||||
Meteor.log.info "publishing presentations for #{meetingId}"
|
Meteor.log.info "publishing presentations for #{meetingId}"
|
||||||
Meteor.Presentations.find({meetingId: meetingId})
|
Meteor.Presentations.find({meetingId: meetingId})
|
||||||
|
|
||||||
|
Meteor.publish 'whiteboard-clean-status', (meetingId) ->
|
||||||
|
Meteor.log.info "whiteboard clean status #{meetingId}"
|
||||||
|
Meteor.WhiteboardCleanStatus.find({meetingId: meetingId})
|
||||||
|
@ -219,6 +219,11 @@ class Meteor.RedisPubSub
|
|||||||
return
|
return
|
||||||
|
|
||||||
if message.header.name is "get_whiteboard_shapes_reply" and message.payload.requester_id is "nodeJSapp"
|
if message.header.name is "get_whiteboard_shapes_reply" and message.payload.requester_id is "nodeJSapp"
|
||||||
|
|
||||||
|
# Create a whiteboard clean status or find one for the current meeting
|
||||||
|
if not Meteor.WhiteboardCleanStatus.findOne({meetingId: meetingId})?
|
||||||
|
Meteor.WhiteboardCleanStatus.insert({meetingId: meetingId, in_progress: false})
|
||||||
|
|
||||||
for shape in message.payload.shapes
|
for shape in message.payload.shapes
|
||||||
whiteboardId = shape.wb_id
|
whiteboardId = shape.wb_id
|
||||||
addShapeToCollection meetingId, whiteboardId, shape
|
addShapeToCollection meetingId, whiteboardId, shape
|
||||||
@ -238,6 +243,7 @@ class Meteor.RedisPubSub
|
|||||||
|
|
||||||
if message.header.name is "whiteboard_cleared_message"
|
if message.header.name is "whiteboard_cleared_message"
|
||||||
whiteboardId = message.payload.whiteboard_id
|
whiteboardId = message.payload.whiteboard_id
|
||||||
|
Meteor.WhiteboardCleanStatus.update({meetingId: meetingId}, {$set: {'in_progress': true}})
|
||||||
removeAllShapesFromSlide meetingId, whiteboardId
|
removeAllShapesFromSlide meetingId, whiteboardId
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ Meteor.startup ->
|
|||||||
Meteor.log.info "server start"
|
Meteor.log.info "server start"
|
||||||
|
|
||||||
#remove all data
|
#remove all data
|
||||||
|
Meteor.WhiteboardCleanStatus.remove({})
|
||||||
clearUsersCollection()
|
clearUsersCollection()
|
||||||
clearChatCollection()
|
clearChatCollection()
|
||||||
clearMeetingsCollection()
|
clearMeetingsCollection()
|
||||||
|
Loading…
Reference in New Issue
Block a user