Refactor Views by cleaning the code, relying on apolloCache and improving performances (#4516)
* Wip refactoring view * Post merge conflicts * Fix review * Add create view capability * Fix create object missing view * Fix tests
This commit is contained in:
+1
-1
@@ -24,7 +24,7 @@ describe('useListenScroll', () => {
|
||||
const { result } = renderHook(
|
||||
() => {
|
||||
useListenScroll({ scrollableRef: containerRef });
|
||||
const isScrolling = useRecoilValue(isScrollingState());
|
||||
const isScrolling = useRecoilValue(isScrollingState);
|
||||
|
||||
return { isScrolling };
|
||||
},
|
||||
|
||||
@@ -15,7 +15,7 @@ export const useListenScroll = <T extends Element>({
|
||||
const hideScrollBarsCallback = useRecoilCallback(
|
||||
({ snapshot }) =>
|
||||
() => {
|
||||
const isScrolling = snapshot.getLoadable(isScrollingState()).getValue();
|
||||
const isScrolling = snapshot.getLoadable(isScrollingState).getValue();
|
||||
|
||||
if (!isScrolling) {
|
||||
scrollableRef.current?.classList.remove('scrolling');
|
||||
@@ -27,13 +27,13 @@ export const useListenScroll = <T extends Element>({
|
||||
const handleScrollStart = useRecoilCallback(
|
||||
({ set }) =>
|
||||
(event: Event) => {
|
||||
set(isScrollingState(), true);
|
||||
set(isScrollingState, true);
|
||||
scrollableRef.current?.classList.add('scrolling');
|
||||
|
||||
const target = event.target as HTMLElement;
|
||||
|
||||
set(scrollTopState(), target.scrollTop);
|
||||
set(scrollLeftState(), target.scrollLeft);
|
||||
set(scrollTopState, target.scrollTop);
|
||||
set(scrollLeftState, target.scrollLeft);
|
||||
},
|
||||
[scrollableRef],
|
||||
);
|
||||
@@ -41,7 +41,7 @@ export const useListenScroll = <T extends Element>({
|
||||
const handleScrollEnd = useRecoilCallback(
|
||||
({ set }) =>
|
||||
() => {
|
||||
set(isScrollingState(), false);
|
||||
set(isScrollingState, false);
|
||||
debounce(hideScrollBarsCallback, 1000)();
|
||||
},
|
||||
[hideScrollBarsCallback],
|
||||
|
||||
Reference in New Issue
Block a user