File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change 167167 } else if (currEntryId !== $selectedEntry ?.id ) {
168168 $state .userPickedEntry = true ;
169169 navigateToEntryId = currEntryId ;
170- refreshSelection ();
170+ void refreshSelection ();
171171 }
172172 });
173173
185185 $ : {
186186 // eslint-disable-next-line @typescript-eslint/no-unused-expressions
187187 $entries ;
188- refreshSelection ();
188+ void refreshSelection ();
189189 }
190190
191- // selection handling, make sure the selected entry is always in the list of entries
192- function refreshSelection() {
191+ async function findEntry(id : string ): Promise <IEntry | undefined > {
192+ const entry = $entries ?.find (e => e .id === id );
193+ if (entry ) return entry ;
194+ if ($selectedEntry ?.id === id ) return $selectedEntry ;
195+ return await lexboxApi .getEntry (id );
196+ }
197+
198+ // selection handling, make sure we preserve selection even if the entry is not in server-page
199+ async function refreshSelection() {
193200 if (! $entries ) return ;
194201
195202 if (navigateToEntryId ) {
196- const entry = $entries . find ( e => e . id === navigateToEntryId );
203+ const entry = await findEntry ( navigateToEntryId );
197204 if (entry ) {
198205 $selectedEntry = entry ;
199206 $state .userPickedEntry = true ;
200207 }
201208 } else if ($selectedEntry !== undefined ) {
202- const entry = $entries . find ( e => e . id === $selectedEntry ! .id );
209+ const entry = await findEntry ( $selectedEntry .id );
203210 if (entry !== $selectedEntry ) {
204211 $selectedEntry = entry ;
205212 }
You can’t perform that action at this time.
0 commit comments