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,
|
saveAttachmentToDisk,
|
||||||
timestamp,
|
timestamp,
|
||||||
});
|
});
|
||||||
this.showToast(Whisper.FileSavedToast, { fullPath });
|
|
||||||
|
if (fullPath) {
|
||||||
|
this.showToast(Whisper.FileSavedToast, { fullPath });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onItemClick = async ({ message, attachment, type }) => {
|
const onItemClick = async ({ message, attachment, type }) => {
|
||||||
|
@ -2001,7 +2004,10 @@
|
||||||
saveAttachmentToDisk,
|
saveAttachmentToDisk,
|
||||||
timestamp,
|
timestamp,
|
||||||
});
|
});
|
||||||
this.showToast(Whisper.FileSavedToast, { fullPath });
|
|
||||||
|
if (fullPath) {
|
||||||
|
this.showToast(Whisper.FileSavedToast, { fullPath });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async displayTapToViewMessage(messageId) {
|
async displayTapToViewMessage(messageId) {
|
||||||
|
@ -2205,7 +2211,10 @@
|
||||||
saveAttachmentToDisk,
|
saveAttachmentToDisk,
|
||||||
timestamp: options.message.get('sent_at'),
|
timestamp: options.message.get('sent_at'),
|
||||||
});
|
});
|
||||||
this.showToast(Whisper.FileSavedToast, { fullPath });
|
|
||||||
|
if (fullPath) {
|
||||||
|
this.showToast(Whisper.FileSavedToast, { fullPath });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
|
|
|
@ -105,6 +105,15 @@ export class Quote extends React.Component<Props, State> {
|
||||||
onClick();
|
onClick();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
public handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
||||||
|
const { onClick } = this.props;
|
||||||
|
|
||||||
|
if (onClick) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
onClick();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public handleImageError = () => {
|
public handleImageError = () => {
|
||||||
// tslint:disable-next-line no-console
|
// tslint:disable-next-line no-console
|
||||||
|
@ -381,7 +390,7 @@ export class Quote extends React.Component<Props, State> {
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
onClick={onClick}
|
onClick={this.handleClick}
|
||||||
onKeyDown={this.handleKeyDown}
|
onKeyDown={this.handleKeyDown}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'module-quote',
|
'module-quote',
|
||||||
|
|
|
@ -339,7 +339,7 @@ export const save = async ({
|
||||||
name: string;
|
name: string;
|
||||||
}) => Promise<{ name: string; fullPath: string }>;
|
}) => Promise<{ name: string; fullPath: string }>;
|
||||||
timestamp?: number;
|
timestamp?: number;
|
||||||
}): Promise<string> => {
|
}): Promise<string | null> => {
|
||||||
if (!attachment.path && !attachment.data) {
|
if (!attachment.path && !attachment.data) {
|
||||||
throw new Error('Attachment had neither path nor data');
|
throw new Error('Attachment had neither path nor data');
|
||||||
}
|
}
|
||||||
|
@ -349,12 +349,16 @@ export const save = async ({
|
||||||
: attachment.data;
|
: attachment.data;
|
||||||
const name = getSuggestedFilename({ attachment, timestamp, index });
|
const name = getSuggestedFilename({ attachment, timestamp, index });
|
||||||
|
|
||||||
const { fullPath } = await saveAttachmentToDisk({
|
const result = await saveAttachmentToDisk({
|
||||||
data,
|
data,
|
||||||
name,
|
name,
|
||||||
});
|
});
|
||||||
|
|
||||||
return fullPath;
|
if (!result) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.fullPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getSuggestedFilename = ({
|
export const getSuggestedFilename = ({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue