Commit 438a3530 authored by Thibaut Frain's avatar Thibaut Frain

Adding basic jio history for chatbox gadget

parent fb60f5d5
...@@ -48,10 +48,16 @@ ...@@ -48,10 +48,16 @@
}).c("body").t(content).toString()); }).c("body").t(content).toString());
} }
} }
gadget_klass.ready(function(g) { gadget_klass.declareAcquiredMethod("jio_put", "jio_put").declareAcquiredMethod("jio_get", "jio_get").ready(function(g) {
return g.jio_get({
_id: "chatbox_history"
}).push(function(response) {
return JSON.parse(response.data.datas);
}).push(function(talks) {
g.props = { g.props = {
talks: {} talks: talks
}; };
});
}).declareMethod("render", function(options) { }).declareMethod("render", function(options) {
var gadget = this, messages; var gadget = this, messages;
this.props.jid = options.jid; this.props.jid = options.jid;
...@@ -86,6 +92,10 @@ ...@@ -86,6 +92,10 @@
this.props.talks[from] = new Talk(from); this.props.talks[from] = new Talk(from);
} }
this.props.talks[from].messages.push(message); this.props.talks[from].messages.push(message);
this.jio_put({
_id: "chatbox_history",
datas: JSON.stringify(this.props.talks)
});
displayMessage(message); displayMessage(message);
}); });
})($, rJS, Handlebars); })($, rJS, Handlebars);
\ No newline at end of file
...@@ -68,10 +68,21 @@ ...@@ -68,10 +68,21 @@
} }
gadget_klass gadget_klass
.declareAcquiredMethod('jio_put', 'jio_put')
.declareAcquiredMethod('jio_get', 'jio_get')
.ready(function (g) { .ready(function (g) {
return g.jio_get({"_id": "chatbox_history"})
.push(function (response) {
return JSON.parse(response.data.datas);
})
.push(function (talks) {
g.props = { g.props = {
talks: {} talks: talks
}; };
});
}) })
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
...@@ -125,6 +136,12 @@ ...@@ -125,6 +136,12 @@
this.props.talks[from] = new Talk(from); this.props.talks[from] = new Talk(from);
} }
this.props.talks[from].messages.push(message); this.props.talks[from].messages.push(message);
this.jio_put({
"_id": "chatbox_history",
"datas": JSON.stringify(this.props.talks)
});
displayMessage(message); displayMessage(message);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment