mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-01 11:40:25 +00:00
fix for "can't delete todos"
This commit is contained in:
parent
bb4fa87f4a
commit
69e577818a
1 changed files with 17 additions and 5 deletions
|
|
@ -155,8 +155,16 @@ ready (model) ->
|
|||
|
||||
exports.del = (e, el) ->
|
||||
# Derby extends model.at to support creation from DOM nodes
|
||||
task = model.at(e.target)
|
||||
|
||||
#task = model.at(e.target)
|
||||
# FIXME normally that would work, and we'd later simply call `user.del task` (instead of that 4-liner down there)
|
||||
# however, see https://github.com/lefnire/habitrpg/pull/226#discussion_r2810391
|
||||
|
||||
id = $(e.target).parents('li.task').attr('data-id')
|
||||
return unless id?
|
||||
|
||||
task = user.at "tasks.#{id}"
|
||||
type = task.get('type')
|
||||
|
||||
history = task.get('history')
|
||||
if history and history.length>2
|
||||
# prevent delete-and-recreate hack on red tasks
|
||||
|
|
@ -166,7 +174,7 @@ ready (model) ->
|
|||
return # Cancel. Don't delete, don't hurt user
|
||||
else
|
||||
task.set('type','habit') # hack to make sure it hits HP, instead of performing "undo checkbox"
|
||||
scoring.score(task.get('id'), direction:'down')
|
||||
scoring.score(id, direction:'down')
|
||||
|
||||
# prevent accidently deleting long-standing tasks
|
||||
else
|
||||
|
|
@ -176,8 +184,12 @@ ready (model) ->
|
|||
#TODO bug where I have to delete from _users.tasks AND _{type}List,
|
||||
# fix when query subscriptions implemented properly
|
||||
$('[rel=tooltip]').tooltip('hide')
|
||||
user.del('tasks.'+task.get('id'))
|
||||
task.remove()
|
||||
|
||||
ids = user.get("#{type}Ids")
|
||||
ids.splice(ids.indexOf(id),1)
|
||||
user.del('tasks.'+id)
|
||||
user.set("#{type}Ids", ids)
|
||||
|
||||
|
||||
exports.clearCompleted = (e, el) ->
|
||||
todoIds = user.get('todoIds')
|
||||
|
|
|
|||
Loading…
Reference in a new issue