mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-08-31 02:58:34 +02:00
Compare commits
2 Commits
fix-loadin
...
fix-apploc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a898f79595 | ||
|
|
5cd9d48bef |
@@ -75,9 +75,9 @@ const BaseDialog = ({
|
||||
background
|
||||
}: BaseDialogProps) => {
|
||||
const floating = useIsFloatingKeyboard();
|
||||
const appState = useAppState();
|
||||
const lockEvents = useRef(false);
|
||||
const [internalVisible, setIntervalVisible] = useState(true);
|
||||
const locked = useUserStore((state) => state.appLocked);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
@@ -86,26 +86,20 @@ const BaseDialog = ({
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (useUserStore.getState().disableAppLockRequests) return;
|
||||
|
||||
if (SettingsService.canLockAppInBackground()) {
|
||||
if (appState === "background") {
|
||||
setIntervalVisible(false);
|
||||
if (useUserStore.getState().appLocked) {
|
||||
lockEvents.current = true;
|
||||
const unsub = useUserStore.subscribe((state) => {
|
||||
if (!state.appLocked) {
|
||||
setIntervalVisible(true);
|
||||
unsub();
|
||||
setTimeout(() => {
|
||||
lockEvents.current = false;
|
||||
});
|
||||
}
|
||||
if (locked) {
|
||||
setIntervalVisible(false);
|
||||
lockEvents.current = true;
|
||||
const unsub = useUserStore.subscribe((state) => {
|
||||
if (!state.appLocked) {
|
||||
setIntervalVisible(true);
|
||||
unsub();
|
||||
setTimeout(() => {
|
||||
lockEvents.current = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [appState]);
|
||||
}, [locked]);
|
||||
|
||||
const Wrapper = useSafeArea ? SafeAreaView : View;
|
||||
|
||||
|
||||
@@ -59,8 +59,9 @@ const SheetWrapper = ({
|
||||
const smallTablet = deviceMode === "smallTablet";
|
||||
const dimensions = useSettingStore((state) => state.dimensions);
|
||||
const insets = useGlobalSafeAreaInsets();
|
||||
const appState = useAppState();
|
||||
const lockEvents = useRef(false);
|
||||
const locked = useUserStore((state) => state.appLocked);
|
||||
|
||||
let width = dimensions.width > 600 ? 600 : 500;
|
||||
|
||||
const style = React.useMemo(() => {
|
||||
@@ -99,24 +100,21 @@ const SheetWrapper = ({
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (useUserStore.getState().disableAppLockRequests) return;
|
||||
if (SettingsService.canLockAppInBackground()) {
|
||||
if (appState === "background") {
|
||||
const ref = fwdRef || localRef;
|
||||
ref?.current?.hide();
|
||||
if (useUserStore.getState().appLocked) {
|
||||
lockEvents.current = true;
|
||||
const unsub = useUserStore.subscribe((state) => {
|
||||
if (!state.appLocked) {
|
||||
ref?.current?.show();
|
||||
unsub();
|
||||
lockEvents.current = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (locked) {
|
||||
const ref = fwdRef || localRef;
|
||||
ref?.current?.hide();
|
||||
if (useUserStore.getState().appLocked) {
|
||||
lockEvents.current = true;
|
||||
const unsub = useUserStore.subscribe((state) => {
|
||||
if (!state.appLocked) {
|
||||
ref?.current?.show();
|
||||
unsub();
|
||||
lockEvents.current = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [appState, fwdRef]);
|
||||
}, [locked, fwdRef]);
|
||||
|
||||
return (
|
||||
<ScopedThemeProvider value="sheet">
|
||||
|
||||
@@ -43,6 +43,8 @@ import { eCloseSheet } from "../../../utils/events";
|
||||
import { useTabStore } from "./use-tab-store";
|
||||
import { editorController, editorState } from "./utils";
|
||||
import { strings } from "@notesnook/intl";
|
||||
import { useUserStore } from "../../../stores/use-user-store";
|
||||
import { sleep } from "../../../utils/time";
|
||||
|
||||
const showEncryptionSheet = (file: DocumentPickerResponse) => {
|
||||
presentSheet({
|
||||
@@ -241,6 +243,13 @@ const gallery = async (options: PickerOptions) => {
|
||||
const pick = async (options: PickerOptions) => {
|
||||
if (!PremiumService.get()) {
|
||||
const user = await db.user.getUser();
|
||||
if (!user) {
|
||||
ToastManager.show({
|
||||
heading: strings.loginRequired(),
|
||||
type: "error"
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (editorState().isFocused) {
|
||||
editorState().isFocused = true;
|
||||
}
|
||||
@@ -251,6 +260,7 @@ const pick = async (options: PickerOptions) => {
|
||||
}
|
||||
return;
|
||||
}
|
||||
useUserStore.getState().setDisableAppLockRequests(true);
|
||||
if (options?.type.startsWith("image") || options?.type === "camera") {
|
||||
if (options.type.startsWith("image")) {
|
||||
gallery(options);
|
||||
@@ -267,6 +277,7 @@ const handleImageResponse = async (
|
||||
options: PickerOptions
|
||||
) => {
|
||||
const result = await AttachImage.present(response, options.context);
|
||||
|
||||
if (!result) return;
|
||||
const compress = result.compress;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user