Remember whether widget drawer was hidden per-room

Fixes #4850

Signed-off-by: Andrew (anoa) <anoa@openmailbox.org>
pull/21833/head
Andrew (anoa) 2017-10-24 16:21:46 -07:00
parent 0463f0e581
commit f032284eff
No known key found for this signature in database
GPG Key ID: 174BEAB009FD176D
2 changed files with 28 additions and 3 deletions

View File

@ -305,6 +305,20 @@ module.exports = React.createClass({
_shouldShowApps: function(room) {
if (!BROWSER_SUPPORTS_SANDBOX) return false;
// Check if user has prompted to close this app before
// If so, do not show apps
let showWidget = localStorage.getItem(
room.roomId + "_show_widget_drawer");
console.warn(room);
console.warn("Key is: " + room.roomId + "_show_widget_drawer");
console.warn("showWidget is: " + showWidget);
if (showWidget == "false") {
console.warn("We're blocking the widget from loading.");
return false;
}
const appsStateEvents = room.currentState.getStateEvents('im.vector.modular.widgets');
// any valid widget = show apps
for (let i = 0; i < appsStateEvents.length; i++) {

View File

@ -83,14 +83,25 @@ module.exports = React.createClass({
onAction: function(action) {
switch (action.action) {
case 'appsDrawer':
// When opening the app draw when there aren't any apps, auto-launch the
// integrations manager to skip the awkward click on "Add widget"
// When opening the app drawer when there aren't any apps,
// auto-launch the integrations manager to skip the awkward
// click on "Add widget"
let widgetStateKey = this.props.room.roomId + "_show_widget_drawer";
if (action.show) {
const apps = this._getApps();
if (apps.length === 0) {
this._launchManageIntegrations();
}
localStorage.removeItem(widgetStateKey);
} else {
// Store hidden state of widget
// Don't show if previously hidden
console.warn("Storing hidden widget state for room - ",
this.props.room.roomId);
localStorage.setItem(widgetStateKey, false);
}
break;
}
},