mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-23 14:41:04 -04:00
webui: chat-channel subscribe
This commit is contained in:
parent
9d9a456a67
commit
253182032a
2 changed files with 64 additions and 9 deletions
|
@ -20,6 +20,9 @@ function lobbies(){
|
||||||
return m("div.btn",{
|
return m("div.btn",{
|
||||||
title: "topic: " + lobby.topic + "\n"
|
title: "topic: " + lobby.topic + "\n"
|
||||||
+ "subscribed: " + lobby.subscribed,
|
+ "subscribed: " + lobby.subscribed,
|
||||||
|
style: {
|
||||||
|
backgroundColor: lobby.subscribed ? 'blue' : 'darkred',
|
||||||
|
},
|
||||||
onclick: function(){
|
onclick: function(){
|
||||||
m.route("/chat?lobby=" + lobby.chat_id);
|
m.route("/chat?lobby=" + lobby.chat_id);
|
||||||
}
|
}
|
||||||
|
@ -29,16 +32,64 @@ function lobbies(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getLobbyDetails(lobbyid){
|
||||||
|
var lobs = rs("chat/lobbies");
|
||||||
|
if (lobs === undefined) {
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
for(var i = 0, l = lobs.length; i < l; ++i) {
|
||||||
|
if (lobs[i].chat_id == lobbyid) {
|
||||||
|
return lobs[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function lobby(lobbyid){
|
function lobby(lobbyid){
|
||||||
|
var lobby = getLobbyDetails(lobbyid);
|
||||||
|
if (lobby == null) {
|
||||||
|
return m("div","waiting ...");
|
||||||
|
}
|
||||||
var msgs = rs("chat/messages/" + lobbyid);
|
var msgs = rs("chat/messages/" + lobbyid);
|
||||||
var info = rs("chat/info/" + lobbyid);
|
var info = rs("chat/info/" + lobbyid);
|
||||||
if (msgs === undefined || info === undefined) {
|
if (msgs === undefined || info === undefined) {
|
||||||
return m("div","waiting ...");
|
return m("div","waiting ...");
|
||||||
}
|
}
|
||||||
return msgs.map(function(item){
|
var intro = [
|
||||||
|
m("h2",lobby.name),
|
||||||
|
m("p",lobby.topic),
|
||||||
|
m("hr")
|
||||||
|
]
|
||||||
|
if (!lobby.subscribed) {
|
||||||
|
return [
|
||||||
|
intro,
|
||||||
|
m("b","select subscribe identity:"),
|
||||||
|
m("p"),
|
||||||
|
rs.list("identity/own", function(item){
|
||||||
|
return m("div.btn2",{
|
||||||
|
onclick:function(){
|
||||||
|
console.log("subscribe - id:" + lobby.id +", "
|
||||||
|
+ "gxs_id:" + item.gxs_id)
|
||||||
|
rs.request("chat/subscribe_lobby",{
|
||||||
|
id:lobby.id,
|
||||||
|
gxs_id:item.gxs_id
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},"subscribe as " + item.name);
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
intro,
|
||||||
|
msgs.map(function(item){
|
||||||
var d = new Date(new Number(item.send_time)*1000);
|
var d = new Date(new Number(item.send_time)*1000);
|
||||||
return msg(item.author_name, d.toLocaleDateString() + " " + d.toLocaleTimeString(),item.msg);
|
return msg(
|
||||||
});
|
item.author_name,
|
||||||
|
d.toLocaleDateString() + " " + d.toLocaleTimeString(),
|
||||||
|
item.msg
|
||||||
|
);
|
||||||
|
})
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -46,8 +97,8 @@ module.exports = {
|
||||||
return m(".chat.container", [
|
return m(".chat.container", [
|
||||||
m(".chat.header", "headerbar"),
|
m(".chat.header", "headerbar"),
|
||||||
m(".chat.left", [
|
m(".chat.left", [
|
||||||
m("div.chat.header","lobbies:"),
|
m("div.chat.header[style=position:relative]","lobbies:"),
|
||||||
m("hr"),
|
m("br"),
|
||||||
lobbies(),
|
lobbies(),
|
||||||
]),
|
]),
|
||||||
m(".chat.right", right),
|
m(".chat.right", right),
|
||||||
|
|
|
@ -170,7 +170,11 @@ function checkFocus(){
|
||||||
// called every time, rs or rs.request failed, only response or value is set
|
// called every time, rs or rs.request failed, only response or value is set
|
||||||
function requestFail(path, response, value) {
|
function requestFail(path, response, value) {
|
||||||
rs.error = "error on " + path;
|
rs.error = "error on " + path;
|
||||||
console.log("Error on " + path + (response == null ? ", value " + value : ", response " + response));
|
console.log("Error on " + path +
|
||||||
|
(response == null ? ", value: " + value : (", response: " +
|
||||||
|
(response.debug_msg === undefined ? response : response.debug_msg)
|
||||||
|
))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rs(path, args, callback, options){
|
function rs(path, args, callback, options){
|
||||||
|
@ -260,8 +264,8 @@ rs.counting = function(path, counterfnkt) {
|
||||||
// listing data-elements
|
// listing data-elements
|
||||||
rs.list = function(path, buildfktn){
|
rs.list = function(path, buildfktn){
|
||||||
var list = rs(path);
|
var list = rs(path);
|
||||||
if (list === undefined) {
|
if (list === undefined|| list == null) {
|
||||||
return "< waiting for server ... >"
|
return "< waiting for server ... >"
|
||||||
}
|
};
|
||||||
return list.map(buildfktn);
|
return list.map(buildfktn);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue