2022-09-20 15:02:09 -06:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const { ViewModel } = require('hydrogen-view-sdk');
|
|
|
|
|
2023-05-03 03:45:33 -06:00
|
|
|
const LOCAL_STORAGE_KEYS = require('matrix-public-archive-shared/lib/local-storage-keys');
|
2022-10-20 01:06:43 -06:00
|
|
|
|
2022-10-27 00:09:13 -06:00
|
|
|
class DeveloperOptionsContentViewModel extends ViewModel {
|
2022-09-20 15:02:09 -06:00
|
|
|
constructor(options) {
|
|
|
|
super(options);
|
2022-10-27 00:09:13 -06:00
|
|
|
const { room, debugActiveDateIntersectionObserver = false } = options;
|
2022-09-20 15:02:09 -06:00
|
|
|
|
2022-10-27 00:09:13 -06:00
|
|
|
this._room = room;
|
2022-09-20 15:02:09 -06:00
|
|
|
this._debugActiveDateIntersectionObserver = debugActiveDateIntersectionObserver;
|
|
|
|
}
|
|
|
|
|
|
|
|
loadValuesFromPersistence() {
|
|
|
|
if (window.localStorage) {
|
|
|
|
this._debugActiveDateIntersectionObserver = JSON.parse(
|
2023-05-03 03:45:33 -06:00
|
|
|
window.localStorage.getItem(LOCAL_STORAGE_KEYS.debugActiveDateIntersectionObserver)
|
2022-09-20 15:02:09 -06:00
|
|
|
);
|
|
|
|
this.emitChange('debugActiveDateIntersectionObserver');
|
|
|
|
} else {
|
2023-05-03 03:45:33 -06:00
|
|
|
console.warn(
|
|
|
|
`Skipping \`${LOCAL_STORAGE_KEYS.debugActiveDateIntersectionObserver}\` read from LocalStorage since LocalStorage is not available`
|
|
|
|
);
|
2022-09-20 15:02:09 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
get debugActiveDateIntersectionObserver() {
|
|
|
|
return this._debugActiveDateIntersectionObserver;
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleDebugActiveDateIntersectionObserver(checkedValue) {
|
|
|
|
this._debugActiveDateIntersectionObserver = checkedValue;
|
|
|
|
window.localStorage.setItem(
|
2023-05-03 03:45:33 -06:00
|
|
|
LOCAL_STORAGE_KEYS.debugActiveDateIntersectionObserver,
|
2022-09-20 15:02:09 -06:00
|
|
|
this._debugActiveDateIntersectionObserver
|
|
|
|
);
|
|
|
|
this.emitChange('debugActiveDateIntersectionObserver');
|
|
|
|
}
|
2022-10-27 00:09:13 -06:00
|
|
|
|
|
|
|
get roomId() {
|
|
|
|
return this._room.id;
|
|
|
|
}
|
2022-09-20 15:02:09 -06:00
|
|
|
}
|
|
|
|
|
2022-10-27 00:09:13 -06:00
|
|
|
module.exports = DeveloperOptionsContentViewModel;
|