-
Notifications
You must be signed in to change notification settings - Fork 485
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(notifications): setup and activation
- Gated behind dev setting (`aws.dev.notifications`) - Setup the notifications panel and begin polling in each of the extensions. - Currently the code collects a bunch of information about the state of auth for telemetry (auth_userState). Refactor this code in each extension so that we can re-use that information for the notification rule engine.
- Loading branch information
Showing
14 changed files
with
208 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/*! | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import * as vscode from 'vscode' | ||
import { DevSettings } from '../shared/settings' | ||
import { NotificationsController } from './controller' | ||
import { NotificationsNode } from './panelNode' | ||
import { RuleEngine, getRuleContext } from './rules' | ||
import globals from '../shared/extensionGlobals' | ||
import { AuthState } from './types' | ||
|
||
/** Time in MS to poll for emergency notifications */ | ||
const emergencyPollTime = 1000 * 10 * 60 | ||
|
||
/** | ||
* Activate the in-IDE notifications module and begin receiving notifications. | ||
* | ||
* @param context extension context | ||
* @param initialState initial auth state | ||
* @param authStateFn fn to get current auth state | ||
*/ | ||
export async function activate( | ||
context: vscode.ExtensionContext, | ||
initialState: AuthState, | ||
authStateFn: () => Promise<AuthState> | ||
) { | ||
// TODO: Currently gated behind feature-flag. | ||
if (!DevSettings.instance.get('notifications', false)) { | ||
return | ||
} | ||
|
||
const panelNode = NotificationsNode.instance | ||
panelNode.registerView(context) | ||
|
||
const controller = new NotificationsController(panelNode) | ||
const engine = new RuleEngine(await getRuleContext(context, initialState)) | ||
|
||
void controller.pollForStartUp(engine) | ||
void controller.pollForEmergencies(engine) | ||
|
||
globals.clock.setInterval(async () => { | ||
const ruleContext = await getRuleContext(context, await authStateFn()) | ||
await controller.pollForEmergencies(new RuleEngine(ruleContext)) | ||
}, emergencyPollTime) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.