Reduced amount of re-render tasks (set is-active class at runtime without re-rendering complete task list).
This commit is contained in:
parent
2c03e4a8e6
commit
eceb1d3894
2 changed files with 28 additions and 13 deletions
|
@ -97,12 +97,12 @@ class App.TaskbarWidget extends App.Controller
|
|||
return
|
||||
|
||||
# check if active task is closed
|
||||
currentTask = App.TaskManager.get(key)
|
||||
tasks = App.TaskManager.all()
|
||||
active_is_closed = false
|
||||
currentTask = App.TaskManager.get(key)
|
||||
tasks = App.TaskManager.all()
|
||||
activeIsClosed = false
|
||||
for task in tasks
|
||||
if currentTask.active && task.key is key
|
||||
active_is_closed = true
|
||||
activeIsClosed = true
|
||||
|
||||
# remove task
|
||||
App.TaskManager.remove(key, false)
|
||||
|
@ -110,7 +110,7 @@ class App.TaskbarWidget extends App.Controller
|
|||
$(e.target).closest('.task').remove()
|
||||
|
||||
# if we do not need to move to an other task
|
||||
return if !active_is_closed
|
||||
return if !activeIsClosed
|
||||
|
||||
# get new task url
|
||||
nextTaskUrl = App.TaskManager.nextTaskUrl()
|
||||
|
|
|
@ -181,7 +181,7 @@ class _taskManagerSingleton extends App.Controller
|
|||
if task.key isnt params.key
|
||||
if task.active
|
||||
task.active = false
|
||||
@taskUpdate(task)
|
||||
@taskUpdate(task, true)
|
||||
else
|
||||
changed = false
|
||||
if !task.active
|
||||
|
@ -191,13 +191,22 @@ class _taskManagerSingleton extends App.Controller
|
|||
changed = true
|
||||
task.notify = false
|
||||
if changed
|
||||
@taskUpdate(task)
|
||||
@taskUpdate(task, true)
|
||||
|
||||
# start worker for task if not exists
|
||||
@startController(params)
|
||||
|
||||
# set active state
|
||||
if !params.init
|
||||
@metaTaskUpdate()
|
||||
$('.nav-tab.task').each( (_index, element) =>
|
||||
localElement = $(element)
|
||||
key = localElement.data('key')
|
||||
task = @get(key)
|
||||
if task.active
|
||||
localElement.addClass('is-active')
|
||||
else
|
||||
localElement.removeClass('is-active')
|
||||
)
|
||||
|
||||
startController: (params) =>
|
||||
|
||||
|
@ -279,7 +288,12 @@ class _taskManagerSingleton extends App.Controller
|
|||
throw "No such task with '#{key}' to update"
|
||||
for item, value of params
|
||||
task[item] = value
|
||||
@taskUpdate(task)
|
||||
|
||||
# mute rerender on state attribute updates
|
||||
mute = false
|
||||
if Object.keys(params).length is 1 && params.state
|
||||
mute = true
|
||||
@taskUpdate(task, mute)
|
||||
|
||||
# remove task certain task from tasks
|
||||
remove: (key, rerender) =>
|
||||
|
@ -336,7 +350,7 @@ class _taskManagerSingleton extends App.Controller
|
|||
prio++
|
||||
if task.prio isnt prio
|
||||
task.prio = prio
|
||||
@taskUpdate(task)
|
||||
@taskUpdate(task, true)
|
||||
|
||||
# release one task
|
||||
release: (key) =>
|
||||
|
@ -396,10 +410,11 @@ class _taskManagerSingleton extends App.Controller
|
|||
@TaskbarIdInt = Math.floor( Math.random() * 99999999 )
|
||||
@TaskbarIdInt
|
||||
|
||||
taskUpdate: (task) ->
|
||||
#@log 'notice', "UPDATE task #{task.id}", task
|
||||
taskUpdate: (task, mute = false) ->
|
||||
@log 'debug', 'UPDATE task', task, mute
|
||||
@tasksToUpdate[ task.key ] = 'toUpdate'
|
||||
@metaTaskUpdate()
|
||||
if !mute
|
||||
@metaTaskUpdate()
|
||||
|
||||
taskUpdateLoop: =>
|
||||
return if @offlineModus
|
||||
|
|
Loading…
Reference in a new issue