fix: first history entry being fetched twice (#903)

This commit is contained in:
Aman Harwara
2022-03-02 18:30:10 +05:30
committed by GitHub
parent 60bddd0f41
commit c184ef2449
4 changed files with 0 additions and 33 deletions

View File

@@ -202,7 +202,6 @@ export const HistoryListContainer: FunctionComponent<Props> = observer(
<div className={`min-h-0 overflow-auto py-1.5 h-full`}> <div className={`min-h-0 overflow-auto py-1.5 h-full`}>
{selectedTab === RevisionListTabType.Session && ( {selectedTab === RevisionListTabType.Session && (
<SessionHistoryList <SessionHistoryList
selectedTab={selectedTab}
sessionHistory={sessionHistory} sessionHistory={sessionHistory}
setSelectedRevision={setSelectedRevision} setSelectedRevision={setSelectedRevision}
setSelectedRemoteEntry={setSelectedRemoteEntry} setSelectedRemoteEntry={setSelectedRemoteEntry}
@@ -214,12 +213,10 @@ export const HistoryListContainer: FunctionComponent<Props> = observer(
remoteHistory={remoteHistory} remoteHistory={remoteHistory}
isFetchingRemoteHistory={isFetchingRemoteHistory} isFetchingRemoteHistory={isFetchingRemoteHistory}
fetchAndSetRemoteRevision={fetchAndSetRemoteRevision} fetchAndSetRemoteRevision={fetchAndSetRemoteRevision}
selectedTab={selectedTab}
/> />
)} )}
{selectedTab === RevisionListTabType.Legacy && ( {selectedTab === RevisionListTabType.Legacy && (
<LegacyHistoryList <LegacyHistoryList
selectedTab={selectedTab}
legacyHistory={legacyHistory} legacyHistory={legacyHistory}
setSelectedRevision={setSelectedRevision} setSelectedRevision={setSelectedRevision}
setSelectedRemoteEntry={setSelectedRemoteEntry} setSelectedRemoteEntry={setSelectedRemoteEntry}

View File

@@ -9,12 +9,10 @@ import {
useState, useState,
} from 'preact/hooks'; } from 'preact/hooks';
import { useListKeyboardNavigation } from '../utils'; import { useListKeyboardNavigation } from '../utils';
import { RevisionListTabType } from './HistoryListContainer';
import { HistoryListItem } from './HistoryListItem'; import { HistoryListItem } from './HistoryListItem';
import { LegacyHistoryEntry } from './utils'; import { LegacyHistoryEntry } from './utils';
type Props = { type Props = {
selectedTab: RevisionListTabType;
legacyHistory: Action[] | undefined; legacyHistory: Action[] | undefined;
setSelectedRevision: StateUpdater< setSelectedRevision: StateUpdater<
HistoryEntry | LegacyHistoryEntry | undefined HistoryEntry | LegacyHistoryEntry | undefined
@@ -25,7 +23,6 @@ type Props = {
export const LegacyHistoryList: FunctionComponent<Props> = ({ export const LegacyHistoryList: FunctionComponent<Props> = ({
legacyHistory, legacyHistory,
selectedTab,
setSelectedRevision, setSelectedRevision,
setSelectedRemoteEntry, setSelectedRemoteEntry,
fetchAndSetLegacyRevision, fetchAndSetLegacyRevision,
@@ -56,13 +53,6 @@ export const LegacyHistoryList: FunctionComponent<Props> = ({
} }
}, [firstEntry, selectFirstEntry, selectedItemUrl, setSelectedRevision]); }, [firstEntry, selectFirstEntry, selectedItemUrl, setSelectedRevision]);
useEffect(() => {
if (selectedTab === RevisionListTabType.Legacy) {
selectFirstEntry();
legacyHistoryListRef.current?.focus();
}
}, [selectFirstEntry, selectedTab]);
return ( return (
<div <div
className={`flex flex-col w-full h-full focus:shadow-none ${ className={`flex flex-col w-full h-full focus:shadow-none ${

View File

@@ -11,7 +11,6 @@ import {
} from 'preact/hooks'; } from 'preact/hooks';
import { Icon } from '../Icon'; import { Icon } from '../Icon';
import { useListKeyboardNavigation } from '../utils'; import { useListKeyboardNavigation } from '../utils';
import { RevisionListTabType } from './HistoryListContainer';
import { HistoryListItem } from './HistoryListItem'; import { HistoryListItem } from './HistoryListItem';
import { previewHistoryEntryTitle, RemoteRevisionListGroup } from './utils'; import { previewHistoryEntryTitle, RemoteRevisionListGroup } from './utils';
@@ -22,7 +21,6 @@ type RemoteHistoryListProps = {
fetchAndSetRemoteRevision: ( fetchAndSetRemoteRevision: (
revisionListEntry: RevisionListEntry revisionListEntry: RevisionListEntry
) => Promise<void>; ) => Promise<void>;
selectedTab: RevisionListTabType;
}; };
export const RemoteHistoryList: FunctionComponent<RemoteHistoryListProps> = export const RemoteHistoryList: FunctionComponent<RemoteHistoryListProps> =
@@ -32,7 +30,6 @@ export const RemoteHistoryList: FunctionComponent<RemoteHistoryListProps> =
remoteHistory, remoteHistory,
isFetchingRemoteHistory, isFetchingRemoteHistory,
fetchAndSetRemoteRevision, fetchAndSetRemoteRevision,
selectedTab,
}) => { }) => {
const remoteHistoryListRef = useRef<HTMLDivElement>(null); const remoteHistoryListRef = useRef<HTMLDivElement>(null);
@@ -69,13 +66,6 @@ export const RemoteHistoryList: FunctionComponent<RemoteHistoryListProps> =
selectedEntryUuid.length, selectedEntryUuid.length,
]); ]);
useEffect(() => {
if (selectedTab === RevisionListTabType.Remote) {
selectFirstEntry();
remoteHistoryListRef.current?.focus();
}
}, [selectFirstEntry, selectedTab]);
return ( return (
<div <div
className={`flex flex-col w-full h-full focus:shadow-none ${ className={`flex flex-col w-full h-full focus:shadow-none ${

View File

@@ -13,12 +13,10 @@ import {
useState, useState,
} from 'preact/hooks'; } from 'preact/hooks';
import { useListKeyboardNavigation } from '../utils'; import { useListKeyboardNavigation } from '../utils';
import { RevisionListTabType } from './HistoryListContainer';
import { HistoryListItem } from './HistoryListItem'; import { HistoryListItem } from './HistoryListItem';
import { LegacyHistoryEntry, ListGroup } from './utils'; import { LegacyHistoryEntry, ListGroup } from './utils';
type Props = { type Props = {
selectedTab: RevisionListTabType;
sessionHistory: ListGroup<NoteHistoryEntry>[]; sessionHistory: ListGroup<NoteHistoryEntry>[];
setSelectedRevision: StateUpdater< setSelectedRevision: StateUpdater<
HistoryEntry | LegacyHistoryEntry | undefined HistoryEntry | LegacyHistoryEntry | undefined
@@ -28,7 +26,6 @@ type Props = {
export const SessionHistoryList: FunctionComponent<Props> = ({ export const SessionHistoryList: FunctionComponent<Props> = ({
sessionHistory, sessionHistory,
selectedTab,
setSelectedRevision, setSelectedRevision,
setSelectedRemoteEntry, setSelectedRemoteEntry,
}) => { }) => {
@@ -67,13 +64,6 @@ export const SessionHistoryList: FunctionComponent<Props> = ({
setSelectedRevision, setSelectedRevision,
]); ]);
useEffect(() => {
if (selectedTab === RevisionListTabType.Session) {
selectFirstEntry();
sessionHistoryListRef.current?.focus();
}
}, [selectFirstEntry, selectedTab]);
return ( return (
<div <div
className={`flex flex-col w-full h-full focus:shadow-none ${ className={`flex flex-col w-full h-full focus:shadow-none ${