diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 83ca987276..583ce78785 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -281,7 +281,7 @@ module.exports = React.createClass({ this.setState({ isPeeking: false, }); - + // This won't necessarily be a MatrixError, but we duck-type // here and say if it's got an 'errcode' key with the right value, // it means we can't peek. @@ -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++) { diff --git a/src/components/views/rooms/AppsDrawer.js b/src/components/views/rooms/AppsDrawer.js index 1c9296228d..9bc946bc4b 100644 --- a/src/components/views/rooms/AppsDrawer.js +++ b/src/components/views/rooms/AppsDrawer.js @@ -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; } },