Improvements (#395)

* Updated @pnp packages to solve an issue with application insights tracking failing the component in IE/Edge.

* Explicit load of the Overlay component to reduce bundle size.

* Store the inital result in order to prevent two calls per page which slows down result loading and is unneeded.
This commit is contained in:
Mikael Svenson 2018-01-20 14:59:21 +01:00 committed by Vesa Juvonen
parent 764d8f10e0
commit 120af41c95
3 changed files with 41 additions and 36 deletions

View File

@ -14,8 +14,8 @@
"@microsoft/sp-core-library": "~1.4.0",
"@microsoft/sp-lodash-subset": "~1.4.0",
"@microsoft/sp-webpart-base": "~1.4.0",
"@pnp/spfx-controls-react": "^1.1.1",
"@pnp/spfx-property-controls": "^1.1.1",
"@pnp/spfx-controls-react": "^1.1.2",
"@pnp/spfx-property-controls": "^1.2.0",
"@types/react": "15.6.6",
"@types/react-addons-shallow-compare": "0.14.17",
"@types/react-addons-test-utils": "0.14.15",

View File

@ -11,6 +11,7 @@ import * as moment from "moment";
class SearchDataProvider implements ISearchDataProvider {
private _initialSearchResult: SearchResults = null;
private _resultsCount: number;
private _context: IWebPartContext;
private _appSearchSettings: SearchQuery;
@ -102,19 +103,23 @@ class SearchDataProvider implements ISearchDataProvider {
};
try {
const r = await pnp.sp.search(searchQuery);
if (!this._initialSearchResult || page == 1) {
this._initialSearchResult = await pnp.sp.search(searchQuery);
}
const allItemsPromises: Promise<any>[] = [];
let refinementResults: IRefinementResult[] = [];
// Need to do this check
// More info here: https://github.com/SharePoint/PnP-JS-Core/issues/337
if (r.RawSearchResults.PrimaryQueryResult) {
if (this._initialSearchResult.RawSearchResults.PrimaryQueryResult) {
// Be careful, there was an issue with paging calculation under 2.0.8 version of sp-pnp-js library
// More info https://github.com/SharePoint/PnP-JS-Core/issues/535
const r2 = await r.getPage(page, this._resultsCount);
let r2 = this._initialSearchResult;
if (page > 1) {
r2 = await this._initialSearchResult.getPage(page, this._resultsCount);
}
const resultRows = r2.RawSearchResults.PrimaryQueryResult.RelevantResults.Table.Rows;
let refinementResultsRows = r2.RawSearchResults.PrimaryQueryResult.RefinementResults;
@ -178,8 +183,8 @@ class SearchDataProvider implements ISearchDataProvider {
});
results.RelevantResults = relevantResults;
results.RefinementResults = refinementResults,
results.TotalRows = r.TotalRows;
results.RefinementResults = refinementResults;
results.TotalRows = this._initialSearchResult.TotalRows;
}
return results;

View File

@ -10,7 +10,7 @@ import TilesList from "../TilesList/TilesList";
import "../SearchWebPart.scss";
import FilterPanel from "../FilterPanel/FilterPanel";
import Paging from "../Paging/Paging";
import { Overlay } from "office-ui-fabric-react";
import { Overlay } from "office-ui-fabric-react/lib/Overlay";
export default class SearchContainer extends React.Component<ISearchContainerProps, ISearchContainerState> {