Skip to content

Commit

Permalink
Merge pull request #87 from ulu-telegram/master
Browse files Browse the repository at this point in the history
deploy
  • Loading branch information
ulugmer authored Nov 16, 2023
2 parents 18cf70b + 4f7eaff commit f50de77
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 29 deletions.
39 changes: 33 additions & 6 deletions src/components/main/CommandMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const SuggestedContacts: FC<SuggestedContactsProps> = ({ topUserIds, usersById,
};

interface HomePageProps {
setPages: (pages: string[]) => void;
/* setPages: (pages: string[]) => void; */
commandArchiveAll: () => void;
topUserIds: string[];
usersById: Record<string, ApiUser>;
Expand All @@ -120,6 +120,9 @@ interface HomePageProps {
handleSupport: () => void;
handleFAQ: () => void;
handleChangelog: () => void;
handleSelectNewGroup: () => void;
handleSelectNewChannel: () => void;
handleCreateFolder: () => void;
}

interface CreateNewPageProps {
Expand All @@ -129,17 +132,38 @@ interface CreateNewPageProps {
}

const HomePage: React.FC<HomePageProps> = ({
setPages, commandArchiveAll, topUserIds, usersById, close,
/* setPages, */commandArchiveAll, topUserIds, usersById, close,
handleSearchFocus, handleOpenSavedMessages, handleSelectSettings,
handleSelectArchived, handleOpenInbox, menuItems, saveAPIKey,
handleSupport, handleFAQ, handleChangelog,
handleSupport, handleFAQ, handleChangelog, handleSelectNewGroup, handleCreateFolder, handleSelectNewChannel,
}) => {
return (
<>
{topUserIds && usersById && <SuggestedContacts topUserIds={topUserIds} usersById={usersById} close={close} />}
<Command.Group heading="Create new...">
<Command.Item onSelect={() => setPages(['home', 'createNew'])}>
<i className="icon icon-add" /><span>Create new...</span>
<Command.Item onSelect={handleSelectNewGroup}>
<i className="icon icon-group" /><span>Create new group</span>
<span className="shortcuts">
{IS_ARC_BROWSER ? (
<>
<span className="kbd"></span>
<span className="kbd"></span>
<span className="kbd">C</span>
</>
) : (
<>
<span className="kbd"></span>
<span className="kbd"></span>
<span className="kbd">C</span>
</>
)}
</span>
</Command.Item>
<Command.Item onSelect={handleSelectNewChannel}>
<i className="icon icon-channel" /><span>Create new channel</span>
</Command.Item>
<Command.Item onSelect={handleCreateFolder}>
<i className="icon icon-folder" /><span>Create new folder</span>
</Command.Item>
</Command.Group>
<CommandSeparator />
Expand Down Expand Up @@ -417,7 +441,7 @@ const CommandMenu: FC<CommandMenuProps> = ({ topUserIds, usersById }) => {
<Command.Empty>No results found.</Command.Empty>
{activePage === 'home' && (
<HomePage
setPages={setPages}
/* setPages={setPages} */
commandArchiveAll={commandArchiveAll}
topUserIds={topUserIds}
usersById={usersById}
Expand All @@ -432,6 +456,9 @@ const CommandMenu: FC<CommandMenuProps> = ({ topUserIds, usersById }) => {
handleFAQ={handleFAQ}
handleChangelog={handleChangelog}
close={close}
handleSelectNewGroup={handleSelectNewGroup}
handleSelectNewChannel={handleSelectNewChannel}
handleCreateFolder={handleCreateFolder}
/>
)}
{activePage === 'createNew' && (
Expand Down
2 changes: 1 addition & 1 deletion src/components/middle/MessageList.scss
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@
transition: transform var(--layer-transition);

.messages-container {
width: calc(100% - var(--right-column-width));
width: 100%;
}

body.no-right-column-animations & {
Expand Down
2 changes: 1 addition & 1 deletion src/components/middle/MiddleColumn.scss
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
}

@media (min-width: 1276px) {
width: calc(100% - var(--right-column-width));
width: 100%;

#Main.right-column-open & {
transform: translate3d(calc(var(--right-column-width) / -2), 0, 0);
Expand Down
36 changes: 16 additions & 20 deletions src/hooks/useMultitouchBackSwipe.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
import { useEffect, useState } from 'react';
import { ipcRenderer } from 'electron';

const useMultitouchBackSwipe = (callback: () => void, threshold = 100) => {
const [scrollPosition, setScrollPosition] = useState(0);
const useMultitouchBackSwipe = (onSwipeBack: () => void) => {
const [scrollStart, setScrollStart] = useState(0);
const [scrollEnd, setScrollEnd] = useState(0);

useEffect(() => {
const handleScrollTouchBegin = () => {
setScrollPosition(0); // Сброс позиции прокрутки при начале жеста
const handleGestureScrollBegin = (event: any) => {
setScrollStart(event.scrollLeft); // Запомнить начальное положение прокрутки
};

const handleScrollTouchEnd = () => {
if (scrollPosition > threshold) {
callback(); // Вызов callback, если прокрутка превысила порог
}
};
const handleGestureScrollEnd = (event: any) => {
setScrollEnd(event.scrollLeft); // Запомнить конечное положение прокрутки

const handleWheel = (e: { deltaX: number }) => {
setScrollPosition((prev) => prev + e.deltaX); // Обновление позиции прокрутки
// Проверить, был ли свайп слева направо
if (scrollEnd > scrollStart) {
onSwipeBack();
}
};

document.addEventListener('wheel', handleWheel);
ipcRenderer.on('scroll-touch-begin', handleScrollTouchBegin);
ipcRenderer.on('scroll-touch-end', handleScrollTouchEnd);
ipcRenderer.on('gesture-scroll-begin', handleGestureScrollBegin);
ipcRenderer.on('gesture-scroll-end', handleGestureScrollEnd);

return () => {
document.removeEventListener('wheel', handleWheel);
ipcRenderer.removeListener('scroll-touch-begin', handleScrollTouchBegin);
ipcRenderer.removeListener('scroll-touch-end', handleScrollTouchEnd);
ipcRenderer.removeListener('gesture-scroll-begin', handleGestureScrollBegin);
ipcRenderer.removeListener('gesture-scroll-end', handleGestureScrollEnd);
};
}, [callback, scrollPosition, threshold]);

return scrollPosition;
}, [scrollStart, scrollEnd, onSwipeBack]);
};

export default useMultitouchBackSwipe;
2 changes: 1 addition & 1 deletion src/styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ $color-message-story-mention-to: #74bcff;
--border-radius-messages: 0.375rem;
--border-radius-messages-small: 0.375rem;
--border-radius-forum-avatar: 25%;
--messages-container-width: 45.5rem;
--messages-container-width: 100rem;
--right-column-width: 26.5rem;
--header-height: 3.5rem;
--custom-emoji-size: 1.25rem;
Expand Down

0 comments on commit f50de77

Please sign in to comment.