Skip to content

Commit

Permalink
Merge pull request #92 from ulu-telegram/master
Browse files Browse the repository at this point in the history
delpoy
  • Loading branch information
ulugmer authored Nov 16, 2023
2 parents 4ce54dc + b78845f commit 80ae152
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 60 deletions.
25 changes: 24 additions & 1 deletion src/components/middle/MessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const MessageList: FC<OwnProps & StateProps> = ({
}) => {
const {
loadViewportMessages, setScrollOffset, loadSponsoredMessages, loadMessageReactions, copyMessagesByIds,
loadMessageViews, loadPeerStoriesByIds,
loadMessageViews, loadPeerStoriesByIds, openChat,
} = getActions();

// eslint-disable-next-line no-null/no-null
Expand Down Expand Up @@ -221,6 +221,29 @@ const MessageList: FC<OwnProps & StateProps> = ({
memoFirstUnreadIdRef.current = firstUnreadId;
}, [firstUnreadId]);

useEffect(() => {
const minDeltaX = 50; // Минимальное расстояние прокрутки для активации свайпа

const handleScroll = (e: WheelEvent) => {
// Проверяем, находится ли элемент, на котором произошло событие, внутри контейнера
if (containerRef.current && containerRef.current.contains(e.target as Node)) {
// Проверяем, был ли совершен горизонтальный свайп
if (Math.abs(e.deltaX) > minDeltaX) {
// Вызываем функцию для обработки свайпа
openChat({ id: undefined });
}
}
};

// Добавляем обработчик событий к window
window.addEventListener('wheel', handleScroll, { passive: true });

// Удаляем обработчик событий при размонтировании компонента
return () => {
window.removeEventListener('wheel', handleScroll);
};
}, [containerRef]);

useEffect(() => {
if (!isCurrentUserPremium && isChannelChat && isReady) {
loadSponsoredMessages({ chatId });
Expand Down
7 changes: 1 addition & 6 deletions src/components/middle/MiddleColumn.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {
memo, useEffect, useMemo,
/* useRef, */
useState,
} from '../../lib/teact/teact';
import { getActions, withGlobal } from '../../global';
Expand Down Expand Up @@ -69,7 +70,6 @@ import useForceUpdate from '../../hooks/useForceUpdate';
import useHistoryBack from '../../hooks/useHistoryBack';
import useLang from '../../hooks/useLang';
import useLastCallback from '../../hooks/useLastCallback';
/* import useMultitouchBackSwipe from '../../hooks/useMultitouchBackSwipe'; */
import usePrevDuringAnimation from '../../hooks/usePrevDuringAnimation';
import usePrevious from '../../hooks/usePrevious';
import { useResize } from '../../hooks/useResize';
Expand Down Expand Up @@ -291,11 +291,6 @@ function MiddleColumn({
: undefined;
}, [chatId, openChat]);

/* useMultitouchBackSwipe(() => {
// Действие, выполняемое при свайпе слева направо
openChat({ id: undefined });
}); */

useSyncEffect(() => {
setDropAreaState(DropAreaState.None);
setIsNotchShown(undefined);
Expand Down
34 changes: 0 additions & 34 deletions src/hooks/useMultitouchBackSwipe.ts

This file was deleted.

Empty file.
19 changes: 0 additions & 19 deletions src/hooks/useMultitouchBackSwipe3.ts

This file was deleted.

0 comments on commit 80ae152

Please sign in to comment.