mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-02 04:00:36 +00:00
temporary fix to #891, model.id() isn't working for some reason.
Provide custom `helpers.uuid()` function until I can figure this out
This commit is contained in:
parent
9b1bcb8367
commit
d055f68c5b
3 changed files with 18 additions and 19 deletions
|
|
@ -2,6 +2,12 @@ moment = require 'moment'
|
|||
_ = require 'underscore'
|
||||
algos = require './algos'
|
||||
|
||||
uuid = ->
|
||||
"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace /[xy]/g, (c) ->
|
||||
r = Math.random() * 16 | 0
|
||||
v = (if c is "x" then r else (r & 0x3 | 0x8))
|
||||
v.toString 16
|
||||
|
||||
# Absolute diff between two dates
|
||||
daysBetween = (yesterday, now, dayStart) ->
|
||||
#sanity-check reset-time (is it 24h time?)
|
||||
|
|
@ -162,4 +168,4 @@ viewHelpers = (view) ->
|
|||
return false unless messages?.length > 0
|
||||
messages && messages[0].id != lastMessageSeen
|
||||
|
||||
module.exports = { viewHelpers, removeWhitespace, randomVal, daysBetween, dayMapping, username }
|
||||
module.exports = { viewHelpers, removeWhitespace, randomVal, daysBetween, dayMapping, username, uuid }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
_ = require('underscore')
|
||||
helpers = require './helpers'
|
||||
|
||||
partyUnsubscribe = (model, cb) ->
|
||||
if window?
|
||||
|
|
@ -165,7 +166,7 @@ module.exports.app = (appExports, model, app) ->
|
|||
# Check for non-whitespace characters
|
||||
return unless /\S/.test text
|
||||
chat.unshift
|
||||
id: model.id()
|
||||
id: helpers.uuid() #FIXME model.id() isn't working, temporary solution https://github.com/lefnire/habitrpg/issues/891#issuecomment-17458776
|
||||
uuid: user.get('id')
|
||||
contributor: user.get('backer.contributor')
|
||||
npc: user.get('backer.npc')
|
||||
|
|
|
|||
|
|
@ -9,32 +9,24 @@ module.exports.app = (appExports, model) ->
|
|||
|
||||
appExports.addTask = (e, el, next) ->
|
||||
type = $(el).attr('data-task-type')
|
||||
list = model.at "_#{type}List"
|
||||
newModel = model.at('_new' + type.charAt(0).toUpperCase() + type.slice(1))
|
||||
text = newModel.get()
|
||||
# Don't add a blank task; 20/02/13 Added a check for undefined value, more at issue #463 -lancemanfv
|
||||
if /^(\s)*$/.test(text) || text == undefined
|
||||
console.error "Task text entered was an empty string."
|
||||
return
|
||||
return if /^(\s)*$/.test(text) || text == undefined
|
||||
|
||||
newModel.set ''
|
||||
#FIXME model.id() isn't working, temporary solution https://github.com/lefnire/habitrpg/issues/891#issuecomment-17458776
|
||||
newTask = {id: helpers.uuid(), type: type, text: text, notes: '', value: 0}
|
||||
switch type
|
||||
|
||||
when 'habit'
|
||||
list.unshift {type: type, text: text, notes: '', value: 0, up: true, down: true}
|
||||
|
||||
newTask = _.defaults {up: true, down: true}, newTask
|
||||
when 'reward'
|
||||
list.unshift {type: type, text: text, notes: '', value: 20 }
|
||||
|
||||
newTask = _.defaults {value: 20}, newTask
|
||||
when 'daily'
|
||||
list.unshift {type: type, text: text, notes: '', value: 0, repeat:{su:true,m:true,t:true,w:true,th:true,f:true,s:true}, completed: false }
|
||||
|
||||
newTask = _.defaults {repeat:{su:true,m:true,t:true,w:true,th:true,f:true,s:true}, completed: false }, newTask
|
||||
when 'todo'
|
||||
list.unshift {type: type, text: text, notes: '', value: 0, completed: false }
|
||||
|
||||
# list.on 'set', '*.completed', (i, completed, previous, isLocal) ->
|
||||
# # Move the item to the bottom if it was checked off
|
||||
# list.move i, -1 if completed && isLocal
|
||||
newTask = _.defaults {completed: false }, newTask
|
||||
model.unshift "_#{type}List", newTask
|
||||
newModel.set ''
|
||||
|
||||
appExports.del = (e, el) ->
|
||||
# Derby extends model.at to support creation from DOM nodes
|
||||
|
|
|
|||
Loading…
Reference in a new issue