show loading while sending last config message

pull/1731/head
Audric Ackermann 4 years ago
parent ee3475f2be
commit e4dae7f408
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { SessionButton, SessionButtonColor } from '../session/SessionButton';
import { SessionWrapperModal } from '../session/SessionWrapperModal';
@ -16,11 +16,15 @@ export const AdminLeaveClosedGroupDialog = (props: Props) => {
const warningAsAdmin = `${window.i18n('leaveGroupConfirmationAdmin')}`;
const okText = window.i18n('leaveAndRemoveForEveryone');
const cancelText = window.i18n('cancel');
const [isLoading, setIsLoading] = useState(false);
const onClickOK = async () => {
setIsLoading(true);
await getConversationController()
.get(props.conversationId)
.leaveClosedGroup();
setIsLoading(false);
closeDialog();
};

@ -120,7 +120,6 @@ const onDeleteAccount = () => {
okTheme: SessionButtonColor.Danger,
onClickOk: deleteAccount,
onClickClose,
closeAfterClickOk: true,
})
);
};

@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { SessionModal } from './SessionModal';
import { SessionButton, SessionButtonColor } from './SessionButton';
import { SessionHtmlRenderer } from './SessionHTMLRenderer';
@ -9,6 +9,7 @@ import { useDispatch } from 'react-redux';
import { updateConfirmModal } from '../../state/ducks/modalDialog';
import { update } from 'lodash';
import { SpacerLG } from '../basic/Text';
import { SessionSpinner } from './SessionSpinner';
export interface SessionConfirmDialogProps {
message?: string;
@ -26,7 +27,6 @@ export interface SessionConfirmDialogProps {
sessionIcon?: SessionIconType;
iconSize?: SessionIconSize;
theme?: DefaultTheme;
closeAfterClickOk?: boolean;
shouldShowConfirm?: () => boolean | undefined;
}
@ -45,6 +45,8 @@ const SessionConfirmInner = (props: SessionConfirmDialogProps) => {
shouldShowConfirm,
} = props;
const [isLoading, setIsLoading] = useState(false);
const okText = props.okText || window.i18n('ok');
const cancelText = props.cancelText || window.i18n('cancel');
const showHeader = !!props.title;
@ -53,9 +55,16 @@ const SessionConfirmInner = (props: SessionConfirmDialogProps) => {
const messageSubText = messageSub ? 'session-confirm-main-message' : 'subtle';
const onClickOkHandler = () => {
const onClickOkHandler = async () => {
if (onClickOk) {
onClickOk();
setIsLoading(true);
try {
await onClickOk();
} catch (e) {
window.log.warn(e);
} finally {
setIsLoading(false);
}
}
window.inboxStore?.dispatch(updateConfirmModal(null));
@ -99,6 +108,8 @@ const SessionConfirmInner = (props: SessionConfirmDialogProps) => {
className="session-confirm-sub-message subtle"
html={messageSub}
/>
<SessionSpinner loading={isLoading} />
</div>
<div className="session-modal__button-group">

Loading…
Cancel
Save