diff --git a/app/assets/javascripts/Components/AttachedFilesPopover/AttachedFilesButton.tsx b/app/assets/javascripts/Components/AttachedFilesPopover/AttachedFilesButton.tsx index af2c3f1ce..2f7b79da4 100644 --- a/app/assets/javascripts/Components/AttachedFilesPopover/AttachedFilesButton.tsx +++ b/app/assets/javascripts/Components/AttachedFilesPopover/AttachedFilesButton.tsx @@ -8,13 +8,7 @@ import { FunctionComponent } from 'preact' import { useCallback, useEffect, useRef, useState } from 'preact/hooks' import { Icon } from '@/Components/Icon' import { useCloseOnBlur } from '@/Hooks/useCloseOnBlur' -import { - ChallengeReason, - ContentType, - FeatureIdentifier, - FeatureStatus, - SNFile, -} from '@standardnotes/snjs' +import { ChallengeReason, ContentType, SNFile } from '@standardnotes/snjs' import { confirmDialog } from '@/Services/AlertService' import { addToast, dismissToast, ToastType } from '@standardnotes/stylekit' import { StreamingFileReader } from '@standardnotes/filepicker' @@ -78,9 +72,7 @@ export const AttachedFilesButton: FunctionComponent = observer( }, [application, reloadAttachedFilesCount]) const toggleAttachedFilesMenu = useCallback(async () => { - if ( - application.features.getFeatureStatus(FeatureIdentifier.Files) !== FeatureStatus.Entitled - ) { + if (!appState.features.isEntitledToFiles) { premiumModal.activate('Files') return } @@ -107,7 +99,7 @@ export const AttachedFilesButton: FunctionComponent = observer( setOpen(newOpenState) } - }, [application.features, onClickPreprocessing, open, premiumModal]) + }, [appState.features.isEntitledToFiles, onClickPreprocessing, open, premiumModal]) const deleteFile = async (file: SNFile) => { const shouldDelete = await confirmDialog({ diff --git a/app/assets/javascripts/Components/NoteView/NoteView.tsx b/app/assets/javascripts/Components/NoteView/NoteView.tsx index 6ddea293d..77bd6bd9d 100644 --- a/app/assets/javascripts/Components/NoteView/NoteView.tsx +++ b/app/assets/javascripts/Components/NoteView/NoteView.tsx @@ -989,7 +989,7 @@ export class NoteView extends PureComponent { )} - {window.enabledUnfinishedFeatures && ( + {this.appState.features.isFilesEnabled && (
void @@ -23,6 +25,7 @@ export class FeaturesState { constructor(private application: WebApplication) { this._hasFolders = this.hasNativeFolders() this._hasSmartViews = this.hasNativeSmartViews() + this._hasFilesBeta = this.isEntitledToFilesBeta() this._premiumAlertFeatureName = undefined makeObservable(this, { @@ -44,6 +47,7 @@ export class FeaturesState { runInAction(() => { this._hasFolders = this.hasNativeFolders() this._hasSmartViews = this.hasNativeSmartViews() + this._hasFilesBeta = this.isEntitledToFilesBeta() }) break default: @@ -64,6 +68,14 @@ export class FeaturesState { return this._hasSmartViews } + public get isFilesEnabled(): boolean { + return this._hasFilesBeta || window.enabledUnfinishedFeatures || isDev + } + + public get isEntitledToFiles(): boolean { + return this._hasFilesBeta + } + public async showPremiumAlert(featureName: string): Promise { this._premiumAlertFeatureName = featureName return when(() => this._premiumAlertFeatureName === undefined) @@ -84,4 +96,13 @@ export class FeaturesState { return status === FeatureStatus.Entitled } + + private isEntitledToFilesBeta(): boolean { + if (window.enabledUnfinishedFeatures) { + return true + } + + const status = this.application.features.getFeatureStatus(FeatureIdentifier.FilesBeta) + return status === FeatureStatus.Entitled + } }