fix seed dialog and leave group as admin dialog
This commit is contained in:
parent
fa6fcfc829
commit
b64e8bf610
|
@ -262,6 +262,7 @@
|
|||
"blockUser": "Block",
|
||||
"unblockUser": "Unblock",
|
||||
"unblocked": "Unblocked",
|
||||
"blocked": "Blocked",
|
||||
"blockedSettingsTitle": "Blocked contacts",
|
||||
"unbanUser": "Unban User",
|
||||
"unbanUserConfirm": "Are you sure you want to unban this user?",
|
||||
|
|
|
@ -52,41 +52,6 @@ export class EditProfileDialog extends React.Component<{}, State> {
|
|||
window.addEventListener('keyup', this.onKeyUp);
|
||||
}
|
||||
|
||||
public async componentDidMount() {
|
||||
const ourNumber = window.storage.get('primaryDevicePubKey');
|
||||
const conversation = await ConversationController.getInstance().getOrCreateAndWait(
|
||||
ourNumber,
|
||||
ConversationTypeEnum.PRIVATE
|
||||
);
|
||||
|
||||
const readFile = async (attachment: any) =>
|
||||
new Promise((resolve, reject) => {
|
||||
const fileReader = new FileReader();
|
||||
fileReader.onload = (e: any) => {
|
||||
const data = e.target.result;
|
||||
resolve({
|
||||
...attachment,
|
||||
data,
|
||||
size: data.byteLength,
|
||||
});
|
||||
};
|
||||
fileReader.onerror = reject;
|
||||
fileReader.onabort = reject;
|
||||
fileReader.readAsArrayBuffer(attachment.file);
|
||||
});
|
||||
|
||||
const avatarPath = conversation.getAvatarPath();
|
||||
const profile = conversation.getLokiProfile();
|
||||
const displayName = profile && profile.displayName;
|
||||
|
||||
this.setState({
|
||||
...this.state,
|
||||
profileName: profile.profileName,
|
||||
avatar: avatarPath || '',
|
||||
setProfileName: profile.profileName,
|
||||
});
|
||||
}
|
||||
|
||||
public render() {
|
||||
const i18n = window.i18n;
|
||||
|
||||
|
@ -179,9 +144,9 @@ export class EditProfileDialog extends React.Component<{}, State> {
|
|||
<SessionIconButton
|
||||
iconType={SessionIconType.QR}
|
||||
iconSize={SessionIconSize.Small}
|
||||
iconColor={'#000000'}
|
||||
iconColor={'rgb(0, 0, 0)'}
|
||||
onClick={() => {
|
||||
this.setState({ mode: 'qr' });
|
||||
this.setState(state => ({ ...state, mode: 'qr' }));
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
@ -192,16 +157,19 @@ export class EditProfileDialog extends React.Component<{}, State> {
|
|||
}
|
||||
|
||||
private fireInputEvent() {
|
||||
this.setState({ mode: 'edit' }, () => {
|
||||
const el = this.inputEl.current;
|
||||
if (el) {
|
||||
el.click();
|
||||
this.setState(
|
||||
state => ({ ...state, mode: 'edit' }),
|
||||
() => {
|
||||
const el = this.inputEl.current;
|
||||
if (el) {
|
||||
el.click();
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
private renderDefaultView() {
|
||||
const name = this.state.setProfileName ? this.state.setProfileName : this.state.profileName;
|
||||
const name = this.state.setProfileName || this.state.profileName;
|
||||
return (
|
||||
<>
|
||||
{this.renderProfileHeader()}
|
||||
|
@ -274,7 +242,6 @@ export class EditProfileDialog extends React.Component<{}, State> {
|
|||
|
||||
private onNameEdited(event: any) {
|
||||
const newName = event.target.value.replace(window.displayNameRegex, '');
|
||||
|
||||
this.setState(state => {
|
||||
return {
|
||||
...state,
|
||||
|
|
|
@ -20,12 +20,6 @@ import { useNetwork } from '../hooks/useNetwork';
|
|||
import { Snode } from '../data/data';
|
||||
import { onionPathModal } from '../state/ducks/modalDialog';
|
||||
|
||||
export type OnionPathModalType = {
|
||||
confirmText?: string;
|
||||
cancelText?: string;
|
||||
title?: string;
|
||||
};
|
||||
|
||||
export type StatusLightType = {
|
||||
glowStartDelay: number;
|
||||
glowDuration: number;
|
||||
|
@ -168,7 +162,7 @@ export const ActionPanelOnionStatusLight = (props: {
|
|||
);
|
||||
};
|
||||
|
||||
export const OnionPathModal = (props: OnionPathModalType) => {
|
||||
export const OnionPathModal = () => {
|
||||
const onConfirm = () => {
|
||||
void shell.openExternal('https://getsession.org/faq/#onion-routing');
|
||||
};
|
||||
|
|
|
@ -111,6 +111,7 @@ class SessionSeedModalInner extends React.Component<{}, State> {
|
|||
const fgColor = '#1B1B1B';
|
||||
|
||||
const hexEncodedSeed = mn_decode(this.state.recoveryPhrase, 'english');
|
||||
const onClose = () => window.inboxStore?.dispatch(recoveryPhraseModal(null));
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -132,6 +133,7 @@ class SessionSeedModalInner extends React.Component<{}, State> {
|
|||
this.copyRecoveryPhrase(this.state.recoveryPhrase);
|
||||
}}
|
||||
/>
|
||||
<SessionButton text={i18n('cancel')} onClick={onClose} />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
|
|
@ -29,6 +29,7 @@ import {
|
|||
showInviteContactByConvoId,
|
||||
showLeaveGroupByConvoId,
|
||||
showRemoveModeratorsByConvoId,
|
||||
showUpdateGroupMembersByConvoId,
|
||||
showUpdateGroupNameByConvoId,
|
||||
} from '../../../interactions/conversationInteractions';
|
||||
|
||||
|
@ -326,7 +327,7 @@ class SessionRightPanel extends React.Component<Props, State> {
|
|||
className="group-settings-item"
|
||||
role="button"
|
||||
onClick={async () => {
|
||||
await showUpdateGroupNameByConvoId(id);
|
||||
await showUpdateGroupMembersByConvoId(id);
|
||||
}}
|
||||
>
|
||||
{window.i18n('groupMembers')}
|
||||
|
|
|
@ -11,8 +11,6 @@ import {
|
|||
} from '../../../state/ducks/modalDialog';
|
||||
import { ConversationController } from '../../../session/conversations';
|
||||
import { UserUtils } from '../../../session/utils';
|
||||
import { AdminLeaveClosedGroupDialog } from '../../conversation/AdminLeaveClosedGroupDialog';
|
||||
import { useTheme } from 'styled-components';
|
||||
import {
|
||||
blockConvoById,
|
||||
clearNickNameByConvoId,
|
||||
|
@ -23,6 +21,7 @@ import {
|
|||
setNotificationForConvoId,
|
||||
showAddModeratorsByConvoId,
|
||||
showInviteContactByConvoId,
|
||||
showLeaveGroupByConvoId,
|
||||
showRemoveModeratorsByConvoId,
|
||||
showUpdateGroupNameByConvoId,
|
||||
unblockConvoById,
|
||||
|
@ -187,49 +186,17 @@ export function getLeaveGroupMenuItem(
|
|||
if (
|
||||
showLeaveGroup(Boolean(isKickedFromGroup), Boolean(left), Boolean(isGroup), Boolean(isPublic))
|
||||
) {
|
||||
const dispatch = useDispatch();
|
||||
const theme = useTheme();
|
||||
const conversation = ConversationController.getInstance().get(conversationId);
|
||||
|
||||
const onClickClose = () => {
|
||||
dispatch(updateConfirmModal(null));
|
||||
};
|
||||
|
||||
const openConfirmationModal = () => {
|
||||
if (!conversation.isGroup()) {
|
||||
throw new Error('showLeaveGroupDialog() called with a non group convo.');
|
||||
}
|
||||
|
||||
const title = window.i18n('leaveGroup');
|
||||
const message = window.i18n('leaveGroupConfirmation');
|
||||
const ourPK = UserUtils.getOurPubKeyStrFromCache();
|
||||
const isAdmin = (conversation.get('groupAdmins') || []).includes(ourPK);
|
||||
const isClosedGroup = conversation.get('is_medium_group') || false;
|
||||
|
||||
// if this is not a closed group, or we are not admin, we can just show a confirmation dialog
|
||||
if (!isClosedGroup || (isClosedGroup && !isAdmin)) {
|
||||
dispatch(
|
||||
updateConfirmModal({
|
||||
title,
|
||||
message,
|
||||
onClickOk: () => {
|
||||
void conversation.leaveClosedGroup();
|
||||
onClickClose();
|
||||
},
|
||||
onClickClose,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
dispatch(
|
||||
adminLeaveClosedGroup({
|
||||
conversationId,
|
||||
})
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return <Item onClick={openConfirmationModal}>{window.i18n('leaveGroup')}</Item>;
|
||||
return (
|
||||
<Item
|
||||
onClick={() => {
|
||||
showLeaveGroupByConvoId(conversationId);
|
||||
}}
|
||||
>
|
||||
{window.i18n('leaveGroup')}
|
||||
</Item>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
openGroupV2ConversationIdRegex,
|
||||
} from '../opengroup/utils/OpenGroupUtils';
|
||||
import { getV2OpenGroupRoom } from '../data/opengroups';
|
||||
import { ToastUtils } from '../session/utils';
|
||||
import { ToastUtils, UserUtils } from '../session/utils';
|
||||
import {
|
||||
ConversationModel,
|
||||
ConversationNotificationSettingType,
|
||||
|
@ -17,6 +17,7 @@ import _ from 'lodash';
|
|||
import { ConversationController } from '../session/conversations';
|
||||
import { BlockedNumberController } from '../util/blockedNumberController';
|
||||
import {
|
||||
adminLeaveClosedGroup,
|
||||
changeNickNameModal,
|
||||
updateAddModeratorsModal,
|
||||
updateConfirmModal,
|
||||
|
@ -194,8 +195,40 @@ export async function showUpdateGroupMembersByConvoId(conversationId: string) {
|
|||
|
||||
export function showLeaveGroupByConvoId(conversationId: string) {
|
||||
const conversation = ConversationController.getInstance().get(conversationId);
|
||||
throw new Error('Audric TODO');
|
||||
window.Whisper.events.trigger('leaveClosedGroup', conversation);
|
||||
|
||||
if (!conversation.isGroup()) {
|
||||
throw new Error('showLeaveGroupDialog() called with a non group convo.');
|
||||
}
|
||||
|
||||
const title = window.i18n('leaveGroup');
|
||||
const message = window.i18n('leaveGroupConfirmation');
|
||||
const ourPK = UserUtils.getOurPubKeyStrFromCache();
|
||||
const isAdmin = (conversation.get('groupAdmins') || []).includes(ourPK);
|
||||
const isClosedGroup = conversation.get('is_medium_group') || false;
|
||||
|
||||
// if this is not a closed group, or we are not admin, we can just show a confirmation dialog
|
||||
if (!isClosedGroup || (isClosedGroup && !isAdmin)) {
|
||||
const onClickClose = () => {
|
||||
window.inboxStore?.dispatch(updateConfirmModal(null));
|
||||
};
|
||||
window.inboxStore?.dispatch(
|
||||
updateConfirmModal({
|
||||
title,
|
||||
message,
|
||||
onClickOk: () => {
|
||||
void conversation.leaveClosedGroup();
|
||||
onClickClose();
|
||||
},
|
||||
onClickClose,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
window.inboxStore?.dispatch(
|
||||
adminLeaveClosedGroup({
|
||||
conversationId,
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
export function showInviteContactByConvoId(conversationId: string) {
|
||||
window.inboxStore?.dispatch(updateInviteContactModal({ conversationId }));
|
||||
|
|
|
@ -971,8 +971,6 @@ async function sendToGroupMembers(
|
|||
const inviteResults = await Promise.all(promises);
|
||||
const allInvitesSent = _.every(inviteResults, Boolean);
|
||||
|
||||
throw new Error('audric: TODEBUG');
|
||||
|
||||
if (allInvitesSent) {
|
||||
// if (true) {
|
||||
if (isRetry) {
|
||||
|
|
|
@ -84,7 +84,7 @@ const ModalSlice = createSlice({
|
|||
return { ...state, onionPathModal: action.payload };
|
||||
},
|
||||
recoveryPhraseModal(state, action: PayloadAction<RecoveryPhraseModalState | null>) {
|
||||
return { ...state, onionPathModal: action.payload };
|
||||
return { ...state, recoveryPhraseModal: action.payload };
|
||||
},
|
||||
adminLeaveClosedGroup(state, action: PayloadAction<AdminLeaveClosedGroupModalState | null>) {
|
||||
return { ...state, adminLeaveClosedGroup: action.payload };
|
||||
|
|
Loading…
Reference in New Issue