[Code] handle nodegit deprecation warnings (#33932)

This commit is contained in:
Yulong 2019-03-27 23:52:02 +08:00 committed by Fuyao Zhao
parent 7cd7792929
commit 6486bdfcd2
5 changed files with 22 additions and 9 deletions

View file

@ -160,7 +160,7 @@
"@elastic/lsp-extension": "^0.1.1",
"@elastic/node-crypto": "0.1.2",
"@elastic/numeral": "2.3.2",
"@elastic/nodegit": "0.25.0-alpha.10",
"@elastic/nodegit": "0.25.0-alpha.11",
"@kbn/babel-preset": "1.0.0",
"@kbn/es-query": "1.0.0",
"@kbn/i18n": "1.0.0",

View file

@ -357,9 +357,9 @@ class CodeContent extends React.PureComponent<Props> {
return (
<CommitHistoryContainer>
<InfiniteScroll
initialLoad={false}
initialLoad={true}
loadMore={() => !loadingCommits && this.props.fetchMoreCommits(repoUri)}
hasMore={!loadingCommits && hasMoreCommits}
hasMore={hasMoreCommits}
useWindow={false}
loader={<CommitHistoryLoading />}
>

View file

@ -50,7 +50,20 @@ export const treeCommitsSelector = (state: RootState) => {
export const hasMoreCommitsSelector = (state: RootState) => {
const path = state.file.currentPath;
return !state.file.commitsFullyLoaded[path];
const isLoading = state.file.loadingCommits;
if (isLoading) {
return false;
}
if (state.file.commitsFullyLoaded[path]) {
return false;
}
const commits = path === '' ? state.file.commits : state.file.treeCommits[path];
if (!commits) {
// To avoid infinite loops in component `InfiniteScroll`,
// here we set hasMore to false before we receive the first batch.
return false;
}
return true;
};
function find(tree: FileTree, paths: string[]): FileTree | null {

View file

@ -184,7 +184,7 @@ export function fileRoute(server: hapi.Server, options: ServerOptions) {
const uri = req.params.uri;
try {
const repository = await gitOperations.openRepo(uri);
const references = await repository.getReferences(Reference.TYPE.OID);
const references = await repository.getReferences(Reference.TYPE.DIRECT);
const results: ReferenceInfo[] = await Promise.all(references.map(referenceInfo));
return results;
} catch (e) {

View file

@ -966,10 +966,10 @@
resolved "https://registry.yarnpkg.com/@elastic/node-crypto/-/node-crypto-0.1.2.tgz#c18ac282f635e88f041cc1555d806e492ca8f3b1"
integrity sha1-wYrCgvY16I8EHMFVXYBuSSyo87E=
"@elastic/nodegit@0.25.0-alpha.10":
version "0.25.0-alpha.10"
resolved "https://registry.yarnpkg.com/@elastic/nodegit/-/nodegit-0.25.0-alpha.10.tgz#2f1234cbc2ac391f2762c7763049afa34a4e9fbb"
integrity sha512-+fcnXtcFQTpjKn2mGySlXtkfB86dU1j2yfw+RYkuNwN3/o/3gSa142bzVxIGYZFP+Tki5fB+AJQI5l6Um0f8YA==
"@elastic/nodegit@0.25.0-alpha.11":
version "0.25.0-alpha.11"
resolved "https://registry.yarnpkg.com/@elastic/nodegit/-/nodegit-0.25.0-alpha.11.tgz#f19acf455eb8bc129135e9f45cd17c4caa721c13"
integrity sha512-r8DqibYZyOLU9e37B5AGkHpUJWoXRToFA1kjrPDCjFSI/gl736mFr8jm8xIrp32yNnSewyW3avSRULQ3RgfubA==
dependencies:
fs-extra "^7.0.0"
json5 "^2.1.0"