Skip to content

Commit

Permalink
fix: default identity selection
Browse files Browse the repository at this point in the history
  • Loading branch information
gnekoz committed Jan 9, 2023
1 parent 0c72442 commit 0e078e4
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
t
} from '@zextras/carbonio-shell-ui';
import { some } from 'lodash';
import { useParams } from 'react-router-dom';
import { SyncDataHandler } from './views/sidebar/sync-data-handler';
import {
mailToSharedFunction,
Expand Down
2 changes: 0 additions & 2 deletions src/helpers/identities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,6 @@ const getRecipientReplyIdentity = (
settings: AccountSettings,
message: MailMessage
): MatchingReplyIdentity => {
console.log('*** settings', settings);

// Get all the available identities for the account
const identities = getIdentities(account, settings);

Expand Down
5 changes: 5 additions & 0 deletions src/types/utils/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ export type AppContext = {
setCount: (arg: number) => void;
};

export type BoardContext = {
mailId: string | MessageActionIdsType | undefined;
folderId: string | undefined;
};

export type ThemeObj = {
windowObj: Window;
breakpoints: {
Expand Down
26 changes: 13 additions & 13 deletions src/ui-actions/message-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import DeleteConvConfirm from './delete-conv-modal';
import RedirectAction from './redirect-message-action';
import { getContentForPrint, getErrorPage } from '../commons/print-conversation';
import { applyTag } from './tag-actions';
import { MailMessage, MsgActionParameters, MsgActionResult } from '../types';
import { BoardContext, MailMessage, MsgActionParameters, MsgActionResult } from '../types';
import { StoreProvider } from '../store/redux';

type MessageActionIdsType = Array<string>;
Expand Down Expand Up @@ -420,9 +420,9 @@ export function replyMsg({
label: t('action.reply', 'Reply'),
click: (ev): void => {
if (ev) ev.preventDefault();
addBoard({
addBoard<BoardContext>({
url: `${MAILS_ROUTE}/edit/${id}?action=${ActionsType.REPLY}`,
context: { mailId: id },
context: { mailId: id, folderId },
title: ''
});
}
Expand All @@ -439,9 +439,9 @@ export function replyAllMsg({
label: t('action.reply_all', 'Reply all'),
click: (ev): void => {
if (ev) ev.preventDefault();
addBoard({
addBoard<BoardContext>({
url: `${MAILS_ROUTE}/edit/${id}?action=${ActionsType.REPLY_ALL}`,
context: { mailId: id },
context: { mailId: id, folderId },
title: ''
});
}
Expand All @@ -458,9 +458,9 @@ export function forwardMsg({
label: t('action.forward', 'Forward'),
click: (ev): void => {
if (ev) ev.preventDefault();
addBoard({
addBoard<BoardContext>({
url: `${MAILS_ROUTE}/edit/${id}?action=${ActionsType.FORWARD}`,
context: { mailId: id },
context: { mailId: id, folderId },
title: ''
});
}
Expand All @@ -477,9 +477,9 @@ export function editAsNewMsg({
label: t('action.edit_as_new', 'Edit as new'),
click: (ev): void => {
if (ev) ev.preventDefault();
addBoard({
addBoard<BoardContext>({
url: `${MAILS_ROUTE}/edit/${id}?action=${ActionsType.EDIT_AS_NEW}`,
context: { mailId: id },
context: { mailId: id, folderId },
title: ''
});
}
Expand All @@ -505,9 +505,9 @@ export function editDraft({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
closeModal();
addBoard({
addBoard<BoardContext>({
url: `${MAILS_ROUTE}/edit/${id}?action=${ActionsType.EDIT_AS_DRAFT}`,
context: { mailId: id },
context: { mailId: id, folderId },
title: ''
});
},
Expand All @@ -529,9 +529,9 @@ export function editDraft({
)
});
} else {
addBoard({
addBoard<BoardContext>({
url: `${MAILS_ROUTE}/edit/${id}?action=${ActionsType.EDIT_AS_DRAFT}`,
context: { mailId: id },
context: { mailId: id, folderId },
title: ''
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ type UseGetIdentitiesPropType = {
setOpen: (arg: boolean) => void;
editorId: string;
originalMessage?: MailMessage;
folderId: string;
};
export const useGetIdentities = ({
updateEditorCb,
setOpen,
editorId,
originalMessage
originalMessage,
folderId
}: UseGetIdentitiesPropType): UseGetIdentitiesReturnType => {
const account = useUserAccount();
const settings = useUserSettings();
Expand All @@ -74,7 +76,8 @@ export const useGetIdentities = ({
const [isIdentitySet, setIsIdentitySet] = useState(false);
const [defaultIdentity, setDefaultIdentity] = useState<IdentityType>();
const allAccounts = useRoots();
const { folderId } = useParams<{ folderId: string }>();

console.log('********** folderId', folderId);

const noName = useMemo(() => t('label.no_name', '<No Name>'), [t]);

Expand Down
8 changes: 5 additions & 3 deletions src/views/app/detail-panel/edit/parts/edit-view-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
useModal
} from '@zextras/carbonio-design-system';
import {
FOLDERS,
getBridgedFunctions,
getCurrentRoute,
minimizeBoards,
Expand All @@ -37,7 +38,7 @@ import { useDispatch } from 'react-redux';
import { useHistory, useParams } from 'react-router-dom';
import { ActionsType } from '../../../../../commons/utils';
import { sendMsg } from '../../../../../store/actions/send-msg';
import { EditViewContextType, MailAttachment } from '../../../../../types';
import { BoardContext, EditViewContextType, MailAttachment } from '../../../../../types';
import { addAttachments } from '../edit-utils';
import { useGetAttachItems } from '../edit-utils-hooks/use-get-attachment-items';
import { useGetIdentities } from '../edit-utils-hooks/use-get-identities';
Expand Down Expand Up @@ -106,7 +107,7 @@ const EditViewHeader: FC<PropType> = ({
const [isReceiptRequested, setIsReceiptRequested] = useState(editor?.requestReadReceipt ?? false);

// needs to be replaced with correct type
const boardContext = useBoard()?.context;
const boardContext = useBoard<BoardContext>()?.context;

const isSendDisabled = useMemo(() => {
const participants = concat(editor?.to, editor?.bcc, editor?.cc);
Expand All @@ -117,7 +118,8 @@ const EditViewHeader: FC<PropType> = ({
updateEditorCb,
setOpen,
editorId: editor?.editorId,
originalMessage: editor?.original
originalMessage: editor?.original,
folderId: boardContext?.folderId ?? FOLDERS.INBOX
});

const inputRef = useRef<any>();
Expand Down
4 changes: 0 additions & 4 deletions src/views/app/detail-panel/preview/mail-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,6 @@ type MailPreviewType = {
};
const MailPreview: FC<MailPreviewType> = ({ message, expanded, isAlone, isMessageView }) => {
const mailContainerRef = useRef<HTMLDivElement>(null);

console.log('*************** router', useCurrentRoute());
console.log('*************** params', useParams());

const [open, setOpen] = useState(expanded || isAlone);

const onClick = useCallback(() => {
Expand Down

0 comments on commit 0e078e4

Please sign in to comment.