Commit 028f6783 authored by jdlrobson's avatar jdlrobson Committed by Brennen Bearnes
Browse files

Fix toggling storage cleanup

Setting item to null, still keeps an entry in localStorage
This also breaks the old implementation in the case of rollback
which happened today.

This patch adds some safe guards to make sure any existing broken
states are fixed, any the entry is removed going forward.

Bug: T272638
Change-Id: Ib7c0a45fcf8645a900288a26d172781612fa1606
No related merge requests found
Showing with 8 additions and 1 deletion
+8 -1
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -42,6 +42,10 @@ function Toggler( options ) {
*/
function getExpandedSections( page ) {
var expandedSections = JSON.parse( mw.storage.session.get( 'expandedSections' ) || '{}' );
// Can be removed 1 week after Ib7c0a45fcf8645a900288a26d172781612fa1606 is deployed
if ( expandedSections === 'null' ) {
expandedSections = {};
}
expandedSections[page.title] = expandedSections[page.title] || {};
return expandedSections;
}
......@@ -55,7 +59,10 @@ function saveExpandedSections( expandedSections ) {
mw.storage.session.set(
'expandedSections', JSON.stringify( mw.storage.get( 'expandedSections' ) )
);
mw.storage.set( 'expandedSections', null );
// Clean up any old storage.
// The following line can be removed 1 week after
// Ib7c0a45fcf8645a900288a26d172781612fa1606 is deployed
mw.storage.remove( 'expandedSections' );
}
mw.storage.session.set(
'expandedSections', JSON.stringify( expandedSections )
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment