mirror of
https://github.com/RetroShare/RSNewWebUI.git
synced 2026-09-14 11:05:47 +05:00
some changes to reflect subscribed channels
This commit is contained in:
parent
b6281457bb
commit
59c6cffc38
@ -3,63 +3,66 @@ const widget = require('widgets');
|
||||
const rs = require('rswebui');
|
||||
const util = require('channels/channels_util');
|
||||
|
||||
const getChannels =
|
||||
{
|
||||
All : [],
|
||||
PopularChannels : [],
|
||||
SubscribedChannels : [],
|
||||
load(){
|
||||
|
||||
rs.rsJsonApiRequest('/rsgxschannels/getChannelsSummaries', {}, (data) => {
|
||||
const getChannels = {
|
||||
All: [],
|
||||
PopularChannels: [],
|
||||
SubscribedChannels: [],
|
||||
async load() {
|
||||
await rs.rsJsonApiRequest('/rsgxschannels/getChannelsSummaries', {}, (data) => {
|
||||
getChannels.All = data.channels;
|
||||
console.log(getChannels.All);
|
||||
getChannels.PopularChannels = getChannels.All;
|
||||
// console.log(util.GROUP_SUBSCRIBE_SUBSCRIBED === 4);
|
||||
getChannels.SubscribedChannels = getChannels.All.filter(
|
||||
(channel) => (channel.mSubscribeFlags) === util.GROUP_SUBSCRIBE_SUBSCRIBED
|
||||
(channel) => channel.mSubscribeFlags === util.GROUP_SUBSCRIBE_SUBSCRIBED
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const sections = {
|
||||
MyChannels: require('channels/my_channels'),
|
||||
SubscribedChannels: require('channels/subscribed_channels'),
|
||||
PopularChannels: require('channels/popular_channels'),
|
||||
OtherChannels: require('channels/other_channels')
|
||||
OtherChannels: require('channels/other_channels'),
|
||||
};
|
||||
|
||||
const Layout = {
|
||||
oninit: getChannels.load,
|
||||
onupdate: getChannels.load,
|
||||
view: (vnode) =>
|
||||
m('.tab-page', [
|
||||
m(util.SearchBar, {
|
||||
list: getChannels.All
|
||||
list: getChannels.All,
|
||||
}),
|
||||
m(widget.Sidebar, {
|
||||
tabs: Object.keys(sections),
|
||||
baseRoute: '/channels/',
|
||||
}),
|
||||
m('.channel-node-panel', vnode.children),
|
||||
m(
|
||||
'.channel-node-panel',
|
||||
|
||||
vnode.attrs.check
|
||||
? m(util.MessageView, {
|
||||
id: vnode.attrs.id,
|
||||
})
|
||||
: m(sections[vnode.attrs.tab], {
|
||||
list: getChannels[vnode.attrs.tab],
|
||||
})
|
||||
),
|
||||
]),
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
view: (vnode) => {
|
||||
const tab = vnode.attrs.tab;
|
||||
if (Object.prototype.hasOwnProperty.call(vnode.attrs, 'mGroupId')) {
|
||||
return m(
|
||||
Layout,
|
||||
m(util.MessageView, {
|
||||
id: vnode.attrs.mGroupId,
|
||||
})
|
||||
);
|
||||
return m(Layout, {
|
||||
check: true, // for channel description
|
||||
id: vnode.attrs.mGroupId,
|
||||
});
|
||||
}
|
||||
return m(
|
||||
Layout,
|
||||
m((sections[tab]), {
|
||||
list: getChannels[tab],
|
||||
}),
|
||||
);
|
||||
return m(Layout, {
|
||||
check: false,
|
||||
tab: vnode.attrs.tab,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@ -19,7 +19,7 @@ async function updateDisplayChannels(keyid, details) {
|
||||
},
|
||||
(data) => {
|
||||
details = data.channelsInfo[0];
|
||||
console.log(details);
|
||||
// console.log(details);
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
@ -76,6 +76,7 @@ const MessageView = () => {
|
||||
let cname = '';
|
||||
let cimage = '';
|
||||
let cauthor = '';
|
||||
let csubscribed = {};
|
||||
return {
|
||||
oninit: (v) => {
|
||||
if (Data.DisplayChannels[v.attrs.id]) {
|
||||
@ -88,6 +89,7 @@ const MessageView = () => {
|
||||
} else {
|
||||
cauthor = 'Unknown';
|
||||
}
|
||||
csubscribed = Data.DisplayChannels[v.attrs.id].isSubscribed;
|
||||
// console.log(typeof(Data.DisplayChannels[v.attrs.id].author));
|
||||
}
|
||||
},
|
||||
@ -127,9 +129,24 @@ const MessageView = () => {
|
||||
updateDisplayChannels(v.attrs.id);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
rs.rsJsonApiRequest(
|
||||
'/rsgxschannels/subscribeToChannel',
|
||||
{
|
||||
channelId: v.attrs.id,
|
||||
subscribe: false,
|
||||
},
|
||||
(data) => {
|
||||
console.log(data);
|
||||
}
|
||||
).then( () => {
|
||||
updateDisplayChannels(v.attrs.id);
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
(Data.DisplayChannels[v.attrs.id].isSubscribed)?'Subscribed':'Subscribe'
|
||||
(csubscribed)?'Subscribed':'Subscribe'
|
||||
),
|
||||
m('img.channelpic', {
|
||||
src: 'data:image/png;base64,' + cimage.mData.base64,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user