message: Fixing history cache to refresh stored data properly
diff: @@ -31,11 +31,7 @@ export class HistoryCache {
  const state = this._get<T>(route, tag);
  if (state) {
  - // We have to put the state back on top so that it was just
  - // accessed. We don't want it being cleaned up.
  - arrayRemove(this.states, i => i === state);
  - this.states.push(state);
  -
  + this._touchState(state);
  return state.data;
  }
  @@ -46,22 +42,12 @@ export class HistoryCache {
  return !!this._get(route, tag);
  }
  - private static _get<T = any>(route: RouteLocationNormalized, tag?: string | symbol) {
  - const historyState = this.getHistoryState();
  - if (!historyState) {
  - return undefined;
  - }
  -
  - return this.states.find(i => i.url === route.fullPath && i.tag === tag) as
  - | HistoryCacheState<T>
  - | undefined;
  - }
  -
  static store<T = any>(route: RouteLocationNormalized, data: T, tag?: string | symbol) {
  - const state = this.get(route, tag);
  + const state = this._get(route, tag);
  if (state) {
  state.data = data;
  + this._touchState(state);
  } else {
  const url = route.fullPath;
  @@ -75,4 +61,24 @@ export class HistoryCache {
  this.states = this.states.slice(-MAX_ITEMS);
  }
  }
  +
  + private static _get<T = any>(route: RouteLocationNormalized, tag?: string | symbol) {
  + const historyState = this.getHistoryState();
  + if (!historyState) {
  + return undefined;
  + }
  +
  + return this.states.find(i => i.url === route.fullPath && i.tag === tag) as
  + | HistoryCacheState<T>
  + | undefined;
  + }
  +
  + /**
  + * Call this to put the state back on top of the states array so that it
  + * doesn't get cleaned up.
  + */
  + private static _touchState(state: HistoryCacheState) {
  + arrayRemove(this.states, i => i === state);
  + this.states.push(state);
  + }
  }
  