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
|
return
|
||||||
|
|
||||||
# check if active task is closed
|
# check if active task is closed
|
||||||
currentTask = App.TaskManager.get(key)
|
currentTask = App.TaskManager.get(key)
|
||||||
tasks = App.TaskManager.all()
|
tasks = App.TaskManager.all()
|
||||||
active_is_closed = false
|
activeIsClosed = false
|
||||||
for task in tasks
|
for task in tasks
|
||||||
if currentTask.active && task.key is key
|
if currentTask.active && task.key is key
|
||||||
active_is_closed = true
|
activeIsClosed = true
|
||||||
|
|
||||||
# remove task
|
# remove task
|
||||||
App.TaskManager.remove(key, false)
|
App.TaskManager.remove(key, false)
|
||||||
|
@ -110,7 +110,7 @@ class App.TaskbarWidget extends App.Controller
|
||||||
$(e.target).closest('.task').remove()
|
$(e.target).closest('.task').remove()
|
||||||
|
|
||||||
# if we do not need to move to an other task
|
# if we do not need to move to an other task
|
||||||
return if !active_is_closed
|
return if !activeIsClosed
|
||||||
|
|
||||||
# get new task url
|
# get new task url
|
||||||
nextTaskUrl = App.TaskManager.nextTaskUrl()
|
nextTaskUrl = App.TaskManager.nextTaskUrl()
|
||||||
|
|
|
@ -181,7 +181,7 @@ class _taskManagerSingleton extends App.Controller
|
||||||
if task.key isnt params.key
|
if task.key isnt params.key
|
||||||
if task.active
|
if task.active
|
||||||
task.active = false
|
task.active = false
|
||||||
@taskUpdate(task)
|
@taskUpdate(task, true)
|
||||||
else
|
else
|
||||||
changed = false
|
changed = false
|
||||||
if !task.active
|
if !task.active
|
||||||
|
@ -191,13 +191,22 @@ class _taskManagerSingleton extends App.Controller
|
||||||
changed = true
|
changed = true
|
||||||
task.notify = false
|
task.notify = false
|
||||||
if changed
|
if changed
|
||||||
@taskUpdate(task)
|
@taskUpdate(task, true)
|
||||||
|
|
||||||
# start worker for task if not exists
|
# start worker for task if not exists
|
||||||
@startController(params)
|
@startController(params)
|
||||||
|
|
||||||
|
# set active state
|
||||||
if !params.init
|
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) =>
|
startController: (params) =>
|
||||||
|
|
||||||
|
@ -279,7 +288,12 @@ class _taskManagerSingleton extends App.Controller
|
||||||
throw "No such task with '#{key}' to update"
|
throw "No such task with '#{key}' to update"
|
||||||
for item, value of params
|
for item, value of params
|
||||||
task[item] = value
|
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 task certain task from tasks
|
||||||
remove: (key, rerender) =>
|
remove: (key, rerender) =>
|
||||||
|
@ -336,7 +350,7 @@ class _taskManagerSingleton extends App.Controller
|
||||||
prio++
|
prio++
|
||||||
if task.prio isnt prio
|
if task.prio isnt prio
|
||||||
task.prio = prio
|
task.prio = prio
|
||||||
@taskUpdate(task)
|
@taskUpdate(task, true)
|
||||||
|
|
||||||
# release one task
|
# release one task
|
||||||
release: (key) =>
|
release: (key) =>
|
||||||
|
@ -396,10 +410,11 @@ class _taskManagerSingleton extends App.Controller
|
||||||
@TaskbarIdInt = Math.floor( Math.random() * 99999999 )
|
@TaskbarIdInt = Math.floor( Math.random() * 99999999 )
|
||||||
@TaskbarIdInt
|
@TaskbarIdInt
|
||||||
|
|
||||||
taskUpdate: (task) ->
|
taskUpdate: (task, mute = false) ->
|
||||||
#@log 'notice', "UPDATE task #{task.id}", task
|
@log 'debug', 'UPDATE task', task, mute
|
||||||
@tasksToUpdate[ task.key ] = 'toUpdate'
|
@tasksToUpdate[ task.key ] = 'toUpdate'
|
||||||
@metaTaskUpdate()
|
if !mute
|
||||||
|
@metaTaskUpdate()
|
||||||
|
|
||||||
taskUpdateLoop: =>
|
taskUpdateLoop: =>
|
||||||
return if @offlineModus
|
return if @offlineModus
|
||||||
|
|
Loading…
Reference in a new issue