[Maps] fix 'New Map' from getting added to recently accessed (#72125)

This commit is contained in:
Nathan Reese 2020-07-16 14:25:25 -06:00 committed by GitHub
parent 4278e560ef
commit d510263666
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View file

@ -7,7 +7,7 @@
import React from 'react';
import { MapsAppView } from '.';
import { getMapsSavedObjectLoader } from '../../bootstrap/services/gis_map_saved_object_loader';
import { getToasts } from '../../../kibana_services';
import { getCoreChrome, getToasts } from '../../../kibana_services';
import { i18n } from '@kbn/i18n';
import { Redirect } from 'react-router-dom';
@ -30,6 +30,10 @@ export const LoadMapAndRender = class extends React.Component {
try {
const savedMap = await getMapsSavedObjectLoader().get(this.props.savedMapId);
if (this._isMounted) {
getCoreChrome().docTitle.change(savedMap.title);
if (this.props.savedMapId) {
getCoreChrome().recentlyAccessed.add(savedMap.getFullPath(), savedMap.title, savedMap.id);
}
this.setState({ savedMap });
}
} catch (err) {

View file

@ -56,11 +56,6 @@ export class MapsAppView extends React.Component {
}
componentDidMount() {
const { savedMap } = this.props;
getCoreChrome().docTitle.change(savedMap.title);
getCoreChrome().recentlyAccessed.add(savedMap.getFullPath(), savedMap.title, savedMap.id);
// Init sync utils
// eslint-disable-next-line react-hooks/rules-of-hooks
this._globalSyncUnsubscribe = useGlobalStateSyncing();