Skip to content

Commit

Permalink
Merge pull request 200ok-ch#44 from 200ok-ch/greenkeeper/react-script…
Browse files Browse the repository at this point in the history
…s-3.1.2

Update react-scripts to the latest version 🚀
  • Loading branch information
munen authored Sep 27, 2019
2 parents 6729708 + 8761a14 commit 602a7a6
Show file tree
Hide file tree
Showing 6 changed files with 2,586 additions and 2,398 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"react-motion": "^0.5.2",
"react-redux": "^7.1.0",
"react-router-dom": "^4.3.1",
"react-scripts": "^2.1.5",
"react-scripts": "3.1.2",
"redux": "^4.0.0",
"redux-linear-undo": "^1.0.8",
"redux-thunk": "^2.3.0"
Expand Down
2 changes: 1 addition & 1 deletion src/components/FileBrowser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const FileBrowser = ({
syncBackend,
additionalSyncBackendState,
}) => {
useEffect(() => syncBackend.getDirectoryListing(path), [path]);
useEffect(() => syncBackend.getDirectoryListing(path), [syncBackend, path]);

const handleLoadMoreClick = () => syncBackend.loadMoreDirectoryListing();

Expand Down
17 changes: 9 additions & 8 deletions src/components/OrgFile/components/ActionDrawer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ const ActionDrawer = ({
const [isDisplayingArrowButtons, setIsDisplayingArrowButtons] = useState(false);
const [isDisplayingCaptureButtons, setIsDisplayingCaptureButtons] = useState(false);

// Send a no-op action to take care of the bug where redux-undo won't allow the first
// action to be undone.
// Send a no-op action to take care of the bug where redux-undo
// won't allow the first action to be undone.
// FIXME: This bug is confirmed in a small test by Alain on 2019-09-27
useEffect(() => {
org.noOp();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
Expand All @@ -47,7 +49,7 @@ const ActionDrawer = ({

const mainArrowButtonBoundingRect = useMemo(
() => (!!mainArrowButton.current ? mainArrowButton.current.getBoundingClientRect() : null),
[mainArrowButton.current]
[mainArrowButton]
);

const handleUpClick = () =>
Expand Down Expand Up @@ -83,11 +85,10 @@ const ActionDrawer = ({
template.get('isAvailableInAllOrgFiles') ||
template
.get('orgFilesWhereAvailable')
.map(
availablePath =>
availablePath.trim().startsWith('/')
? availablePath.trim()
: '/' + availablePath.trim()
.map(availablePath =>
availablePath.trim().startsWith('/')
? availablePath.trim()
: '/' + availablePath.trim()
)
.includes((path || '').trim())
);
Expand Down
23 changes: 10 additions & 13 deletions src/components/OrgFile/components/CaptureModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,28 @@ import substituteTemplateVariables from '../../../../lib/capture_template_substi
export default ({ template, onCapture, headers, onClose }) => {
const [substitutedTemplate, initialCursorIndex] = useMemo(
() => substituteTemplateVariables(template.get('template')),
[template.get('template')]
[template]
);

const targetHeader = useMemo(() => headerWithPath(headers, template.get('headerPaths')), [
headers,
template.get('headerPaths'),
template,
]);

const [textareaValue, setTextareaValue] = useState(substitutedTemplate);
const [shouldPrepend, setShouldPrepend] = useState(template.get('shouldPrepend'));

const textarea = useRef(null);

useEffect(
() => {
if (textarea.current) {
textarea.current.focus();
if (initialCursorIndex !== null) {
textarea.current.selectionStart = initialCursorIndex;
textarea.current.selectionEnd = initialCursorIndex;
}
useEffect(() => {
if (textarea.current) {
textarea.current.focus();
if (initialCursorIndex !== null) {
textarea.current.selectionStart = initialCursorIndex;
textarea.current.selectionEnd = initialCursorIndex;
}
},
[textarea]
);
}
}, [textarea, initialCursorIndex]);

const handleCaptureClick = () => onCapture(template.get('id'), textareaValue, shouldPrepend);

Expand Down
81 changes: 40 additions & 41 deletions src/components/UI/Drawer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ export default ({ children, shouldIncludeCloseButton, onClose }) => {
useLayoutEffect(() => {
innerContainerHeight.current = innerContainer.current.offsetHeight;
});
const endInnerContainerDrag = () => {
setIsVisible(dragOffsetY <= innerContainerHeight.current * 0.3);
setDragOffsetY(null);
};

const handleInnerContainerClick = event => event.stopPropagation();

Expand Down Expand Up @@ -53,46 +49,49 @@ export default ({ children, shouldIncludeCloseButton, onClose }) => {
}
};

const handleTouchEndOrCancel = event => endInnerContainerDrag();

useEffect(
() => {
if (!!innerContainer.current) {
// Super annoying logic for disabling scrolling of the body when a slide up is active.
// Briefly: if we're already at the top of our Drawer and trying to scroll up, disable
// scrolling. Likewise, if we're already at the bottom of our Drawer and trying to scroll
// down, disable scrolling.
innerContainer.current.addEventListener('touchstart', handleTouchStart);
innerContainer.current.addEventListener('touchmove', handleTouchMove);
innerContainer.current.addEventListener('touchend', handleTouchEndOrCancel);
innerContainer.current.addEventListener('touchcancel', handleTouchEndOrCancel);

return () => {
innerContainer.current.removeEventListener('touchstart', handleTouchStart);
innerContainer.current.removeEventListener('touchmove', handleTouchMove);
innerContainer.current.removeEventListener('touchend', handleTouchEndOrCancel);
innerContainer.current.removeEventListener('touchcancel', handleTouchEndOrCancel);
};
} else {
return null;
}
},
[innerContainer.current, dragOffsetY]
);
useEffect(() => {
const endInnerContainerDrag = () => {
setIsVisible(dragOffsetY <= innerContainerHeight.current * 0.3);
setDragOffsetY(null);
};
const handleTouchEndOrCancel = event => endInnerContainerDrag();

if (!!innerContainer.current) {
// Super annoying logic for disabling scrolling of the body when a slide up is active.
// Briefly: if we're already at the top of our Drawer and trying to scroll up, disable
// scrolling. Likewise, if we're already at the bottom of our Drawer and trying to scroll
// down, disable scrolling.
innerContainer.current.addEventListener('touchstart', handleTouchStart);
innerContainer.current.addEventListener('touchmove', handleTouchMove);
innerContainer.current.addEventListener('touchend', handleTouchEndOrCancel);
innerContainer.current.addEventListener('touchcancel', handleTouchEndOrCancel);

// Tmp variable for cleanup. Otherwise the linter will complain
// that the `current` value will change. It suggested this tmp
// variable.
const innerContainerCurrent = innerContainer.current;

return () => {
innerContainerCurrent.removeEventListener('touchstart', handleTouchStart);
innerContainerCurrent.removeEventListener('touchmove', handleTouchMove);
innerContainerCurrent.removeEventListener('touchend', handleTouchEndOrCancel);
innerContainerCurrent.removeEventListener('touchcancel', handleTouchEndOrCancel);
};
} else {
return null;
}
}, [innerContainer, dragOffsetY]);

useEffect(
() => {
// A ridiculous hack to get around what is presumably a Mobile Safari bug in iOS 12.
// Without this, I can't scroll the inner container in the agenda view.
useEffect(() => {
// A ridiculous hack to get around what is presumably a Mobile Safari bug in iOS 12.
// Without this, I can't scroll the inner container in the agenda view.
setTimeout(() => {
innerContainer.current.style.left = '0';
setTimeout(() => {
innerContainer.current.style.left = '0';
setTimeout(() => {
innerContainer.current.style.left = '-1px';
}, 0);
innerContainer.current.style.left = '-1px';
}, 0);
},
[children]
);
}, 0);
}, [children]);

const outerClassName = classNames('drawer-outer-container', {
'drawer-outer-container--visible': isVisible,
Expand Down
Loading

0 comments on commit 602a7a6

Please sign in to comment.