Skip to content

Commit c4dc643

Browse files
committed
refactor
1 parent ed392b6 commit c4dc643

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

services/static-webserver/client/source/class/osparc/WindowSizeTracker.js

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ qx.Class.define("osparc.WindowSizeTracker", {
4040
},
4141

4242
tooSmall: {
43-
check: [null, "shortText", "longText"], // display short message, long one or none
43+
check: [null, "logout", "shortText", "longText"],
4444
init: null,
4545
nullable: true,
4646
apply: "__applyTooSmall"
@@ -71,24 +71,16 @@ qx.Class.define("osparc.WindowSizeTracker", {
7171

7272
this.setCompactVersion(width < this.self().WIDTH_COMPACT_BREAKPOINT);
7373

74-
if (width < this.self().WIDTH_BREAKPOINT || height < this.self().HEIGHT_BREAKPOINT) {
75-
this.setTooSmall(width < this.self().WIDTH_COMPACT_BREAKPOINT ? "shortText" : "longText");
74+
if (width < this.self().WIDTH_LOGOUT_BREAKPOINT) {
75+
this.setTooSmall("logout");
76+
} else if (width < this.self().WIDTH_COMPACT_BREAKPOINT) {
77+
this.setTooSmall("shortText");
78+
} else if (width < this.self().WIDTH_BREAKPOINT) {
79+
this.setTooSmall("longText");
7680
} else {
7781
this.setTooSmall(null);
7882
}
7983

80-
if (width < this.self().MIN_WIDTH_LOGOUT) {
81-
if (this.__tooSmallDialog) {
82-
this.__tooSmallDialog.center();
83-
this.__tooSmallDialog.open();
84-
} else {
85-
this.__tooSmallDialog = osparc.TooSmallDialog.openWindow();
86-
this.__tooSmallDialog.addListener("close", () => this.__tooSmallDialog = null, this);
87-
}
88-
} else if (this.__tooSmallDialog) {
89-
this.__tooSmallDialog.close();
90-
}
91-
9284
this.set({
9385
windowWidth: width,
9486
windowHeight: height
@@ -103,14 +95,16 @@ qx.Class.define("osparc.WindowSizeTracker", {
10395
}
10496

10597
let notification = null;
106-
if (tooSmall === "shortText") {
98+
if (tooSmall === "logout" || tooSmall === "shortText") {
10799
notification = new osparc.notification.RibbonNotification(null, "smallWindow", true);
108100
} else if (tooSmall === "longText") {
109101
const text = this.__getLongText(true);
110102
notification = new osparc.notification.RibbonNotification(text, "smallWindow", true);
111103
}
112104
osparc.notification.RibbonNotifications.getInstance().addNotification(notification);
113105
this.__lastRibbonMessage = notification;
106+
107+
this.evaluateTooSmallDialog();
114108
},
115109

116110
__getLongText: function() {
@@ -125,6 +119,21 @@ qx.Class.define("osparc.WindowSizeTracker", {
125119
osparc.notification.RibbonNotifications.getInstance().removeNotification(this.__lastRibbonMessage);
126120
this.__lastRibbonMessage = null;
127121
}
122+
},
123+
124+
evaluateTooSmallDialog: function() {
125+
const tooSmall = this.getTooSmall();
126+
if (tooSmall === "logout") {
127+
if (this.__tooSmallDialog) {
128+
this.__tooSmallDialog.center();
129+
this.__tooSmallDialog.open();
130+
} else {
131+
this.__tooSmallDialog = osparc.TooSmallDialog.openWindow();
132+
this.__tooSmallDialog.addListener("close", () => this.__tooSmallDialog = null, this);
133+
}
134+
} else if (this.__tooSmallDialog) {
135+
this.__tooSmallDialog.close();
136+
}
128137
}
129138
}
130139
});

0 commit comments

Comments
 (0)