Skip to content

Commit

Permalink
fix: first history entry being fetched twice (#903)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara committed Mar 2, 2022
1 parent 60bddd0 commit c184ef2
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 33 deletions.
Expand Up @@ -202,7 +202,6 @@ export const HistoryListContainer: FunctionComponent<Props> = observer(
<div className={`min-h-0 overflow-auto py-1.5 h-full`}>
{selectedTab === RevisionListTabType.Session && (
<SessionHistoryList
selectedTab={selectedTab}
sessionHistory={sessionHistory}
setSelectedRevision={setSelectedRevision}
setSelectedRemoteEntry={setSelectedRemoteEntry}
Expand All @@ -214,12 +213,10 @@ export const HistoryListContainer: FunctionComponent<Props> = observer(
remoteHistory={remoteHistory}
isFetchingRemoteHistory={isFetchingRemoteHistory}
fetchAndSetRemoteRevision={fetchAndSetRemoteRevision}
selectedTab={selectedTab}
/>
)}
{selectedTab === RevisionListTabType.Legacy && (
<LegacyHistoryList
selectedTab={selectedTab}
legacyHistory={legacyHistory}
setSelectedRevision={setSelectedRevision}
setSelectedRemoteEntry={setSelectedRemoteEntry}
Expand Down
Expand Up @@ -9,12 +9,10 @@ import {
useState,
} from 'preact/hooks';
import { useListKeyboardNavigation } from '../utils';
import { RevisionListTabType } from './HistoryListContainer';
import { HistoryListItem } from './HistoryListItem';
import { LegacyHistoryEntry } from './utils';

type Props = {
selectedTab: RevisionListTabType;
legacyHistory: Action[] | undefined;
setSelectedRevision: StateUpdater<
HistoryEntry | LegacyHistoryEntry | undefined
Expand All @@ -25,7 +23,6 @@ type Props = {

export const LegacyHistoryList: FunctionComponent<Props> = ({
legacyHistory,
selectedTab,
setSelectedRevision,
setSelectedRemoteEntry,
fetchAndSetLegacyRevision,
Expand Down Expand Up @@ -56,13 +53,6 @@ export const LegacyHistoryList: FunctionComponent<Props> = ({
}
}, [firstEntry, selectFirstEntry, selectedItemUrl, setSelectedRevision]);

useEffect(() => {
if (selectedTab === RevisionListTabType.Legacy) {
selectFirstEntry();
legacyHistoryListRef.current?.focus();
}
}, [selectFirstEntry, selectedTab]);

return (
<div
className={`flex flex-col w-full h-full focus:shadow-none ${
Expand Down
Expand Up @@ -11,7 +11,6 @@ import {
} from 'preact/hooks';
import { Icon } from '../Icon';
import { useListKeyboardNavigation } from '../utils';
import { RevisionListTabType } from './HistoryListContainer';
import { HistoryListItem } from './HistoryListItem';
import { previewHistoryEntryTitle, RemoteRevisionListGroup } from './utils';

Expand All @@ -22,7 +21,6 @@ type RemoteHistoryListProps = {
fetchAndSetRemoteRevision: (
revisionListEntry: RevisionListEntry
) => Promise<void>;
selectedTab: RevisionListTabType;
};

export const RemoteHistoryList: FunctionComponent<RemoteHistoryListProps> =
Expand All @@ -32,7 +30,6 @@ export const RemoteHistoryList: FunctionComponent<RemoteHistoryListProps> =
remoteHistory,
isFetchingRemoteHistory,
fetchAndSetRemoteRevision,
selectedTab,
}) => {
const remoteHistoryListRef = useRef<HTMLDivElement>(null);

Expand Down Expand Up @@ -69,13 +66,6 @@ export const RemoteHistoryList: FunctionComponent<RemoteHistoryListProps> =
selectedEntryUuid.length,
]);

useEffect(() => {
if (selectedTab === RevisionListTabType.Remote) {
selectFirstEntry();
remoteHistoryListRef.current?.focus();
}
}, [selectFirstEntry, selectedTab]);

return (
<div
className={`flex flex-col w-full h-full focus:shadow-none ${
Expand Down
Expand Up @@ -13,12 +13,10 @@ import {
useState,
} from 'preact/hooks';
import { useListKeyboardNavigation } from '../utils';
import { RevisionListTabType } from './HistoryListContainer';
import { HistoryListItem } from './HistoryListItem';
import { LegacyHistoryEntry, ListGroup } from './utils';

type Props = {
selectedTab: RevisionListTabType;
sessionHistory: ListGroup<NoteHistoryEntry>[];
setSelectedRevision: StateUpdater<
HistoryEntry | LegacyHistoryEntry | undefined
Expand All @@ -28,7 +26,6 @@ type Props = {

export const SessionHistoryList: FunctionComponent<Props> = ({
sessionHistory,
selectedTab,
setSelectedRevision,
setSelectedRemoteEntry,
}) => {
Expand Down Expand Up @@ -67,13 +64,6 @@ export const SessionHistoryList: FunctionComponent<Props> = ({
setSelectedRevision,
]);

useEffect(() => {
if (selectedTab === RevisionListTabType.Session) {
selectFirstEntry();
sessionHistoryListRef.current?.focus();
}
}, [selectFirstEntry, selectedTab]);

return (
<div
className={`flex flex-col w-full h-full focus:shadow-none ${
Expand Down

0 comments on commit c184ef2

Please sign in to comment.