IdleHandler: move message strings inside

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I91da2fda73967d11673f59a4c29fb94f2e12f5a0
This commit is contained in:
Szymon Kłos 2024-01-05 15:52:50 +01:00 committed by Szymon Kłos
parent e9cf81f29e
commit bfc4b1599d
3 changed files with 22 additions and 13 deletions

View file

@ -734,7 +734,7 @@ pot:
src/control/Control.DownloadProgress.js \
src/control/Control.FormulaBar.js \
src/control/Control.FormulaBarJSDialog.js \
src/control/jsdialog/Widget.MobileBorderSelector.js \
src/control/Control.IdleHandler.ts \
src/control/Control.JSDialogBuilder.js \
src/control/Control.LanguageDialog.js \
src/control/Control.Menubar.js \
@ -767,6 +767,7 @@ pot:
src/control/Ruler.js \
src/control/Signing.js \
src/control/Toolbar.js \
src/control/jsdialog/Widget.MobileBorderSelector.js \
src/control/jsdialog/Widget.TreeView.js \
src/core/Socket.js \
src/docstate.js \

View file

@ -27,6 +27,16 @@ class IdleHandler {
map: any;
dimId: string = 'inactive_user_message';
getIdleMessage(): string {
if (this.map['wopi'] && this.map['wopi'].DisableInactiveMessages) {
return '';
} else if (window.mode.isDesktop()) {
return _('Idle document - please click to reload and resume editing');
} else {
return _('Idle document - please tap to reload and resume editing');
}
}
isDimActive(): boolean {
return !!document.getElementById(this.map.uiManager.generateModalId(this.dimId));
}
@ -37,6 +47,8 @@ class IdleHandler {
}
_activate() {
window.app.console.debug('IdleHandler: _activate()');
if (this._serverRecycling || this._documentIdle) {
return false;
}
@ -68,7 +80,11 @@ class IdleHandler {
return false;
}
_dim(message: string) {
_dim() {
const message = this.getIdleMessage();
window.app.console.debug('IdleHandler: _dim(' + message + ')');
this._active = false;
var map = this.map;
@ -111,6 +127,8 @@ class IdleHandler {
}
_deactivate() {
window.app.console.debug('IdleHandler: _deactivate()');
if (this._serverRecycling || this._documentIdle || !this.map._docLoaded) {
return;
}

View file

@ -779,11 +779,6 @@ app.definitions.Socket = L.Class.extend({
postMsgData['Reason'] = 'OwnerTermination';
}
else if (textMsg === 'idle' || textMsg === 'oom') {
if (window.mode.isDesktop()) {
msg = _('Idle document - please click to reload and resume editing');
} else {
msg = _('Idle document - please tap to reload and resume editing');
}
app.idleHandler._documentIdle = true;
this._map._docLayer._documentInfo = undefined;
postMsgData['Reason'] = 'DocumentIdle';
@ -867,13 +862,8 @@ app.definitions.Socket = L.Class.extend({
// Close any open dialogs first.
this._map.uiManager.closeAll();
var message = '';
if (!this._map['wopi'].DisableInactiveMessages) {
message = msg;
}
if (textMsg === 'idle' || textMsg === 'oom') {
app.idleHandler._dim(message);
app.idleHandler._dim();
}
if (postMsgData['Reason']) {