Remember whether widget drawer was hidden per-room
Fixes #4850 Signed-off-by: Andrew (anoa) <anoa@openmailbox.org>
This commit is contained in:
parent
0463f0e581
commit
f032284eff
2 changed files with 28 additions and 3 deletions
|
@ -305,6 +305,20 @@ module.exports = React.createClass({
|
||||||
_shouldShowApps: function(room) {
|
_shouldShowApps: function(room) {
|
||||||
if (!BROWSER_SUPPORTS_SANDBOX) return false;
|
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');
|
const appsStateEvents = room.currentState.getStateEvents('im.vector.modular.widgets');
|
||||||
// any valid widget = show apps
|
// any valid widget = show apps
|
||||||
for (let i = 0; i < appsStateEvents.length; i++) {
|
for (let i = 0; i < appsStateEvents.length; i++) {
|
||||||
|
|
|
@ -83,14 +83,25 @@ module.exports = React.createClass({
|
||||||
onAction: function(action) {
|
onAction: function(action) {
|
||||||
switch (action.action) {
|
switch (action.action) {
|
||||||
case 'appsDrawer':
|
case 'appsDrawer':
|
||||||
// When opening the app draw when there aren't any apps, auto-launch the
|
// When opening the app drawer when there aren't any apps,
|
||||||
// integrations manager to skip the awkward click on "Add widget"
|
// 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) {
|
if (action.show) {
|
||||||
const apps = this._getApps();
|
const apps = this._getApps();
|
||||||
if (apps.length === 0) {
|
if (apps.length === 0) {
|
||||||
this._launchManageIntegrations();
|
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;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue