Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more missing awaits #7185

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ModelMixins/ExportWebCoverageServiceMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ function ExportWebCoverageServiceMixin<
);
});

pendingWorkbenchItem.terria.workbench.add(pendingWorkbenchItem);
await pendingWorkbenchItem.terria.workbench.add(pendingWorkbenchItem);

// Load WCS metadata (DescribeCoverage request)
(await this.loadWcsMetadata()).throwIfError();
Expand Down
4 changes: 2 additions & 2 deletions lib/ModelMixins/TileErrorHandlerMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ function TileErrorHandlerMixin<T extends AbstractConstructor<ModelType>>(

// Browsers don't tell us much about a failed image load, so we do an
// XHR to get more error information if needed.
const maybeXhr =
const maybeXhr: Promise<HTMLImageElement | ImageBitmap> | undefined =
attemptNumber === 1
? Promise.reject(tileProviderError.error)
: fetchTileImage(tile, imageryProvider);

if (this.handleTileError && maybeXhr) {
// Give the catalog item a chance to handle this error.
this.handleTileError(maybeXhr as any, tile);
await this.handleTileError(maybeXhr as any, tile);
}

try {
Expand Down
2 changes: 1 addition & 1 deletion lib/ModelMixins/TimeFilterMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function TimeFilterMixin<T extends AbstractConstructor<BaseType>>(Base: T) {

const coords = coordinatesFromTraits(this.timeFilterCoordinates);
if (coords) {
this.setTimeFilterFromLocation(coords);
await this.setTimeFilterFromLocation(coords);
}
disposeListener();
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export default class WebProcessingServiceCatalogFunction extends XmlRequestMixin
return;
}

const inputValue = await Promise.resolve(result.inputValue);
const inputValue = await result.inputValue;
if (!isDefined(inputValue)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Catalog/addUserCatalogMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default async function addUserCatalogMember(
newCatalogMemberOrPromise: BaseModel | Promise<BaseModel | undefined>,
options: AddUserCatalogMemberOptions = {}
): Promise<BaseModel | undefined> {
const promise =
const promise: Promise<BaseModel | undefined> =
newCatalogMemberOrPromise instanceof Promise
? newCatalogMemberOrPromise
: Promise.resolve(newCatalogMemberOrPromise);
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Catalog/addUserFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default async function addUserFiles(
}

tempCatalogItem.loadPromise = loadPromise;
terria.workbench.add(tempCatalogItem);
await terria.workbench.add(tempCatalogItem);
tempCatalogItemList.push(tempCatalogItem);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Models/GlobeOrMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ export default abstract class GlobeOrMap {
})
);

this.terria.overlays.add(catalogItem);
await this.terria.overlays.add(catalogItem);
this._highlightPromise = catalogItem.loadMapItems();

const removeCallback = (this._removeHighlightCallback = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export default class IndexedItemSearchProvider extends ItemSearchProvider {
const json = await loadJson5(indexRootUrl);
try {
this.indexRoot = parseIndexRoot(json);
// FIXME: missing await.
this.getOrLoadResultsData();
} catch (parseError) {
console.warn(parseError);
Expand Down
5 changes: 3 additions & 2 deletions lib/Models/Terria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,7 @@ export default class Terria {

// Zoom to workbench items if any of the init sources specifically requested it
if (this.focusWorkbenchItemsAfterLoadingInitSources) {
// FIXME: missing await.
this.doZoomToWorkbenchItems();
}

Expand Down Expand Up @@ -1731,7 +1732,7 @@ export default class Terria {
// - If there are multiple initSources, the setting from the last source takes effect
try {
const initialCamera = CameraView.fromJson(initData.initialCamera);
this.currentViewer.zoomTo(initialCamera, 2.0);
await this.currentViewer.zoomTo(initialCamera, 2.0);
// reset in case this was enabled by a previous initSource
this.focusWorkbenchItemsAfterLoadingInitSources = false;
} catch (error) {
Expand Down Expand Up @@ -1768,7 +1769,7 @@ export default class Terria {
);
}
if (isJsonString(initData.settings.baseMapId)) {
this.mainViewer.setBaseMap(
await this.mainViewer.setBaseMap(
this.baseMapsModel.baseMapItems.find(
(item) => item.item.uniqueId === initData.settings!.baseMapId
)?.item
Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export default class Workbench {
if (!error && MappableMixin.isMixedInto(item)) {
error = (await item.loadMapItems()).error;
if (!error && item.zoomOnAddToWorkbench && !item.disableZoomTo) {
item.terria.currentViewer.zoomTo(item);
await item.terria.currentViewer.zoomTo(item);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/ReactViewModels/ViewState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ export default class ViewState {
);
result.throwIfError();
const model = result.throwIfUndefined();
this.viewCatalogMember(model);
await this.viewCatalogMember(model);
} catch (e) {
terria.raiseErrorToUser(e, {
message: `Couldn't find model \`${previewedItemId}\` for preview`
Expand Down
4 changes: 2 additions & 2 deletions lib/ReactViews/DragDropFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ class DragDropFile extends React.Component<PropsType> {
);

isDefined(firstZoomableItem) &&
runInAction(() =>
(await runInAction(() =>
props.viewState.terria.currentViewer.zoomTo(firstZoomableItem, 1)
);
));
}

runInAction(() => (props.viewState.isDraggingDroppingFile = false));
Expand Down
2 changes: 1 addition & 1 deletion lib/ReactViews/ExplorerWindow/Tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Tabs extends React.Component {
result.raiseError(this.props.terria);
} else {
if (!file.disableZoomTo) {
this.props.terria.currentViewer.zoomTo(file, 1);
await this.props.terria.currentViewer.zoomTo(file, 1);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ReactViews/Map/Panels/ToolsPanel/CountDatasets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const CountDatasets: React.FC<CountDatasetsProps> = observer((props) => {
path.push(member.name!);

const loadPromise = member.loadMembers();
const countPromise = member.isLoading
const countPromise: Promise<void> = member.isLoading
? loadPromise
.then((result) => result.throwIfError())
.then(
Expand Down
2 changes: 1 addition & 1 deletion lib/ReactViews/Tools/DiffTool/DiffTool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ class Main extends React.Component<MainPropsType> {
const imageryProvider =
part && ImageryParts.is(part) && part.imageryProvider;
if (imageryProvider) {
const promises = [
const promises: Promise<boolean>[] = [
setTimeFilterFromLocation(
this.props.leftItem,
markerLocation,
Expand Down
2 changes: 1 addition & 1 deletion lib/ReactViews/Workbench/Controls/ViewingControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class ViewingControls extends React.Component<
});

// Add it to terria.catalog, which is required so the new item can be shared.
addUserCatalogMember(terria, splitRef, {
await addUserCatalogMember(terria, splitRef, {
open: false
});
});
Expand Down