Make it work with current version of xo-web.

This commit is contained in:
Julien Fontanet 2015-05-19 16:48:03 +02:00
parent 312fcea5f1
commit 7f60725c88
2 changed files with 13 additions and 4 deletions

View File

@ -33,7 +33,7 @@
"make-error": "^0.3.0",
"pw": "0.0.4",
"ws": "^0.7.1",
"xo-collection": "^0.2.1"
"xo-collection": "^0.3.0"
},
"devDependencies": {
"mocha": "^2.1.0",

View File

@ -8,6 +8,7 @@ var forEach = require('lodash.foreach')
var Index = require('xo-collection/index')
var isString = require('lodash.isstring')
var startsWith = require('lodash.startswith')
var UniqueIndex = require('xo-collection/unique-index')
var Api = require('./api')
var BackOff = require('./back-off')
@ -62,7 +63,9 @@ function setMultiple (collection, items) {
function unsetMultiple (collection, items) {
forEach(items, function (item) {
collection.unset(item)
if (collection.has(item)) {
collection.remove(item)
}
})
}
@ -111,9 +114,15 @@ function Xo (opts) {
objects.getKey = function (item) {
return item.UUID || item.ref || 'undefined'
}
objects.createIndex('ref', new Index('ref'))
objects.createIndex('ref', new UniqueIndex('ref'))
objects.createIndex('type', new Index('type'))
objects.createIndex('uuid', new Index('uuid'))
objects.createIndex('UUID', new UniqueIndex('UUID'))
// This hack is used to trigger an Angular refresh in xo-web
// every time the collection is updated.
objects.on('finish', function () {
Bluebird.resolve().then(function () {})
})
this.status = 'disconnected'
this.user = null