mobile: restrict attachment upload by logged out users

This commit is contained in:
Ammar Ahmed
2025-10-29 12:33:20 +05:00
parent 351d412fdf
commit e690973107
5 changed files with 22 additions and 7 deletions

View File

@@ -59,6 +59,7 @@ export type Settings = {
fontScale: number;
markdownShortcuts: boolean;
features: Record<any, any>;
loggedIn: boolean;
};
export type EditorProps = {

View File

@@ -165,6 +165,7 @@ export const useEditorEvents = (
state.timeFormat
]);
const handleBack = useRef<NativeEventSubscription>();
const loggedIn = useUserStore((state) => !!state.user);
const { fontScale } = useWindowDimensions();
const doubleSpacedLines = useSettingStore(
@@ -224,7 +225,8 @@ export const useEditorEvents = (
timeFormat: db.settings?.getTimeFormat(),
fontScale,
markdownShortcuts,
features
features,
loggedIn
});
}, [
fullscreen,
@@ -242,7 +244,8 @@ export const useEditorEvents = (
timeFormat,
loading,
fontScale,
markdownShortcuts
markdownShortcuts,
loggedIn
]);
const onBackPress = useCallback(async () => {
@@ -556,9 +559,17 @@ export const useEditorEvents = (
if (editor.state.current?.isFocused) {
editor.state.current.isFocused = true;
}
PaywallSheet.present(
await isFeatureAvailable(editorMessage.value.feature)
);
if (editorMessage.value.feature === "insertAttachment") {
ToastManager.show({
type: "info",
message: strings.loginRequired()
});
} else {
PaywallSheet.present(
await isFeatureAvailable(editorMessage.value.feature)
);
}
break;
case EditorEvents.monograph:
publishNote();

View File

@@ -113,7 +113,8 @@ const Tiptap = ({
claims: {
callout: !!settings.features?.callout?.isAllowed,
outlineList: !!settings.features?.outlineList?.isAllowed,
taskList: !!settings.features?.taskList?.isAllowed
taskList: !!settings.features?.taskList?.isAllowed,
insertAttachment: settings.loggedIn
},
onPermissionDenied: (claim) => {
post(

View File

@@ -34,7 +34,8 @@ const initialState = {
fontFamily: "sans-serif",
fontSize: 16,
timeFormat: "12-hour",
dateFormat: "DD-MM-YYYY"
dateFormat: "DD-MM-YYYY",
loggedIn: false
};
global.settingsController = {

View File

@@ -53,6 +53,7 @@ export type Settings = {
fontScale: number;
markdownShortcuts: boolean;
features: Record<any, any>;
loggedIn: boolean;
};
/* eslint-disable no-var */