refactor: 💡 remove usage of ember/runloop & ember-pollster (#2705)

* refactor: 💡 remove usage of ember/runloop & ember-pollster

---------

Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
This commit is contained in:
Lisbet AlvarezandZhihe Li authored and GitHub committed 2025-03-06 12:20:48 -08:00
1 parent e29a83ec25
commit 29bde998ed
23 files changed
+225 -197

No files matched your search

@@ -7,7 +7,7 @@ import Route from '@ember/routing/route';
import { getOwner } from '@ember/application';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import runEvery from 'ember-pollster/decorators/route/run-every';
import { task, timeout } from 'ember-concurrency';
import { notifyError } from 'core/decorators/notify';
import config from '../../../../../config/environment';
@@ -20,6 +20,15 @@ export default class ScopesScopeAuthenticateMethodOidcRoute extends Route {
@service windowManager;
@service router;
// =attributes
poller = task(async () => {
while (!this.session.isAuthenticated) {
await timeout(POLL_TIMEOUT_SECONDS * 1000);
this.refresh();
}
});
// =methods
beforeModel;
@@ -43,9 +52,11 @@ export default class ScopesScopeAuthenticateMethodOidcRoute extends Route {
controller.authMethod = authMethod;
}
@runEvery(POLL_TIMEOUT_SECONDS * 1000)
poller() {
this.refresh();
/**
* When this route is activated (entered), start polling for authentication.
*/
activate() {
this.poller.perform();
}
/**
@@ -53,6 +64,7 @@ export default class ScopesScopeAuthenticateMethodOidcRoute extends Route {
* any windows opened via the window manager service.
*/
deactivate() {
this.poller.cancelAll();
this.windowManager.closeAll();
}