Use bindActionCreators in StickerCreator
This commit is contained in:
parent
ba5e2ff6e5
commit
d6924c0088
4 changed files with 40 additions and 26 deletions
|
@ -20,10 +20,12 @@ export const ShareStage = () => {
|
||||||
const images = stickersDuck.useOrderedImagePaths();
|
const images = stickersDuck.useOrderedImagePaths();
|
||||||
const shareUrl = stickersDuck.usePackUrl();
|
const shareUrl = stickersDuck.usePackUrl();
|
||||||
const [linkCopied, setLinkCopied] = React.useState(false);
|
const [linkCopied, setLinkCopied] = React.useState(false);
|
||||||
const onCopy = React.useCallback(() => setLinkCopied(true), [setLinkCopied]);
|
const onCopy = React.useCallback(() => {
|
||||||
const resetLinkCopied = React.useCallback(() => setLinkCopied(false), [
|
setLinkCopied(true);
|
||||||
setLinkCopied,
|
}, [setLinkCopied]);
|
||||||
]);
|
const resetLinkCopied = React.useCallback(() => {
|
||||||
|
setLinkCopied(false);
|
||||||
|
}, [setLinkCopied]);
|
||||||
|
|
||||||
const handleNext = React.useCallback(() => {
|
const handleNext = React.useCallback(() => {
|
||||||
window.close();
|
window.close();
|
||||||
|
|
|
@ -11,7 +11,9 @@ import { encryptAndUpload } from '../../util/preload';
|
||||||
import { useI18n } from '../../util/i18n';
|
import { useI18n } from '../../util/i18n';
|
||||||
import { Toaster } from '../../components/Toaster';
|
import { Toaster } from '../../components/Toaster';
|
||||||
|
|
||||||
const handleCancel = () => history.push('/add-meta');
|
const handleCancel = () => {
|
||||||
|
history.push('/add-meta');
|
||||||
|
};
|
||||||
|
|
||||||
export const UploadStage = () => {
|
export const UploadStage = () => {
|
||||||
const i18n = useI18n();
|
const i18n = useI18n();
|
||||||
|
@ -24,8 +26,11 @@ export const UploadStage = () => {
|
||||||
const [complete, setComplete] = React.useState(0);
|
const [complete, setComplete] = React.useState(0);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
// tslint:disable-next-line: no-floating-promises
|
||||||
(async () => {
|
(async () => {
|
||||||
const onProgress = () => setComplete(i => i + 1);
|
const onProgress = () => {
|
||||||
|
setComplete(i => i + 1);
|
||||||
|
};
|
||||||
try {
|
try {
|
||||||
const packMeta = await encryptAndUpload(
|
const packMeta = await encryptAndUpload(
|
||||||
{ title, author },
|
{ title, author },
|
||||||
|
@ -36,7 +41,10 @@ export const UploadStage = () => {
|
||||||
actions.setPackMeta(packMeta);
|
actions.setPackMeta(packMeta);
|
||||||
history.push('/share');
|
history.push('/share');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
actions.addToast('StickerCreator--Toasts--errorUploading', [e.message]);
|
actions.addToast({
|
||||||
|
key: 'StickerCreator--Toasts--errorUploading',
|
||||||
|
subs: [e.message],
|
||||||
|
});
|
||||||
history.push('/add-meta');
|
history.push('/add-meta');
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -59,7 +59,9 @@ const InnerGrid = SortableContainer(
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
window.log.error('Error processing image:', e);
|
window.log.error('Error processing image:', e);
|
||||||
actions.removeSticker(path);
|
actions.removeSticker(path);
|
||||||
actions.addToast('StickerCreator--Toasts--errorProcessing');
|
actions.addToast({
|
||||||
|
key: 'StickerCreator--Toasts--errorProcessing',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,6 +11,7 @@ import { useDispatch, useSelector } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import { clamp, find, isNumber, pull, remove, take, uniq } from 'lodash';
|
import { clamp, find, isNumber, pull, remove, take, uniq } from 'lodash';
|
||||||
import { SortEnd } from 'react-sortable-hoc';
|
import { SortEnd } from 'react-sortable-hoc';
|
||||||
|
import { bindActionCreators } from 'redux';
|
||||||
import arrayMove from 'array-move';
|
import arrayMove from 'array-move';
|
||||||
import { AppState } from '../reducer';
|
import { AppState } from '../reducer';
|
||||||
import { PackMetaData, WebpData } from '../../util/preload';
|
import { PackMetaData, WebpData } from '../../util/preload';
|
||||||
|
@ -268,24 +269,25 @@ export const useStickerActions = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
return useMemo(
|
return useMemo(
|
||||||
() => ({
|
() =>
|
||||||
addWebp: (data: WebpData) => dispatch(addWebp(data)),
|
bindActionCreators(
|
||||||
initializeStickers: (paths: Array<string>) =>
|
{
|
||||||
dispatch(initializeStickers(paths)),
|
addWebp,
|
||||||
removeSticker: (src: string) => dispatch(removeSticker(src)),
|
initializeStickers,
|
||||||
moveSticker: (sortEnd: SortEnd) => dispatch(moveSticker(sortEnd)),
|
removeSticker,
|
||||||
setCover: (webp: WebpData) => dispatch(setCover(webp)),
|
moveSticker,
|
||||||
setEmoji: (p: { id: string; emoji: EmojiPickDataType }) =>
|
setCover,
|
||||||
dispatch(setEmoji(p)),
|
setEmoji,
|
||||||
setTitle: (title: string) => dispatch(setTitle(title)),
|
setTitle,
|
||||||
setAuthor: (author: string) => dispatch(setAuthor(author)),
|
setAuthor,
|
||||||
setPackMeta: (e: PackMetaData) => dispatch(setPackMeta(e)),
|
setPackMeta,
|
||||||
addToast: (key: string, subs?: Array<number>) =>
|
addToast,
|
||||||
dispatch(addToast({ key, subs })),
|
dismissToast,
|
||||||
dismissToast: () => dispatch(dismissToast()),
|
reset,
|
||||||
reset: () => dispatch(reset()),
|
resetStatus,
|
||||||
resetStatus: () => dispatch(resetStatus()),
|
},
|
||||||
}),
|
dispatch
|
||||||
|
),
|
||||||
[dispatch]
|
[dispatch]
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue