Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: restrict attachment upload by logged out users

Ammar Ahmede690973107dc
diff --git a/apps/mobile/app/screens/editor/tiptap/types.ts b/apps/mobile/app/screens/editor/tiptap/types.ts
index 3248d27c7..d40cf1dee 100644
--- a/apps/mobile/app/screens/editor/tiptap/types.ts
+++ b/apps/mobile/app/screens/editor/tiptap/types.ts
@@ -59,6 +59,7 @@ export type Settings = {
fontScale: number;
markdownShortcuts: boolean;
features: Record<any, any>;
+ loggedIn: boolean;
};
export type EditorProps = {
diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor-events.tsx b/apps/mobile/app/screens/editor/tiptap/use-editor-events.tsx
index 9a86c2314..11906e3d7 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor-events.tsx
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor-events.tsx
@@ -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();
diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsx
index 917052441..9c80c9315 100644
--- a/packages/editor-mobile/src/components/editor.tsx
+++ b/packages/editor-mobile/src/components/editor.tsx
@@ -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(
diff --git a/packages/editor-mobile/src/hooks/useSettings.ts b/packages/editor-mobile/src/hooks/useSettings.ts
index 1ced7d836..584aca477 100644
--- a/packages/editor-mobile/src/hooks/useSettings.ts
+++ b/packages/editor-mobile/src/hooks/useSettings.ts
@@ -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 = {
diff --git a/packages/editor-mobile/src/utils/index.ts b/packages/editor-mobile/src/utils/index.ts
index 6ffcb8e9b..6ffe87e85 100644
--- a/packages/editor-mobile/src/utils/index.ts
+++ b/packages/editor-mobile/src/utils/index.ts
@@ -53,6 +53,7 @@ export type Settings = {
fontScale: number;
markdownShortcuts: boolean;
features: Record<any, any>;
+ loggedIn: boolean;
};
/* eslint-disable no-var */