add / remove moderator modals refactored. Need to remove old whisper code and files.

pull/1665/head
Warrick Corfe-Tan 4 years ago
parent eb964f8aeb
commit 7dc318aa3d

@ -1,9 +1,9 @@
.modal { .modal {
position: fixed; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
height: 100%; height: 100vh;
width: 100%; width: 100vw;
background-color: rgba(0, 0, 0, 0.3); background-color: rgba(0, 0, 0, 0.3);
padding: 0 20px; padding: 0 20px;
z-index: 100; z-index: 100;

@ -9,6 +9,7 @@ import { Flex } from '../basic/Flex';
import { ConversationModel } from '../../models/conversation'; import { ConversationModel } from '../../models/conversation';
import { ApiV2 } from '../../opengroup/opengroupV2'; import { ApiV2 } from '../../opengroup/opengroupV2';
import { processDecrypted } from '../../receiver/dataMessage'; import { processDecrypted } from '../../receiver/dataMessage';
import { SessionWrapperModal } from '../session/SessionWrapperModal';
interface Props { interface Props {
convo: ConversationModel; convo: ConversationModel;
onClose: any; onClose: any;
@ -146,12 +147,14 @@ export const AddModeratorsDialog = (props: any) => {
let channelAPI: any; let channelAPI: any;
useEffect(() => { useEffect(() => {
async function getPublicSendData { async function getPublicSendData () {
if (props.convo.isOpenGroupV1()) { if (props.convo.isOpenGroupV1()) {
channelAPI = await convo.getPublicSendData(); channelAPI = await convo.getPublicSendData();
} }
setFirstLoading(false); setFirstLoading(false);
} }
getPublicSendData();
}, []) }, [])
@ -160,7 +163,7 @@ export const AddModeratorsDialog = (props: any) => {
// if we don't have valid data entered by the user // if we don't have valid data entered by the user
const pubkey = PubKey.from(inputBoxValue); const pubkey = PubKey.from(inputBoxValue);
if (!pubkey) { if (!pubkey) {
window.log.info('invalid pubkey for adding as moderator:', this.state.inputBoxValue); window.log.info('invalid pubkey for adding as moderator:', inputBoxValue);
ToastUtils.pushInvalidPubKey(); ToastUtils.pushInvalidPubKey();
return; return;
} }
@ -211,7 +214,7 @@ export const AddModeratorsDialog = (props: any) => {
return ( return (
<SessionModal title={title} onClose={() => onClose()} theme={theme}> <SessionWrapperModal showExitIcon={true} title={title} onClose={() => onClose()} theme={theme}>
<Flex container={true} flexDirection="column" alignItems="center"> <Flex container={true} flexDirection="column" alignItems="center">
{renderContent && ( {renderContent && (
<> <>
@ -236,7 +239,7 @@ export const AddModeratorsDialog = (props: any) => {
)} )}
<SessionSpinner loading={addingInProgress || firstLoading} /> <SessionSpinner loading={addingInProgress || firstLoading} />
</Flex> </Flex>
</SessionModal> </SessionWrapperModal>
); );
} }

@ -11,6 +11,7 @@ import { ContactType, SessionMemberListItem } from '../session/SessionMemberList
import { SessionModal } from '../session/SessionModal'; import { SessionModal } from '../session/SessionModal';
import { SessionSpinner } from '../session/SessionSpinner'; import { SessionSpinner } from '../session/SessionSpinner';
import _ from 'lodash'; import _ from 'lodash';
import { SessionWrapperModal } from '../session/SessionWrapperModal';
interface Props { interface Props {
convo: ConversationModel; convo: ConversationModel;
onClose: any; onClose: any;
@ -60,7 +61,7 @@ export class RemoveModeratorsDialog extends React.Component<Props, State> {
const renderContent = !firstLoading; const renderContent = !firstLoading;
return ( return (
<SessionModal title={title} onClose={this.closeDialog} theme={this.props.theme}> <SessionWrapperModal title={title} onClose={this.closeDialog} theme={this.props.theme}>
<Flex container={true} flexDirection="column" alignItems="center"> <Flex container={true} flexDirection="column" alignItems="center">
{renderContent && ( {renderContent && (
<> <>
@ -91,7 +92,7 @@ export class RemoveModeratorsDialog extends React.Component<Props, State> {
<SessionSpinner loading={firstLoading} /> <SessionSpinner loading={firstLoading} />
</Flex> </Flex>
</SessionModal> </SessionWrapperModal>
); );
} }

@ -33,12 +33,9 @@ import { OpenGroupManagerV2 } from '../../opengroup/opengroupV2/OpenGroupManager
import { loadDefaultRooms } from '../../opengroup/opengroupV2/ApiUtil'; import { loadDefaultRooms } from '../../opengroup/opengroupV2/ApiUtil';
import { forceRefreshRandomSnodePool } from '../../session/snode_api/snodePool'; import { forceRefreshRandomSnodePool } from '../../session/snode_api/snodePool';
import { SwarmPolling } from '../../session/snode_api/swarmPolling'; import { SwarmPolling } from '../../session/snode_api/swarmPolling';
import _, { divide } from 'lodash';
import { ActionPanelOnionStatusLight, OnionPathModal } from '../OnionStatusDialog'; import { ActionPanelOnionStatusLight, OnionPathModal } from '../OnionStatusDialog';
import { EditProfileDialog } from '../EditProfileDialog'; import { EditProfileDialog } from '../EditProfileDialog';
import { StateType } from '../../state/reducer'; import { StateType } from '../../state/reducer';
import { updateConfirmModal } from "../../state/ducks/modalDialog";
import { useInView } from 'react-intersection-observer';
import { SessionConfirm } from './SessionConfirm'; import { SessionConfirm } from './SessionConfirm';
// tslint:disable-next-line: no-import-side-effect no-submodule-imports // tslint:disable-next-line: no-import-side-effect no-submodule-imports

@ -34,6 +34,8 @@ import { getDecryptedMediaUrl } from '../../../session/crypto/DecryptedAttachmen
import { deleteOpenGroupMessages } from '../../../interactions/conversation'; import { deleteOpenGroupMessages } from '../../../interactions/conversation';
import { ConversationTypeEnum } from '../../../models/conversation'; import { ConversationTypeEnum } from '../../../models/conversation';
import { SessionButtonColor } from '../SessionButton'; import { SessionButtonColor } from '../SessionButton';
import { AddModeratorsDialog } from '../../conversation/ModeratorsAddDialog';
import { RemoveModeratorsDialog } from '../../conversation/ModeratorsRemoveDialog';
@ -68,6 +70,8 @@ interface State {
// lightbox options // lightbox options
lightBoxOptions?: any; lightBoxOptions?: any;
modal: JSX.Element | null;
} }
interface Props { interface Props {
@ -102,6 +106,7 @@ export class SessionConversation extends React.Component<Props, State> {
showOptionsPane: false, showOptionsPane: false,
stagedAttachments: [], stagedAttachments: [],
isDraggingFile: false, isDraggingFile: false,
modal: null
}; };
this.compositionBoxRef = React.createRef(); this.compositionBoxRef = React.createRef();
this.messageContainerRef = React.createRef(); this.messageContainerRef = React.createRef();
@ -291,6 +296,7 @@ export class SessionConversation extends React.Component<Props, State> {
/> />
</div> </div>
{ this.state.modal ? this.state.modal : null}
<div className={classNames('conversation-item__options-pane', showOptionsPane && 'show')}> <div className={classNames('conversation-item__options-pane', showOptionsPane && 'show')}>
<SessionRightPanelWithDetails {...this.getRightPanelProps()} /> <SessionRightPanelWithDetails {...this.getRightPanelProps()} />
</div> </div>
@ -514,11 +520,29 @@ export class SessionConversation extends React.Component<Props, State> {
window.Whisper.events.trigger('leaveClosedGroup', conversation); window.Whisper.events.trigger('leaveClosedGroup', conversation);
}, },
onAddModerators: () => { onAddModerators: () => {
window.Whisper.events.trigger('addModerators', conversation); // window.Whisper.events.trigger('addModerators', conversation);
this.setState({
...this.state,
modal: (
<AddModeratorsDialog
convo={conversation}
onClose={() => this.setState({ ...this.state, modal: null })}
theme={this.props.theme}
></AddModeratorsDialog>)
})
}, },
onRemoveModerators: () => { onRemoveModerators: () => {
window.Whisper.events.trigger('removeModerators', conversation); // window.Whisper.events.trigger('removeModerators', conversation);
this.setState({
...this.state,
modal: (
<RemoveModeratorsDialog
convo={conversation}
onClose={() => this.setState({ ...this.state, modal: null })}
theme={this.props.theme}
></RemoveModeratorsDialog>)
})
}, },
onShowLightBox: (lightBoxOptions = {}) => { onShowLightBox: (lightBoxOptions = {}) => {
this.setState({ lightBoxOptions }); this.setState({ lightBoxOptions });

@ -235,10 +235,10 @@ class SessionRightPanel extends React.Component<Props, State> {
const leaveGroupString = isPublic const leaveGroupString = isPublic
? window.i18n('leaveGroup') ? window.i18n('leaveGroup')
: isKickedFromGroup : isKickedFromGroup
? window.i18n('youGotKickedFromGroup') ? window.i18n('youGotKickedFromGroup')
: left : left
? window.i18n('youLeftTheGroup') ? window.i18n('youLeftTheGroup')
: window.i18n('leaveGroup'); : window.i18n('leaveGroup');
const disappearingMessagesOptions = timerOptions.map(option => { const disappearingMessagesOptions = timerOptions.map(option => {
return { return {

Loading…
Cancel
Save