(core) Skip showing empty doc tours

Summary: Empty doc tours are now skipped. Before, an error was shown instead.

Test Plan: Browser test.

Reviewers: jarek

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D4204
This commit is contained in:
George Gevoian
2024-03-04 17:48:40 -05:00
parent ca8ac806db
commit a5099fc598
2 changed files with 34 additions and 8 deletions

View File

@@ -358,9 +358,9 @@ export class GristDoc extends DisposableWithEvents {
urlState().state,
isTourActiveObs(),
fromKo(this.docModel.isTutorial),
(_use, state, hasActiveTour, isTutorial) => {
async (_use, state, hasActiveTour, isTutorial) => {
// Tours and tutorials can interfere with in-product tips and announcements.
const hasPendingDocTour = state.docTour || this._shouldAutoStartDocTour();
const hasPendingDocTour = state.docTour || await this._shouldAutoStartDocTour();
const hasPendingWelcomeTour = state.welcomeTour || this._shouldAutoStartWelcomeTour();
const isPopupManagerDisabled = this.behavioralPromptsManager.isDisabled();
if (
@@ -401,7 +401,7 @@ export class GristDoc extends DisposableWithEvents {
}
const shouldStartTutorial = isTutorial;
const shouldStartDocTour = state.docTour || this._shouldAutoStartDocTour();
const shouldStartDocTour = state.docTour || await this._shouldAutoStartDocTour();
const shouldStartWelcomeTour = state.welcomeTour || this._shouldAutoStartWelcomeTour();
if (shouldStartTutorial || shouldStartDocTour || shouldStartWelcomeTour) {
isStartingTourOrTutorial = true;
@@ -1823,15 +1823,22 @@ export class GristDoc extends DisposableWithEvents {
/**
* Returns whether a doc tour should automatically be started.
*
* Currently, tours are started if a GristDocTour table exists and the user hasn't
* seen the tour before.
* Currently, tours are started if a non-empty GristDocTour table exists and the
* user hasn't seen the tour before.
*/
private _shouldAutoStartDocTour(): boolean {
if (this._disableAutoStartingTours || this.docModel.isTutorial()) {
private async _shouldAutoStartDocTour(): Promise<boolean> {
if (
this._disableAutoStartingTours ||
this.docModel.isTutorial() ||
!this.docModel.hasDocTour() ||
this._seenDocTours.get()?.includes(this.docId())
) {
return false;
}
return this.docModel.hasDocTour() && !this._seenDocTours.get()?.includes(this.docId());
const tableData = this.docData.getTable('GristDocTour')!;
await this.docData.fetchTable('GristDocTour');
return tableData.numRecords() > 0;
}
/**