-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IdleService #427
IdleService #427
Conversation
Was looking for a default display of this (app overrideable) more like what we have in Hoist Sencha. This looks like a start, but really need that bit in order to merge things. Also, the Hoist Sencha version had the ability to change this per user via preference. Seems like for consistency we really just want to mirror everything we have in Hoist Sencha. |
Took a look at this. I like how the app can specify any We're missing a few features that we need to reach parity with Hoist Sencha:
See https://github.com/exhi/hoist-sencha/blob/develop/grails-app/assets/src/xh/all/svc/IdleService.js for how these features are implemented in Hoist Sencha |
app/AppContainer.js
Outdated
@@ -58,7 +59,8 @@ export class AppContainer extends Component { | |||
render() { | |||
return div( | |||
this.renderContent(), | |||
exceptionDialog() // Always render the exception dialog -- might need it :-( | |||
exceptionDialog(), // Always render the exception dialog -- might need it :-( | |||
idleWrapper() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thinks this belongs more properly down around line 90. Is not analogous to the exceptionDialog in needing to be rendered in all states. Can we call it idleDialog for symmetry? Also, can we perhaps trigger this with a LoadState.IDLE. Think it makes more sense to handle that way, since this is a terminal state. It will be easier to reason about, and we can avoid the extra wrapper component.
app/impl/IdleWrapper.js
Outdated
import {Component} from 'react'; | ||
import {XH, HoistComponent, elemFactory} from '@xh/hoist/core'; | ||
|
||
@HoistComponent() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry -- you made those last changes so quickly, I hadn't finished my comments. Don't think we need this wrapper component. This null check can be just made inline in the main renderer.
core/HoistApp.js
Outdated
@@ -62,6 +63,21 @@ export function HoistApp(C) { | |||
}; | |||
}, | |||
|
|||
/** | |||
* App must implement this method with appropriate logic to display a message when the app | |||
* has been idle for the amount of minutes defined by the `xhxhIdleTimeoutMins` config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling mistake here....
core/HoistApp.js
Outdated
@@ -62,6 +63,21 @@ export function HoistApp(C) { | |||
}; | |||
}, | |||
|
|||
/** | |||
* App must implement this method with appropriate logic to display a message when the app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'may override' instead of 'must implement'
core/HoistApp.js
Outdated
* has been idle for the amount of minutes defined by the `xhxhIdleTimeoutMins` config. | ||
* @param {Function} callback - A callback function to be handled by the showIdleDialog | ||
*/ | ||
showIdleDialog(callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps this should be named 'renderIdleDialog()' if its job is to return a react element that can be rendered.
svc/IdleService.js
Outdated
|
||
window.dispatchEvent(new CustomEvent('appSuspended')); | ||
XH.idleComponent = XH.app.showIdleDialog(() => { | ||
window.location.reload(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the flag for reload (e.g. reload(true)) missing?? This is clearly in the sencha source, and we spent a long time troubleshooting problems related to that...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the initial idleService PR (https://github.com/exhi/hoist/pull/250/files) as source for these changes so I would be able to take compare the whole implementation instead of just looking at the final code in IdleService.js
. That's why some things were missing like using an app config or user config to disable the service. I'll add the flag to disable cache.
svc/IdleService.js
Outdated
this.destroyAppListener(); | ||
Timer.cancelAll(); | ||
|
||
window.dispatchEvent(new CustomEvent('appSuspended')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use window.dispatchEvent, or anything like window events. Realize we are trying to mimic the sencha implementation here, but not sure we need this. Also, the term suspended is just a new word -- if we were going to have such an event would probably want something with the word 'idle' in it
yes, that's always a risk with looking at a single pull request -- gotta
look at the latest and greatest of the code in question,
…On Mon, Jul 9, 2018 at 3:02 PM, Guilherme Lopes ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In svc/IdleService.js
<#427 (comment)>:
> + destroyAppListener() {
+ window.removeEventListener('keydown', this.resetTimer, true);
+ window.removeEventListener('mousemove', this.resetTimer, true);
+ window.removeEventListener('mousedown', this.resetTimer, true);
+ window.removeEventListener('scroll', this.resetTimer, true);
+ }
+
+ @action
+ timeout() {
+ this.task.cancel();
+ this.destroyAppListener();
+ Timer.cancelAll();
+
+ window.dispatchEvent(new CustomEvent('appSuspended'));
+ XH.idleComponent = XH.app.showIdleDialog(() => {
+ window.location.reload();
I used the initial idleService PR (https://github.com/exhi/
hoist/pull/250/files) as source for these changes so I would be able to
take compare the whole implementation instead of just looking at the final
code in IdleService.js. That's why some things were missing like using an
app config or user config to disable the service. I'll add the flag to
disable cache.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#427 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACM16TzUlcYvliPjSa3Lv_r0VcRZ64nfks5uE6i2gaJpZM4VAJ_c>
.
|
+ enhancement to MessageModel for direct open + LoadState => AppState
# Conflicts: # core/XH.js
I refactored this a bit, and it led to a larger refactor to create a new notion of AppState, which includes AppState.SUSPENDED. Also simplified the implementation of IdleService and its timers, and also the way in which applications override the default component. Also some unrelated file moves from '/app' package to '/impl'. cr: atm (partially, IdleService review still pending) |
#132