* feat: introduce native smart tags * feat: introduce react navigation * feat: render smart tag special cases * feat: add create tag & all count * feat: move components to react + mobx * fix: workaround issue with snjs * feat: nice smart tag icons in experimental * feat: add back components * fix: typo on all tags * feat: add panel resizer + simplif code * fix: panel resize size & refresh * fix: auto select all notes * style: remove legacy tag view * style: remove legacy directives * fix: select tag from note view * feat: WIP smart tag rename * fix: template checks * fix: user can create new notes * panel: init width * fix: panel resizer ref * fix: update with new component viewer * fix: use fixed isTemplateItem & fixed findItems * refactor: rename tags panel into navigation * style: remove TODOs that are ok * feat: smart tag premium check with premium service * refactor: multi-select variables for debuggability * fix: clean deinit code * fix: prevent trigger tag changes event for the same uuid * fix: typings * fix: use minimal state * style: remove dead code * style: long variable names * refactor: move magic string to module * fix: use smart filter feature * refactor: add task id in todo
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { FeaturesState } from '@/ui_models/app_state/features_state';
|
|
import { observer } from 'mobx-react-lite';
|
|
import { FunctionalComponent } from 'preact';
|
|
import { useCallback, useContext, useState } from 'preact/hooks';
|
|
import { createContext } from 'react';
|
|
import { PremiumFeaturesModal } from '../PremiumFeaturesModal';
|
|
|
|
type PremiumModalContextData = {
|
|
activate: (featureName: string) => void;
|
|
};
|
|
|
|
const PremiumModalContext = createContext<PremiumModalContextData | null>(null);
|
|
|
|
const PremiumModalProvider_ = PremiumModalContext.Provider;
|
|
|
|
export const usePremiumModal = (): PremiumModalContextData => {
|
|
const value = useContext(PremiumModalContext);
|
|
|
|
if (!value) {
|
|
throw new Error('invalid PremiumModal context');
|
|
}
|
|
|
|
return value;
|
|
};
|
|
|
|
interface Props {
|
|
state: FeaturesState;
|
|
}
|
|
|
|
export const PremiumModalProvider: FunctionalComponent<Props> = observer(
|
|
({ state, children }) => {
|
|
const featureName = state._premiumAlertFeatureName;
|
|
const activate = state.showPremiumAlert;
|
|
const close = state.closePremiumAlert;
|
|
|
|
const showModal = !!featureName;
|
|
|
|
return (
|
|
<>
|
|
{showModal && (
|
|
<PremiumFeaturesModal
|
|
showModal={!!featureName}
|
|
featureName={featureName}
|
|
onClose={close}
|
|
/>
|
|
)}
|
|
<PremiumModalProvider_ value={{ activate }}>
|
|
{children}
|
|
</PremiumModalProvider_>
|
|
</>
|
|
);
|
|
}
|
|
);
|