No propagate, fix 'attachment save' cancel
* Quote: Ensure that clicks don't propagate to parent * Attachment Save: Check for null; returned if user cancels out
This commit is contained in:
parent
95d393ee89
commit
bfa76b05d2
3 changed files with 29 additions and 7 deletions
|
@ -1804,7 +1804,10 @@
|
|||
saveAttachmentToDisk,
|
||||
timestamp,
|
||||
});
|
||||
this.showToast(Whisper.FileSavedToast, { fullPath });
|
||||
|
||||
if (fullPath) {
|
||||
this.showToast(Whisper.FileSavedToast, { fullPath });
|
||||
}
|
||||
};
|
||||
|
||||
const onItemClick = async ({ message, attachment, type }) => {
|
||||
|
@ -2001,7 +2004,10 @@
|
|||
saveAttachmentToDisk,
|
||||
timestamp,
|
||||
});
|
||||
this.showToast(Whisper.FileSavedToast, { fullPath });
|
||||
|
||||
if (fullPath) {
|
||||
this.showToast(Whisper.FileSavedToast, { fullPath });
|
||||
}
|
||||
},
|
||||
|
||||
async displayTapToViewMessage(messageId) {
|
||||
|
@ -2205,7 +2211,10 @@
|
|||
saveAttachmentToDisk,
|
||||
timestamp: options.message.get('sent_at'),
|
||||
});
|
||||
this.showToast(Whisper.FileSavedToast, { fullPath });
|
||||
|
||||
if (fullPath) {
|
||||
this.showToast(Whisper.FileSavedToast, { fullPath });
|
||||
}
|
||||
};
|
||||
|
||||
const props = {
|
||||
|
|
|
@ -105,6 +105,15 @@ export class Quote extends React.Component<Props, State> {
|
|||
onClick();
|
||||
}
|
||||
};
|
||||
public handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
||||
const { onClick } = this.props;
|
||||
|
||||
if (onClick) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
onClick();
|
||||
}
|
||||
};
|
||||
|
||||
public handleImageError = () => {
|
||||
// tslint:disable-next-line no-console
|
||||
|
@ -381,7 +390,7 @@ export class Quote extends React.Component<Props, State> {
|
|||
)}
|
||||
>
|
||||
<button
|
||||
onClick={onClick}
|
||||
onClick={this.handleClick}
|
||||
onKeyDown={this.handleKeyDown}
|
||||
className={classNames(
|
||||
'module-quote',
|
||||
|
|
|
@ -339,7 +339,7 @@ export const save = async ({
|
|||
name: string;
|
||||
}) => Promise<{ name: string; fullPath: string }>;
|
||||
timestamp?: number;
|
||||
}): Promise<string> => {
|
||||
}): Promise<string | null> => {
|
||||
if (!attachment.path && !attachment.data) {
|
||||
throw new Error('Attachment had neither path nor data');
|
||||
}
|
||||
|
@ -349,12 +349,16 @@ export const save = async ({
|
|||
: attachment.data;
|
||||
const name = getSuggestedFilename({ attachment, timestamp, index });
|
||||
|
||||
const { fullPath } = await saveAttachmentToDisk({
|
||||
const result = await saveAttachmentToDisk({
|
||||
data,
|
||||
name,
|
||||
});
|
||||
|
||||
return fullPath;
|
||||
if (!result) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return result.fullPath;
|
||||
};
|
||||
|
||||
export const getSuggestedFilename = ({
|
||||
|
|
Loading…
Add table
Reference in a new issue