diff --git a/app/actions.js b/app/actions.js
index f8fa0b4..244af05 100644
--- a/app/actions.js
+++ b/app/actions.js
@@ -697,6 +697,7 @@ const initializeCabal = ({ addr, username, settings }) => async dispatch => {
]
cabalDetailsEvents.forEach((event) => {
cabalDetails.on(event.name, throttle((data) => {
+ // console.log('Event', event.name, data)
event.action(data)
}), event.throttleDelay || 200, { leading: true, trailing: true })
})
@@ -756,42 +757,43 @@ const generateUniqueName = () => {
return `${randomItem(adjectives)}-${randomItem(nouns)}`
}
-export const moderationHide = ({ addr, channel, reason, userKey }) => async dispatch => {
- const cabalDetails = client.getDetails(addr)
- cabalDetails.moderation.hide([[userKey, reason]], { channel, reason } )
+export const moderationHide = (props) => async dispatch => {
+ dispatch(moderationAction('hide', props))
}
-export const moderationUnhide = ({ addr, channel, reason, userKey }) => async dispatch => {
- const cabalDetails = client.getDetails(addr)
- cabalDetails.moderation.unhide([[userKey, reason]], { channel, reason } )
+export const moderationUnhide = (props) => async dispatch => {
+ dispatch(moderationAction('unhide', props))
}
-export const moderationBlock = ({ addr, channel, reason, userKey }) => async dispatch => {
- const cabalDetails = client.getDetails(addr)
- cabalDetails.moderation.block([[userKey, reason]], { channel, reason } )
+export const moderationBlock = (props) => async dispatch => {
+ dispatch(moderationAction('block', props))
}
-export const moderationUnblock = ({ addr, channel, reason, userKey }) => async dispatch => {
- const cabalDetails = client.getDetails(addr)
- cabalDetails.moderation.unblock([[userKey, reason]], { channel, reason } )
+export const moderationUnblock = (props) => async dispatch => {
+ dispatch(moderationAction('unblock', props))
}
-export const moderationAddMod = ({ addr, channel, reason, userKey }) => async dispatch => {
- const cabalDetails = client.getDetails(addr)
- cabalDetails.moderation.addMod([[userKey, reason]], { channel, reason } )
+export const moderationAddMod = (props) => async dispatch => {
+ dispatch(moderationAction('addMod', props))
}
-export const moderationRemoveMod = ({ addr, channel, reason, userKey }) => async dispatch => {
- const cabalDetails = client.getDetails(addr)
- cabalDetails.moderation.removeMod([[userKey, reason]], { channel, reason } )
+export const moderationRemoveMod = (props) => async dispatch => {
+ dispatch(moderationAction('removeMod', props))
}
-export const moderationAddAdmin = ({ addr, channel, reason, userKey }) => async dispatch => {
- const cabalDetails = client.getDetails(addr)
- cabalDetails.moderation.addAdmin([[userKey, reason]], { channel, reason } )
+export const moderationAddAdmin = (props) => async dispatch => {
+ dispatch(moderationAction('addAdmin', props))
+}
+
+export const moderationRemoveAdmin = (props) => async dispatch => {
+ dispatch(moderationAction('removeAdmin', props))
}
-export const moderationRemoveAdmin = ({ addr, channel, reason, userKey }) => async dispatch => {
+export const moderationAction = (action, { addr, channel, reason, userKey}) => async dispatch => {
const cabalDetails = client.getDetails(addr)
- cabalDetails.moderation.removeAdmin([[userKey, reason]], { channel, reason } )
+ await cabalDetails.moderation[action](userKey, { channel, reason })
+ setTimeout(() => {
+ const users = cabalDetails.getUsers()
+ dispatch({ type: 'UPDATE_CABAL', addr, users })
+ }, 500)
}
diff --git a/app/containers/messages.js b/app/containers/messages.js
index f454485..748aa91 100644
--- a/app/containers/messages.js
+++ b/app/containers/messages.js
@@ -45,6 +45,7 @@ function MessagesContainer (props) {
)
} else {
+ const defaultSystemName = 'Cabalbot'
let prevMessage = {}
return (
@@ -71,7 +72,6 @@ function MessagesContainer (props) {
let item = (
)
prevMessage = message
if (message.type === 'status') {
- const defaultSystemName = 'Cabalbot'
item = (
@@ -86,6 +86,35 @@ function MessagesContainer (props) {
)
}
+ if (message.type === 'chat/moderation') {
+ const { role, type, issuerid, receiverid, reason } = message.content
+ const issuer = props.getUsers({ addr: props.addr })[issuerid]
+ const receiver = props.getUsers({ addr: props.addr })[receiverid]
+ const issuerName = issuer && issuer.name ? issuer.name : issuerid.slice(0, 8)
+ const receiverName = receiver && receiver.name ? receiver.name : receiverid.slice(0, 8)
+ item = (
+
+
+
+
{message.name || defaultSystemName}{renderDate(formattedTime)}
+
+ Moderation:
+ {role === 'hide' &&
+ {issuerName} {(type === 'add' ? 'hid' : 'unhid')} {receiverName}}
+ {role !== 'hide' &&
+ {issuerName} {(type === 'add' ? 'added' : 'removed')} {receiverName} as {role}}
+ {!!reason &&
+ ({reason})
+ }
+
+
+
+ )
+ }
if (message.type === 'chat/text') {
item = (
diff --git a/app/containers/sidebar.js b/app/containers/sidebar.js
index 1bbd162..959de2d 100644
--- a/app/containers/sidebar.js
+++ b/app/containers/sidebar.js
@@ -181,7 +181,8 @@ class SidebarScreen extends React.Component {
const deduplicatedNicks = []
users && users.forEach((user) => {
const userIndex = deduplicatedNicks.findIndex((u) => u.name === user.name)
- if (user.name && userIndex > -1) {
+ const moderated = user.isHidden || user.isAdmin || user.isModerator
+ if (user.name && userIndex > -1 && !moderated) {
deduplicatedNicks[userIndex].users.push(user)
} else {
deduplicatedNicks.push({
@@ -311,6 +312,7 @@ class SidebarScreen extends React.Component {
const isAdmin = peer.users.some((u) => u.isAdmin())
const isModerator = peer.users.some((u) => u.isModerator())
const isHidden = peer.users.some((u) => u.isHidden())
+ const name = isHidden ? peer.name.substring(0, 3) + peer.key.substring(0, 6) : peer.name
return (
- {peer.name || peer.key.substring(0, 6)}
+ {peer.name ? name : peer.key.substring(0, 6)}
{peer.users.length > 1 && ({peer.users.length})}
{!isAdmin && !isModerator && isHidden && HIDDEN}
diff --git a/app/styles/style.scss b/app/styles/style.scss
index 12ce900..e9773c9 100644
--- a/app/styles/style.scss
+++ b/app/styles/style.scss
@@ -949,8 +949,6 @@ form {
border: 2px solid rgba(0, 0, 0, 0.25);
border-radius: 3px;
transition: all 0.1s ease-in-out;
- padding: .5rem 0;
- min-height: 48px;
&:hover, &:focus {
border-color: rgba(0, 0, 0, 0.5);
@@ -967,13 +965,13 @@ form {
.composer__input {
width: 100%;
- padding: 0 1rem;
}
.composer__input form {
width: 100%;
display: flex;
align-content: center;
+ padding: 0.5rem;
}
.composer__input textarea {
@@ -995,7 +993,7 @@ form {
}
.composer__other {
- align-self: flex-end;
+ align-self: center;
display: table-cell;
width: 3rem;
height: 1.5rem;
diff --git a/package.json b/package.json
index f12524b..2364931 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "cabal-desktop",
- "version": "6.0.1",
+ "version": "6.0.2",
"description": "Cabal p2p offline-first desktop application",
"scripts": {
"build": "cross-env NODE_ENV=production webpack",
@@ -51,7 +51,7 @@
"@babel/runtime": "^7.7.7",
"@reduxjs/toolkit": "^1.3.5",
"babel-runtime": "^6.26.0",
- "cabal-client": "^6.0.0",
+ "cabal-client": "6.1.0",
"collect-stream": "^1.2.1",
"dat-encoding": "^5.0.1",
"debug": "^4.1.1",
diff --git a/yarn.lock b/yarn.lock
index 275c5d7..19cec8f 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2359,10 +2359,10 @@ bulk-write-stream@^1.1.3:
inherits "^2.0.1"
readable-stream "^2.1.4"
-cabal-client@^6.0.0:
- version "6.0.0"
- resolved "https://registry.yarnpkg.com/cabal-client/-/cabal-client-6.0.0.tgz#081f64f839116e681447dbeb5ac72ee5c649945a"
- integrity sha512-Fb357yv3TzcEH0fX1crtx2m4Ua+WF0HqFznnu9mEZUaGk8BCKv9Sk+g2QXc2BdqJ59mjlTRvflFio1UzFzfqJw==
+cabal-client@6.1.0:
+ version "6.1.0"
+ resolved "https://registry.yarnpkg.com/cabal-client/-/cabal-client-6.1.0.tgz#5e350c836d5c46bbf55ef032897ed8dd948531e7"
+ integrity sha512-y/8CJBR4+f8MIdwXCfKevYzkV7Jdnb19WDixFValn6U180zKIA4dWkoWaD0B1Kr9PNy2bKLT1/ixG2Tsn76e/g==
dependencies:
cabal-core "^13.0.0"
collect-stream "^1.2.1"