diff --git a/src/components/elements/MarkNotificationRead.jsx b/src/components/elements/MarkNotificationRead.jsx
index e75d6420..2987bc68 100644
--- a/src/components/elements/MarkNotificationRead.jsx
+++ b/src/components/elements/MarkNotificationRead.jsx
@@ -15,18 +15,21 @@ class MarkNotificationRead extends React.Component {
};
shouldComponentUpdate(nextProps) {
- if (this.props.interval !== nextProps.interval) {
+ if (this.props.interval !== nextProps.interval ||
+ this.props.fields !== nextProps.fields) {
return true
}
return false;
}
+ _markIt = () => {
+ const { account, update } = this.props
+ markNotificationRead(account, this.fields_array).then(nc => update(nc))
+ }
+
_activateInterval = (interval) => {
if (!this.interval) {
- const { account, update } = this.props;
- this.interval = setInterval(() => {
- markNotificationRead(account, this.fields_array).then(nc => update(nc));
- }, interval);
+ this.interval = setInterval(this._markIt, interval)
}
}
@@ -38,23 +41,26 @@ class MarkNotificationRead extends React.Component {
}
componentDidMount() {
- const { account, fields, update, interval, delay } = this.props;
- this.fields_array = fields.replace(/\s/g,'').split(',');
- const firstMark = () => {
- markNotificationRead(account, this.fields_array).then(nc => update(nc))
- }
+ const { fields, interval, delay } = this.props;
+ this.fields_array = fields.replace(/\s/g,'').split(',')
if (delay) {
- setTimeout(firstMark, delay)
+ setTimeout(this._markIt, delay)
}
if (interval) {
this._activateInterval(interval);
} else if (!delay) {
- firstMark()
+ this._markIt()
}
}
- componentDidUpdate() {
- const { interval } = this.props
+ componentDidUpdate(prevProps) {
+ const { interval, delay, fields } = this.props
+ if (prevProps.fields !== fields) {
+ this.fields_array = fields.replace(/\s/g,'').split(',')
+ if (delay) {
+ setTimeout(this._markIt, delay)
+ }
+ }
if (interval) {
this._activateInterval(interval);
} else {
diff --git a/src/components/modules/MessagesTopCenter.jsx b/src/components/modules/MessagesTopCenter.jsx
index 23201bd2..7a884fc9 100644
--- a/src/components/modules/MessagesTopCenter.jsx
+++ b/src/components/modules/MessagesTopCenter.jsx
@@ -132,7 +132,7 @@ class MessagesTopCenter extends React.Component {
btnType = 'join'
} else if (isModer) {
myStatus = tt('msgs_group_dropdown.moder')
- btnType = 'retire'
+ //btnType = 'retire'
} else if (isMember) {
btnType = 'retire'
} else if (member_type === 'banned') {
diff --git a/src/components/modules/groups/GroupMembers.jsx b/src/components/modules/groups/GroupMembers.jsx
index 18e45034..1db996df 100644
--- a/src/components/modules/groups/GroupMembers.jsx
+++ b/src/components/modules/groups/GroupMembers.jsx
@@ -23,8 +23,7 @@ class GroupMembers extends React.Component {
constructor(props) {
super(props)
this.state = {
- showModers: false,
- showPendings: !!props.showPendings,
+ currentTab: props.current_tab || 'member',
}
}
@@ -47,28 +46,25 @@ class GroupMembers extends React.Component {
init = (force = false) => {
const { initialized } = this.state
if (!initialized || force) {
- const { currentGroup } = this.props
+ const { currentGroup, username } = this.props
if (currentGroup) {
const group = currentGroup
- const memberTypes = ['moder']
+ let { amModer } = getRoleInGroup(group, username)
+
+ const memberTypes = []
const sortConditions = []
- const { showPendings, showBanneds, showModers } = this.state
- if (!showModers) memberTypes.push('member')
- if (showPendings) {
- memberTypes.push('pending')
- sortConditions.push({
- member_type: 'pending',
- direction: 'up'
- })
- }
- if (showBanneds) {
- memberTypes.push('banned')
- sortConditions.push({
- member_type: 'banned',
- direction: 'up'
- })
+ const { currentTab } = this.state
+ if (!amModer && currentTab === 'member') {
+ memberTypes.push('moder')
+ memberTypes.push('member')
+ } else if (currentTab) {
+ memberTypes.push(currentTab)
}
+ // sortConditions.push({
+ // member_type: 'banned',
+ // direction: 'up'
+ // })
this.props.fetchGroupMembers(group, memberTypes, sortConditions)
this.setState({
@@ -78,37 +74,12 @@ class GroupMembers extends React.Component {
}
}
- toggleModers = (e) => {
- this.setState({
- showModers: !this.state.showModers
- }, () => {
- this.init(true)
- })
- }
-
- togglePendings = (e) => {
- const { checked } = e.target
- this.setState({
- showPendings: checked
- }, () => {
- this.init(true)
- })
- }
-
- toggleBanneds = (e) => {
- const { checked } = e.target
- this.setState({
- showBanneds: checked
- }, () => {
- this.init(true)
- })
- }
-
onAddAccount = (e) => {
try {
const { value } = e.target
const member = value
- const member_type = 'member'
+ const { currentTab } = this.state
+ const member_type = currentTab
const { username, currentGroup } = this.props
const { creatingNew } = currentGroup
@@ -133,20 +104,39 @@ class GroupMembers extends React.Component {
}
}
- _renderMemberTypeSwitch = () => {
+ _renderMemberTypeSwitch = (amModer, ownerRight) => {
const { currentGroup, } = this.props
const { moders, members, } = currentGroup
- const { showModers } = this.state
- const disabled = !moders
- return