@@ -92,6 +92,7 @@ export default class RoundController implements MoveRootCtrl {
92
92
preDrop ?: cg . Role ;
93
93
sign : string = Math . random ( ) . toString ( 36 ) ;
94
94
keyboardHelp : boolean = location . hash === '#keyboard' ;
95
+ blindfoldStorage : LichessBooleanStorage ;
95
96
96
97
constructor (
97
98
readonly opts : RoundOpts ,
@@ -111,6 +112,7 @@ export default class RoundController implements MoveRootCtrl {
111
112
} , 3000 ) ;
112
113
113
114
this . socket = makeSocket ( opts . socketSend , this ) ;
115
+ this . blindfoldStorage = lichess . storage . boolean ( `blindfold.${ this . data . player . user ?. id ?? 'anon' } ` ) ;
114
116
115
117
if ( d . clock )
116
118
this . clock = new ClockController ( d , {
@@ -856,7 +858,7 @@ export default class RoundController implements MoveRootCtrl {
856
858
857
859
blindfold = ( v ?: boolean ) : boolean => {
858
860
if ( v === undefined || v === this . data . player . blindfold ) return this . data . player . blindfold ?? false ;
859
- lichess . storage . set ( `blindfold. ${ this . data . player . user ?. id ?? 'anon' } ` , v ? 'true' : 'false' ) ;
861
+ this . blindfoldStorage . set ( v ) ;
860
862
this . data . player . blindfold = v ;
861
863
this . socket . send ( `blindfold-${ v ? 'yes' : 'no' } ` ) ;
862
864
this . redraw ( ) ;
@@ -899,10 +901,10 @@ export default class RoundController implements MoveRootCtrl {
899
901
if ( lichess . storage . get ( 'blindfold' ) === 'true' ) {
900
902
// TODO - delete this if block & storage.set once a few weeks pass
901
903
lichess . storage . remove ( 'blindfold' ) ;
902
- lichess . storage . set ( `blindfold. ${ this . data . player . user ?. id ?? 'anon' } ` , ' true' ) ;
904
+ this . blindfoldStorage . set ( true ) ;
903
905
}
904
906
905
- this . blindfold ( lichess . storage . get ( `blindfold. ${ this . data . player . user ?. id ?? 'anon' } ` ) === 'true' ) ;
907
+ this . blindfold ( this . blindfoldStorage . get ( ) ) ;
906
908
}
907
909
wakeLock . request ( ) ;
908
910
0 commit comments