Skip to content

Commit 5251753

Browse files
authored
Internal - Room Search Fix (#721)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description Fixes the rerender cycle by making it sure it redoes the math if the state changes instead It doesn't have or need a changelog as it is a bug encountered only in the dev branch Fixes # #### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. --> The callas disregard for the state of the room compelled and educated in writing the pr 😔😔😔
2 parents cbb2251 + 8307e4a commit 5251753

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/app/components/editor/autocomplete/RoomMentionAutocomplete.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { KeyboardEvent as ReactKeyboardEvent } from 'react';
2-
import { useCallback, useEffect } from 'react';
2+
import { useCallback, useEffect, useMemo } from 'react';
33
import type { Editor } from 'slate';
44
import { ReactEditor } from 'slate-react';
55
import { Avatar, Icon, Icons, MenuItem, Text } from 'folds';
@@ -83,7 +83,11 @@ export function RoomMentionAutocomplete({
8383
const mx = useMatrixClient();
8484
const mDirects = useAtomValue(mDirectAtom);
8585

86-
const allRooms = useAtomValue(allRoomsAtom).toSorted(factoryRoomIdByActivity(mx));
86+
const allRoomsFromAtom = useAtomValue(allRoomsAtom);
87+
const allRooms = useMemo(
88+
() => allRoomsFromAtom.toSorted(factoryRoomIdByActivity(mx)),
89+
[allRoomsFromAtom, mx]
90+
);
8791

8892
const [result, search, resetSearch] = useAsyncSearch(
8993
allRooms,

0 commit comments

Comments
 (0)