react-dynamic-help
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -25,2 +25,3 @@ import * as React from "react"; | ||
export declare class HelpController extends React.Component<HelpControllerProps, HelpControllerState> { | ||
registeredFlows: Set<string>; | ||
appTargets: AppTargetsState; | ||
@@ -27,0 +28,0 @@ systemState: SystemState; |
@@ -71,3 +71,3 @@ "use strict"; | ||
} | ||
const _resetState = { | ||
const __resetState = { | ||
systemEnabled: true, | ||
@@ -92,2 +92,5 @@ flows: {}, | ||
super(props); | ||
// Here we track which flows have definitely registered, and therefore are present in the current | ||
// JSX of the application (as opposed to flows that were once present, saved in storage, but removed from the application) | ||
this.registeredFlows = new Set(); | ||
// we accumulate multiple updates to state per render cycle (due to refs changing on render) here. | ||
@@ -97,3 +100,3 @@ // .. the ultimate value of these ends up in this.state (and storage) when react finally updates the state, | ||
this.appTargets = { targetItems: {} }; | ||
this.systemState = _resetState; | ||
this.systemState = __resetState; | ||
this.propagateSystemState = () => { | ||
@@ -117,3 +120,3 @@ (0, DynamicHelp_1.log)(this.props.debug, "HelpController state update:", this.systemState); | ||
}); | ||
this.systemState = this.props.storage.get("system-state", _resetState); | ||
this.systemState = this.props.storage.get("system-state", __resetState); | ||
(0, DynamicHelp_1.log)(this.props.debug, "Initial state loaded:", this.systemState); | ||
@@ -191,6 +194,8 @@ this.setState({ systemState: this.systemState }); | ||
(0, DynamicHelp_1.log)(this.props.debug, "Info: resetting help system state"); | ||
this.systemState = _resetState; | ||
this.systemState = __resetState; | ||
this.propagateSystemState(); | ||
}; | ||
this.getFlowInfo = () => Object.values(this.systemState.flows); | ||
// Only share registered flows with the app. | ||
// The other flow info that we have from stored state is presumably out of date and therefore irrelevant | ||
this.getFlowInfo = () => Array.from(this.registeredFlows).map((flowId) => this.systemState.flows[flowId]); | ||
// | ||
@@ -202,2 +207,3 @@ // API for Help Flows and Help Items to interact with systemState. | ||
(0, DynamicHelp_1.log)(this.props.debug, "Flow registration:", id, showInitially); | ||
this.registeredFlows.add(id); | ||
const desc = description || id; | ||
@@ -204,0 +210,0 @@ if (!(id in this.systemState.flows)) { |
@@ -25,2 +25,3 @@ import * as React from "react"; | ||
export declare class HelpController extends React.Component<HelpControllerProps, HelpControllerState> { | ||
registeredFlows: Set<string>; | ||
appTargets: AppTargetsState; | ||
@@ -27,0 +28,0 @@ systemState: SystemState; |
@@ -45,3 +45,3 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; | ||
} | ||
const _resetState = { | ||
const __resetState = { | ||
systemEnabled: true, | ||
@@ -66,2 +66,5 @@ flows: {}, | ||
super(props); | ||
// Here we track which flows have definitely registered, and therefore are present in the current | ||
// JSX of the application (as opposed to flows that were once present, saved in storage, but removed from the application) | ||
this.registeredFlows = new Set(); | ||
// we accumulate multiple updates to state per render cycle (due to refs changing on render) here. | ||
@@ -71,3 +74,3 @@ // .. the ultimate value of these ends up in this.state (and storage) when react finally updates the state, | ||
this.appTargets = { targetItems: {} }; | ||
this.systemState = _resetState; | ||
this.systemState = __resetState; | ||
this.propagateSystemState = () => { | ||
@@ -91,3 +94,3 @@ log(this.props.debug, "HelpController state update:", this.systemState); | ||
}); | ||
this.systemState = this.props.storage.get("system-state", _resetState); | ||
this.systemState = this.props.storage.get("system-state", __resetState); | ||
log(this.props.debug, "Initial state loaded:", this.systemState); | ||
@@ -165,6 +168,8 @@ this.setState({ systemState: this.systemState }); | ||
log(this.props.debug, "Info: resetting help system state"); | ||
this.systemState = _resetState; | ||
this.systemState = __resetState; | ||
this.propagateSystemState(); | ||
}; | ||
this.getFlowInfo = () => Object.values(this.systemState.flows); | ||
// Only share registered flows with the app. | ||
// The other flow info that we have from stored state is presumably out of date and therefore irrelevant | ||
this.getFlowInfo = () => Array.from(this.registeredFlows).map((flowId) => this.systemState.flows[flowId]); | ||
// | ||
@@ -176,2 +181,3 @@ // API for Help Flows and Help Items to interact with systemState. | ||
log(this.props.debug, "Flow registration:", id, showInitially); | ||
this.registeredFlows.add(id); | ||
const desc = description || id; | ||
@@ -178,0 +184,0 @@ if (!(id in this.systemState.flows)) { |
{ | ||
"name": "react-dynamic-help", | ||
"description": "React Dynamic Help - Create flows of helpful popups in your React App", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -10,3 +10,3 @@ # react-dynamic-help | ||
V 1.1.1 - Basic implementation of the concept, enough features to actually use. | ||
V 1.1.2 - Basic implementation of the concept, enough features to actually use. | ||
@@ -13,0 +13,0 @@ Demo at https://github.com/GreenAsJade/react-dynamic-help-demo |
111819
2373