Skip to content

Commit 08d0017

Browse files
author
Pedro
committed
Add information about the skipped step
1 parent 07795e7 commit 08d0017

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Along with `this.props.start()`, `copilot` HOC passes `copilotEvents` function t
184184
List of available events is:
185185

186186
- `start` — Copilot tutorial has started.
187-
- `stop` — Copilot tutorial has ended or skipped.
187+
- `stop` — Copilot tutorial has ended.
188188
- `stepChange` — Next step is triggered. Passes [`Step`](https://github.com/okgrow/react-native-copilot/blob/master/src/types.js#L2) instance as event handler argument.
189189

190190

src/components/CopilotModal.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,11 @@ class CopilotModal extends Component<Props, State> {
212212
this.props.prev();
213213
}
214214

215-
handleStop = () => {
215+
handleStop = (wasSkipped?: boolean) => {
216+
wasSkipped = typeof wasSkipped !== "boolean" ? false : wasSkipped;
217+
216218
this.reset();
217-
this.props.stop();
219+
this.props.stop(wasSkipped);
218220
}
219221

220222
renderMask() {

src/hocs/copilot.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,19 @@ const copilot = ({
148148
}
149149
}
150150

151-
stop = async (): void => {
151+
stop = async (wasSkipped: boolean): void => {
152152
await this.setVisibility(false);
153-
this.eventEmitter.emit('stop');
153+
this.eventEmitter.emit('stop', wasSkipped
154+
? {
155+
wasSkipped: true,
156+
skippedStep: this.state.currentStep,
157+
nextStep: this.getNextStep()
158+
}
159+
: {
160+
wasSkipped: false,
161+
skippedStep: null,
162+
nextStep: null
163+
});
154164
}
155165

156166
async moveToCurrentStep(): void {

0 commit comments

Comments
 (0)