Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/feat_add_idb_search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: minor
---

Add encrypted room in-memory search and indexedDB persistent search
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"emojibase-data": "^17.0.0",
"eventemitter3": "^5.0.4",
"file-saver": "^2.0.5",
"flexsearch": "0.8.212",
"focus-trap-react": "^12.0.3",
"folds": "^2.6.2",
"framer-motion": "^12.42.2",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 29 additions & 2 deletions src/app/components/GlobalKeyboardShortcuts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
getHomeRoomPath,
getHomeSearchPath,
getInboxBookmarksPath,
getDirectSearchPath,
getSpaceRoomPath,
getSpaceSearchPath,
withSearchParam,
Expand All @@ -34,6 +35,8 @@
import { useSetting } from '$state/hooks/settings';
import { settingsAtom } from '$state/settings';
import { matchesShortcut } from '../keyboard/shortcuts';
import { useIsDirectRoom } from '$hooks/useRoom';
import { isKeyHotkey } from 'is-hotkey';

export function GlobalKeyboardShortcuts() {
const [shortcutOverrides] = useSetting(settingsAtom, 'shortcutOverrides');
Expand All @@ -42,6 +45,7 @@
const mx = useMatrixClient();
const roomToParents = useAtomValue(roomToParentsAtom);
const mDirects = useAtomValue(mDirectAtom);
const direct = useIsDirectRoom();
const roomToUnread = useAtomValue(roomToUnreadAtom);
const unreadIndexRef = useRef(0);

Expand Down Expand Up @@ -180,7 +184,7 @@
/** Ctrl+F: Search for messages */
const handleSearchMessageInRoom = useCallback(
(evt: KeyboardEvent) => {
if (!matchesShortcut('app.searchMessages', evt, shortcutOverrides)) return;

Check failure on line 187 in src/app/components/GlobalKeyboardShortcuts.tsx

View workflow job for this annotation

GitHub Actions / Lint

react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'shortcutOverrides'
evt.preventDefault();

const searchParams: SearchPathSearchParams = {
Expand All @@ -188,19 +192,42 @@
};
const path = currentSpace
? getSpaceSearchPath(getCanonicalAliasOrRoomId(mx, currentSpace))
: getHomeSearchPath();
: direct
? getDirectSearchPath()
: getHomeSearchPath();
const roomName = mx.getRoom(currentRoom?.roomId)?.name;
navigate(withSearchParam(path, searchParams));
announce(`Start Searching messages ${roomName ? `in ${roomName}` : ''}`);
},
[mx, currentRoom, currentSpace, navigate, shortcutOverrides]
[mx, currentRoom, currentSpace, navigate, direct]
);

const handleSearchMessageGlobally = useCallback(
(evt: KeyboardEvent) => {
if (!isKeyHotkey('mod+shift+f', evt)) return;
evt.preventDefault();

const searchParams: SearchPathSearchParams = {
global: 'true',
};
const path = currentSpace
? getSpaceSearchPath(getCanonicalAliasOrRoomId(mx, currentSpace))
: direct
? getDirectSearchPath()
: getHomeSearchPath();
const roomName = mx.getRoom(currentRoom?.roomId)?.name;
navigate(withSearchParam(path, searchParams));
announce(`Start Searching messages ${roomName ? `in ${roomName}` : ''}`);
},
[mx, currentRoom, currentSpace, navigate, direct]
);

useKeyDown(window, handleNextUnreadKeyDown);
useKeyDown(window, handleUnreadNavKeyDown);
useKeyDown(window, handleReplyKeyDown);
useKeyDown(window, handleBookmarkKeyDown);
useKeyDown(window, handleSearchMessageInRoom);
useKeyDown(window, handleSearchMessageGlobally);

return null;
}
Loading
Loading