mirror of
https://github.com/RetroShare/RSNewWebUI.git
synced 2026-09-14 11:05:47 +05:00
review fixed
This commit is contained in:
parent
c568d28c01
commit
4f93f7024b
@ -13,11 +13,11 @@ const filesUploadHashes = {
|
||||
Thumbnail: [],
|
||||
};
|
||||
|
||||
async function parseFile(file, type) {
|
||||
async function parsefile(file, type) {
|
||||
const fileSize = file.size;
|
||||
const chunkSize = 1024 * 1024; // bytes
|
||||
let offset = 0;
|
||||
let chunkReaderBlock = null;
|
||||
let chunkreaderblock = null;
|
||||
const hash = sha1.create();
|
||||
const ansList = [];
|
||||
|
||||
@ -42,11 +42,11 @@ async function parseFile(file, type) {
|
||||
// }
|
||||
|
||||
// // of to the next chunk
|
||||
// await chunkReaderBlock(offset, chunkSize, file);
|
||||
// await chunkreaderblock(offset, chunkSize, file);
|
||||
// return ansList;
|
||||
// };
|
||||
|
||||
chunkReaderBlock = async function (_offset, length, _file) {
|
||||
chunkreaderblock = async function (_offset, length, _file) {
|
||||
// const reader = new FileReader();
|
||||
const blob = await _file.slice(_offset, length + _offset);
|
||||
const data = await blob.text();
|
||||
@ -65,11 +65,11 @@ async function parseFile(file, type) {
|
||||
}
|
||||
|
||||
// of to the next chunk
|
||||
await chunkReaderBlock(offset, chunkSize, file);
|
||||
await chunkreaderblock(offset, chunkSize, file);
|
||||
};
|
||||
|
||||
// read with the first block
|
||||
await chunkReaderBlock(offset, chunkSize, file);
|
||||
await chunkreaderblock(offset, chunkSize, file);
|
||||
return ansList;
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ const AddPost = () => {
|
||||
onchange: async (e) => {
|
||||
filesUploadHashes.Thumbnail = [];
|
||||
pthumbnail = [];
|
||||
const ansList = await parseFile(e.target.files[0], '');
|
||||
const ansList = await parsefile(e.target.files[0], '');
|
||||
|
||||
if (filesUploadHashes.Thumbnail.length === e.target.files.length) {
|
||||
pthumbnail.push({
|
||||
@ -109,7 +109,7 @@ const AddPost = () => {
|
||||
filesUploadHashes.PostFiles = [];
|
||||
pfiles = [];
|
||||
for (let i = 0; i < e.target.files.length; i++) {
|
||||
await parseFile(e.target.files[i], 'multiple');
|
||||
await parsefile(e.target.files[i], 'multiple');
|
||||
}
|
||||
// console.log(filesUploadHashes.PostFiles, filesUploadHashes.PostFiles.length);
|
||||
|
||||
@ -128,7 +128,8 @@ const AddPost = () => {
|
||||
m('input[type=text][placeholder=Title]', {
|
||||
oninput: (e) => (ptitle = e.target.value),
|
||||
}),
|
||||
m('textarea[rows=5][style="width: 90%; display: block;"]', {
|
||||
m('textarea[rows=5]', {
|
||||
style: {width: '90%', display: 'block'},
|
||||
oninput: (e) => (content = e.target.value),
|
||||
value: content,
|
||||
}),
|
||||
@ -146,8 +147,8 @@ const AddPost = () => {
|
||||
thumbnail: pthumbnail,
|
||||
});
|
||||
res.body.retval === false
|
||||
? util.popupMessage([m('h3', 'Error'), m('hr'), m('p', res.body.errorMessage)])
|
||||
: util.popupMessage([
|
||||
? util.m([m('h3', 'Error'), m('hr'), m('p', res.body.errorMessage)])
|
||||
: util.m([
|
||||
m('h3', 'Success'),
|
||||
m('hr'),
|
||||
m('p', 'Post added successfully'),
|
||||
@ -256,7 +257,7 @@ const ChannelView = () => {
|
||||
style: 'display:' + (csubscribed ? 'block' : 'none'),
|
||||
},
|
||||
m('h3', 'Posts'),
|
||||
m('button', { onclick: () => util.popupMessage(m(AddPost, { chanId: v.attrs.id })) }, [
|
||||
m('button', { onclick: () => util.m(m(AddPost, { chanId: v.attrs.id })) }, [
|
||||
'Add Post',
|
||||
m('i.fas.fa-edit'),
|
||||
]),
|
||||
@ -283,7 +284,7 @@ const ChannelView = () => {
|
||||
class: 'card-img',
|
||||
src: 'data:image/png;base64,' + plist[key].post.mThumbnail.mData.base64,
|
||||
|
||||
alt: 'No Thumbnail',
|
||||
alt: '',
|
||||
}),
|
||||
m('div', { class: 'card-info' }, [
|
||||
m('h4', { class: 'card-title' }, plist[key].post.mMeta.mMsgName),
|
||||
@ -298,7 +299,7 @@ const ChannelView = () => {
|
||||
};
|
||||
};
|
||||
|
||||
async function AddVote(voteType, vchannelId, vpostId, vauthorId, vcommentId) {
|
||||
async function addvote(voteType, vchannelId, vpostId, vauthorId, vcommentId) {
|
||||
const res = await rs.rsJsonApiRequest('/rsgxschannels/voteForComment', {
|
||||
channelId: vchannelId,
|
||||
postId: vpostId,
|
||||
@ -307,7 +308,7 @@ async function AddVote(voteType, vchannelId, vpostId, vauthorId, vcommentId) {
|
||||
vote: voteType,
|
||||
});
|
||||
if (res.body.retval) {
|
||||
util.updateDisplayChannels(vchannelId);
|
||||
util.updatedisplaychannels(vchannelId);
|
||||
m.redraw();
|
||||
}
|
||||
}
|
||||
@ -322,7 +323,8 @@ const AddComment = () => {
|
||||
(vnode.attrs.parent_comment !== '') > 0
|
||||
? [m('h5', 'Reply to comment: '), m('p', vnode.attrs.parent_comment)]
|
||||
: '',
|
||||
m('textarea[rows=5][style="width: 90%; display: block;"]', {
|
||||
m('textarea[rows=5]', {
|
||||
style: {width: '90%', display: 'block'},
|
||||
oninput: (e) => (inputComment = e.target.value),
|
||||
value: inputComment,
|
||||
}),
|
||||
@ -339,13 +341,13 @@ const AddComment = () => {
|
||||
});
|
||||
|
||||
res.body.retval === false
|
||||
? util.popupMessage([m('h3', 'Error'), m('hr'), m('p', res.body.errorMessage)])
|
||||
: util.popupMessage([
|
||||
? util.m([m('h3', 'Error'), m('hr'), m('p', res.body.errorMessage)])
|
||||
: util.m([
|
||||
m('h3', 'Success'),
|
||||
m('hr'),
|
||||
m('p', 'Comment added successfully'),
|
||||
]);
|
||||
util.updateDisplayChannels(vnode.attrs.channelId);
|
||||
util.updatedisplaychannels(vnode.attrs.channelId);
|
||||
m.redraw();
|
||||
},
|
||||
},
|
||||
@ -354,7 +356,7 @@ const AddComment = () => {
|
||||
]),
|
||||
};
|
||||
};
|
||||
function DisplayComment() {
|
||||
function displaycomment() {
|
||||
return {
|
||||
oninit: (v) => {},
|
||||
view: ({ attrs: { commentStruct, identity, replyDepth } }) => {
|
||||
@ -395,7 +397,7 @@ function DisplayComment() {
|
||||
{
|
||||
style: 'font-size:15px',
|
||||
onclick: () =>
|
||||
util.popupMessage(
|
||||
util.m(
|
||||
m(AddComment, {
|
||||
parent_comment: comment.mComment,
|
||||
channelId: comment.mMeta.mGroupId,
|
||||
@ -412,7 +414,7 @@ function DisplayComment() {
|
||||
{
|
||||
style: 'font-size:15px',
|
||||
onclick: () =>
|
||||
AddVote(
|
||||
addvote(
|
||||
util.GXS_VOTE_UP,
|
||||
comment.mMeta.mGroupId,
|
||||
comment.mMeta.mThreadId,
|
||||
@ -427,7 +429,7 @@ function DisplayComment() {
|
||||
{
|
||||
style: 'font-size:15px',
|
||||
onclick: () =>
|
||||
AddVote(
|
||||
addvote(
|
||||
util.GXS_VOTE_DOWN,
|
||||
comment.mMeta.mGroupId,
|
||||
comment.mMeta.mThreadId,
|
||||
@ -455,7 +457,7 @@ function DisplayComment() {
|
||||
commentStruct.showReplies &&
|
||||
// parMap.map((value) =>
|
||||
Object.keys(parMap).map((key, index) =>
|
||||
m(DisplayComment, {
|
||||
m(displaycomment, {
|
||||
commentStruct: Data.Comments[parMap[key].mMeta.mThreadId][parMap[key].mMeta.mMsgId],
|
||||
identity,
|
||||
replyDepth: replyDepth + 1,
|
||||
@ -515,7 +517,7 @@ const PostView = () => {
|
||||
post.mFiles.map((file) =>
|
||||
m('tr', [
|
||||
m('td', file.mName),
|
||||
m('td', util.formatBytes(file.mSize.xint64)),
|
||||
m('td', util.formatbytes(file.mSize.xint64)),
|
||||
m(
|
||||
'button',
|
||||
{
|
||||
@ -557,7 +559,7 @@ const PostView = () => {
|
||||
'button',
|
||||
{
|
||||
onclick: () => {
|
||||
util.popupMessage(
|
||||
util.popupmessage(
|
||||
m(AddComment, {
|
||||
parent_comment: '',
|
||||
channelId: v.attrs.channelId,
|
||||
@ -577,7 +579,7 @@ const PostView = () => {
|
||||
Object.keys(topComments).map((key, index) =>
|
||||
Data.Comments[topComments[key].mMeta.mThreadId] &&
|
||||
Data.Comments[topComments[key].mMeta.mThreadId][topComments[key].mMeta.mMsgId]
|
||||
? m(DisplayComment, {
|
||||
? m(displaycomment, {
|
||||
identity: ownId,
|
||||
commentStruct:
|
||||
Data.Comments[topComments[key].mMeta.mThreadId][
|
||||
|
||||
@ -19,7 +19,7 @@ const Data = {
|
||||
ParentCommentMap: {},
|
||||
};
|
||||
|
||||
async function updateContent(content, channelid) {
|
||||
async function updatecontent(content, channelid) {
|
||||
const res = await rs.rsJsonApiRequest('/rsgxschannels/getChannelContent', {
|
||||
channelId: channelid,
|
||||
contentsIds: [content.mMsgId],
|
||||
@ -62,7 +62,7 @@ async function updateContent(content, channelid) {
|
||||
}
|
||||
}
|
||||
|
||||
async function updateDisplayChannels(keyid, details) {
|
||||
async function updatedisplaychannels(keyid, details) {
|
||||
const res1 = await rs.rsJsonApiRequest('/rsgxschannels/getChannelsInfo', {
|
||||
chanIds: [keyid],
|
||||
});
|
||||
@ -90,7 +90,7 @@ async function updateDisplayChannels(keyid, details) {
|
||||
|
||||
if (res2.body.retval) {
|
||||
res2.body.summaries.map((content) => {
|
||||
updateContent(content, keyid);
|
||||
updatecontent(content, keyid);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -123,7 +123,7 @@ const ChannelSummary = () => {
|
||||
return {
|
||||
oninit: (v) => {
|
||||
keyid = v.attrs.details.mGroupId;
|
||||
updateDisplayChannels(keyid);
|
||||
updatedisplaychannels(keyid);
|
||||
},
|
||||
|
||||
view: (v) => {},
|
||||
@ -150,10 +150,6 @@ const CommentsTable = () => {
|
||||
};
|
||||
};
|
||||
|
||||
const optionSelect = {
|
||||
showval: 'Options',
|
||||
opts: ['Reply', 'Vote Up', 'Vote Down'],
|
||||
};
|
||||
|
||||
const FilesTable = () => {
|
||||
return {
|
||||
@ -166,7 +162,7 @@ const FilesTable = () => {
|
||||
};
|
||||
};
|
||||
|
||||
function formatBytes(bytes, decimals = 2) {
|
||||
function formatbytes(bytes, decimals = 2) {
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
const k = 1024;
|
||||
const dm = decimals < 0 ? 0 : decimals;
|
||||
@ -175,7 +171,7 @@ function formatBytes(bytes, decimals = 2) {
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
||||
}
|
||||
|
||||
function popupMessage(message) {
|
||||
function popupmessage(message) {
|
||||
const container = document.getElementById('modal-container');
|
||||
container.style.display = 'block';
|
||||
m.render(
|
||||
@ -238,15 +234,14 @@ const SearchBar = () => {
|
||||
module.exports = {
|
||||
Data,
|
||||
SearchBar,
|
||||
popupMessage,
|
||||
popupmessage,
|
||||
ChannelSummary,
|
||||
formatBytes,
|
||||
formatbytes,
|
||||
DisplayChannelsFromList,
|
||||
updateDisplayChannels,
|
||||
updatedisplaychannels,
|
||||
ChannelTable,
|
||||
FilesTable,
|
||||
CommentsTable,
|
||||
optionSelect,
|
||||
GROUP_SUBSCRIBE_ADMIN,
|
||||
GROUP_SUBSCRIBE_NOT_SUBSCRIBED,
|
||||
GROUP_SUBSCRIBE_PUBLISH,
|
||||
|
||||
@ -2,18 +2,18 @@ const m = require('mithril');
|
||||
const rs = require('rswebui');
|
||||
const util = require('forums/forums_util');
|
||||
|
||||
function DisplayThread() {
|
||||
function displaythread() {
|
||||
return {
|
||||
oninit: (v) => {},
|
||||
view: ({ attrs: { threadStruct, replyDepth } }) => {
|
||||
const thread = threadStruct.thread;
|
||||
let parMap = [];
|
||||
if (util.Data.ParentThreadMap[thread.mMeta.mMsgId]) {
|
||||
parMap = Array.from(util.Data.ParentThreadMap[thread.mMeta.mMsgId]);
|
||||
parMap = util.Data.ParentThreadMap[thread.mMeta.mMsgId];
|
||||
}
|
||||
return [
|
||||
m('tr', [
|
||||
parMap.length > 0
|
||||
Object.keys(parMap).length
|
||||
? m(
|
||||
'td',
|
||||
m('i.fas.fa-angle-right', {
|
||||
@ -48,9 +48,9 @@ function DisplayThread() {
|
||||
),
|
||||
]),
|
||||
threadStruct.showReplies &&
|
||||
parMap.map((value) =>
|
||||
m(DisplayThread, {
|
||||
threadStruct: util.Data.Threads[value.mGroupId][value.mMsgId],
|
||||
Object.keys(parMap).map((key, index) =>
|
||||
m(displaythread, {
|
||||
threadStruct: util.Data.Threads[parMap[key].mGroupId][parMap[key].mMsgId],
|
||||
replyDepth: replyDepth + 1,
|
||||
})
|
||||
),
|
||||
@ -94,7 +94,7 @@ const ThreadView = () => {
|
||||
'tbody',
|
||||
util.Data.Threads[v.attrs.forumId] &&
|
||||
util.Data.Threads[v.attrs.forumId][v.attrs.msgId] &&
|
||||
m(DisplayThread, {
|
||||
m(displaythread, {
|
||||
threadStruct: util.Data.Threads[v.attrs.forumId][v.attrs.msgId],
|
||||
replyDepth: 0,
|
||||
})
|
||||
@ -198,7 +198,9 @@ const ForumView = () => {
|
||||
style: 'display:' + (fsubscribed ? 'block' : 'none'),
|
||||
},
|
||||
m('h3', 'Threads'),
|
||||
m('button', { onclick: () => util.popupMessage() }, [
|
||||
m('button',
|
||||
// { onclick: () => util.popupMessage() },
|
||||
[
|
||||
'New Thread',
|
||||
m('i.fas.fa-pencil-alt'),
|
||||
]),
|
||||
|
||||
@ -14,7 +14,7 @@ const Data = {
|
||||
ParentThreadMap: {},
|
||||
};
|
||||
|
||||
async function updateDisplayForums(keyid, details = {}) {
|
||||
async function updatedisplayforums(keyid, details = {}) {
|
||||
const res = await rs.rsJsonApiRequest('/rsgxsforums/getForumsInfo', {
|
||||
forumIds: [keyid], // keyid: Forumid
|
||||
});
|
||||
@ -53,9 +53,9 @@ async function updateDisplayForums(keyid, details = {}) {
|
||||
Data.ParentThreads[keyid][thread.mMsgId] = thread;
|
||||
} else {
|
||||
if (Data.ParentThreadMap[thread.mParentId] === undefined) {
|
||||
Data.ParentThreadMap[thread.mParentId] = new Set();
|
||||
Data.ParentThreadMap[thread.mParentId] = {};
|
||||
}
|
||||
Data.ParentThreadMap[thread.mParentId].add(thread);
|
||||
Data.ParentThreadMap[thread.mParentId][thread.mMsgId] = thread;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -90,7 +90,7 @@ const ForumSummary = () => {
|
||||
return {
|
||||
oninit: (v) => {
|
||||
keyid = v.attrs.details.mGroupId;
|
||||
updateDisplayForums(keyid);
|
||||
updatedisplayforums(keyid);
|
||||
},
|
||||
|
||||
view: (v) => {},
|
||||
@ -107,7 +107,7 @@ const ThreadsTable = () => {
|
||||
oninit: (v) => {},
|
||||
view: (v) =>
|
||||
m('table.threads', [
|
||||
m('tr', [m('th', 'Comment'), m('th', 'Author'), m('th', 'Date')]),
|
||||
m('tr', [m('th', 'Comment'), m('th', 'Date'), m('th', 'Author')]),
|
||||
v.children,
|
||||
]),
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user