Skip to content

Commit

Permalink
cci: handle old cached pages (post-refactor)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChlodAlejandro committed Nov 23, 2022
1 parent 29a42ea commit 211fdd2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/wiki/DeputyCasePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,27 @@ export default class DeputyCasePage extends DeputyCase {
title = await getPageTitle( pageId );
}

return new DeputyCasePage(
// Fix for old data (moved from section name to IDs as of c5251642)
const oldSections =
cachedInfo.lastActiveSections.some( ( v ) => v.indexOf( ' ' ) !== -1 );
if ( oldSections ) {
cachedInfo.lastActiveSections =
cachedInfo.lastActiveSections.map( ( v ) => v.replace( / /g, '_' ) );
}

const casePage = new DeputyCasePage(
pageId,
title,
document,
parsoid,
cachedInfo.lastActive,
cachedInfo.lastActiveSections
);
if ( oldSections ) {
// Save to fix the data in storage
await casePage.saveToCache();
}
return casePage;
} else {
return new DeputyCasePage( pageId, title, document, parsoid );
}
Expand Down

0 comments on commit 211fdd2

Please sign in to comment.