Skip to content

Commit

Permalink
focus on rightclick
Browse files Browse the repository at this point in the history
  • Loading branch information
TheUltDev committed Feb 15, 2025
1 parent 43c31e5 commit b1837d8
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 23 deletions.
3 changes: 2 additions & 1 deletion client/src/media/dir/hooks/use-entry-hfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function useEntryHfs({item, cmd, opt, tmp}: EntryHfsProps) {
const put = usePut();

// Spatial navigation
const {focused, ref: refFoc} = useFocusable({
const {focused, ref: refFoc, focusSelf: foc} = useFocusable({
onFocus: (_lay, _props, e) => tmp
? undefined
: cmd.select(item, e.event as unknown as GestureResponderEvent),
Expand Down Expand Up @@ -93,5 +93,6 @@ export function useEntryHfs({item, cmd, opt, tmp}: EntryHfsProps) {
cmd: $.bind(cmd, item),
opt: {...opt, focused, dropping},
ref: [refDnd, refFoc],
foc,
};
}
3 changes: 2 additions & 1 deletion client/src/media/dir/hooks/use-entry-torrent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function useEntryTorrent({item, cmd, opt}: EntryTorrentProps) {
const [dragging, setDragging] = useState(false);

// Spatial navigation
const {focused, ref: refFoc} = useFocusable({
const {focused, ref: refFoc, focusSelf: foc} = useFocusable({
onEnterPress: () => cmd.download(item),
});

Expand All @@ -40,5 +40,6 @@ export function useEntryTorrent({item, cmd, opt}: EntryTorrentProps) {
cmd: $.bind(cmd, item),
opt: {...opt, focused, dragging},
ref: [refDnd, refFoc],
foc,
};
}
3 changes: 2 additions & 1 deletion client/src/media/dir/hooks/use-entry-zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function useEntryZip({item, cmd, opt}: EntryZipProps) {
const [dragging, setDragging] = useState(false);

// Spatial navigation
const {focused, ref: refFoc} = useFocusable({
const {focused, ref: refFoc, focusSelf: foc} = useFocusable({
onEnterPress: () => cmd.extract(item),
});

Expand All @@ -40,5 +40,6 @@ export function useEntryZip({item, cmd, opt}: EntryZipProps) {
cmd: $.bind(cmd, item),
opt: {...opt, focused, dragging},
ref: [refDnd, refFoc],
foc,
};
}
4 changes: 2 additions & 2 deletions client/src/media/dir/stacks/entry-hfs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ export interface EntryHfsProps {
export function EntryHfs(props: EntryHfsProps) {
const {item, tmp} = props;
const {name, size, isFile} = item;
const {ext, cmd, opt, ref} = useEntryHfs(props);
const {ext, cmd, opt, ref, foc} = useEntryHfs(props);
const dir = !isFile;

return (
<Touch
refs={ref}
onPress={cmd.select}
onDoublePress={dir ? () => cmd.open(true) : undefined}>
<MenuHfs {...{item, cmd}} on={open => open && ref[0]?.current?.focus()}>
<MenuHfs {...{item, cmd}} on={() => foc()}>
<ListRow {...{name, size, ext, dir, tmp, opt}} img={cmd.thumbnail}/>
</MenuHfs>
</Touch>
Expand Down
4 changes: 2 additions & 2 deletions client/src/media/dir/stacks/entry-torrent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface EntryTorrentProps {
export function EntryTorrent(props: EntryTorrentProps) {
const {item} = props;
const {name, length} = item;
const {ext, cmd, opt, ref} = useEntryTorrent(props);
const {ext, cmd, opt, ref, foc} = useEntryTorrent(props);
const size = length;
const dir = false;

Expand All @@ -23,7 +23,7 @@ export function EntryTorrent(props: EntryTorrentProps) {
refs={ref}
onPress={cmd.download}
onDoublePress={dir ? cmd.download : undefined}>
<MenuTorrent {...{item, cmd, on: open => open && ref[0]?.current?.focus()}}>
<MenuTorrent {...{item, cmd}} on={() => foc()}>
<ListRow {...{name, size, ext, dir, opt}}/>
</MenuTorrent>
</Touch>
Expand Down
4 changes: 2 additions & 2 deletions client/src/media/dir/stacks/entry-zip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ export interface EntryZipProps {
export function EntryZip(props: EntryZipProps) {
const {item} = props;
const {name, size, dir} = item;
const {ext, cmd, opt, ref} = useEntryZip(props);
const {ext, cmd, opt, ref, foc} = useEntryZip(props);

return (
<Touch
refs={ref}
onPress={cmd.extract}
onDoublePress={dir ? cmd.extract : undefined}>
<MenuZip {...{item, cmd, on: open => open && ref[0]?.current?.focus()}}>
<MenuZip {...{item, cmd}} on={() => foc()}>
<ListRow {...{name, size, ext, dir, opt, tmp: true}}/>
</MenuZip>
</Touch>
Expand Down
3 changes: 2 additions & 1 deletion client/src/media/dir/stacks/menu-torrent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {useMemo} from 'react';
import {useLingui} from '@lingui/react/macro';
import {MenuContext} from 'app/stacks/float';

import type {TorrentFileEntry} from 'media/dir/types/torrent';
import type {useEntryTorrent} from 'media/dir/hooks/use-entry-torrent';
import type {TorrentFileEntry} from 'media/dir/types/torrent';

export interface MenuTorrentProps extends React.PropsWithChildren {
item: TorrentFileEntry,
Expand All @@ -14,6 +14,7 @@ export interface MenuTorrentProps extends React.PropsWithChildren {
export function MenuTorrent(props: MenuTorrentProps) {
const {item, cmd, on} = props;
const {t} = useLingui();

return (
<MenuContext label={item.name} onOpenChange={on} items={useMemo(() => [
{
Expand Down
3 changes: 2 additions & 1 deletion client/src/media/dir/stacks/menu-zip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {useMemo} from 'react';
import {useLingui} from '@lingui/react/macro';
import {MenuContext} from 'app/stacks/float';

import type {ZipFileEntry} from 'media/dir/types/zip';
import type {useEntryZip} from 'media/dir/hooks/use-entry-zip';
import type {ZipFileEntry} from 'media/dir/types/zip';

export interface MenuZipProps extends React.PropsWithChildren {
item: ZipFileEntry,
Expand All @@ -14,6 +14,7 @@ export interface MenuZipProps extends React.PropsWithChildren {
export function MenuZip(props: MenuZipProps) {
const {item, cmd, on} = props;
const {t} = useLingui();

return (
<MenuContext label={item.name} onOpenChange={on} items={useMemo(() => [
{
Expand Down
4 changes: 2 additions & 2 deletions translations/ar.po
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ msgstr "المستندات"
msgid "Documents"
msgstr "المستندات"

#: ../../client/src/media/dir/stacks/menu-hfs.tsx:44
#: ../../client/src/media/dir/stacks/menu-torrent.tsx:23
msgid "Download"
msgstr "تحميل"

Expand Down Expand Up @@ -194,7 +194,7 @@ msgstr "أدخل اسم المجلد"
msgid "Enter name"
msgstr "أدخل الاسم"

#: ../../client/src/media/hooks/use-media-controls.ts:101
#: ../../client/src/media/dir/stacks/menu-zip.tsx:23
msgid "Extract"
msgstr "استخراج"

Expand Down
4 changes: 2 additions & 2 deletions translations/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ msgstr "Docs"
msgid "Documents"
msgstr "Documents"

#: ../../client/src/media/dir/stacks/menu-hfs.tsx:44
#: ../../client/src/media/dir/stacks/menu-torrent.tsx:23
msgid "Download"
msgstr "Download"

Expand Down Expand Up @@ -194,7 +194,7 @@ msgstr "Enter folder name"
msgid "Enter name"
msgstr "Enter name"

#: ../../client/src/media/hooks/use-media-controls.ts:101
#: ../../client/src/media/dir/stacks/menu-zip.tsx:23
msgid "Extract"
msgstr "Extract"

Expand Down
4 changes: 2 additions & 2 deletions translations/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ msgstr "Documentos"
msgid "Documents"
msgstr "Documentos"

#: ../../client/src/media/dir/stacks/menu-hfs.tsx:44
#: ../../client/src/media/dir/stacks/menu-torrent.tsx:23
msgid "Download"
msgstr "Descargar"

Expand Down Expand Up @@ -194,7 +194,7 @@ msgstr "Ingresa nombre de carpeta"
msgid "Enter name"
msgstr "Ingresa nombre"

#: ../../client/src/media/hooks/use-media-controls.ts:101
#: ../../client/src/media/dir/stacks/menu-zip.tsx:23
msgid "Extract"
msgstr "Extraer"

Expand Down
4 changes: 2 additions & 2 deletions translations/ja.po
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ msgstr "ドキュメント"
msgid "Documents"
msgstr "ドキュメント"

#: ../../client/src/media/dir/stacks/menu-hfs.tsx:44
#: ../../client/src/media/dir/stacks/menu-torrent.tsx:23
msgid "Download"
msgstr "ダウンロード"

Expand Down Expand Up @@ -194,7 +194,7 @@ msgstr "フォルダ名を入力"
msgid "Enter name"
msgstr "名前を入力"

#: ../../client/src/media/hooks/use-media-controls.ts:101
#: ../../client/src/media/dir/stacks/menu-zip.tsx:23
msgid "Extract"
msgstr "抽出"

Expand Down
4 changes: 2 additions & 2 deletions translations/ko.po
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ msgstr "문서"
msgid "Documents"
msgstr "문서"

#: ../../client/src/media/dir/stacks/menu-hfs.tsx:44
#: ../../client/src/media/dir/stacks/menu-torrent.tsx:23
msgid "Download"
msgstr "다운로드"

Expand Down Expand Up @@ -194,7 +194,7 @@ msgstr "폴더 이름 입력"
msgid "Enter name"
msgstr "이름 입력"

#: ../../client/src/media/hooks/use-media-controls.ts:101
#: ../../client/src/media/dir/stacks/menu-zip.tsx:23
msgid "Extract"
msgstr "추출"

Expand Down
4 changes: 2 additions & 2 deletions translations/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ msgstr "Документы"
msgid "Documents"
msgstr "Документы"

#: ../../client/src/media/dir/stacks/menu-hfs.tsx:44
#: ../../client/src/media/dir/stacks/menu-torrent.tsx:23
msgid "Download"
msgstr "Скачать"

Expand Down Expand Up @@ -194,7 +194,7 @@ msgstr "Введите имя папки"
msgid "Enter name"
msgstr "Введите имя"

#: ../../client/src/media/hooks/use-media-controls.ts:101
#: ../../client/src/media/dir/stacks/menu-zip.tsx:23
msgid "Extract"
msgstr "Извлечь"

Expand Down

0 comments on commit b1837d8

Please sign in to comment.