Compare commits

..

17 Commits

Author SHA1 Message Date
Ammar Ahmed
2febd09613 Merge branch 'master' into fix/sync-quick-notes
Signed-off-by: Ammar Ahmed <40239442+ammarahm-ed@users.noreply.github.com>
2023-04-26 15:13:27 +05:00
ammarahm-ed
91138f4911 mobile: ensure full db init when sync is required 2023-04-26 15:12:29 +05:00
ammarahm-ed
f9bcfe2f7a mobile: obfuscate short emails 2023-04-26 15:02:56 +05:00
ammarahm-ed
3621f95dbc web: obfuscate short emails 2023-04-26 15:02:56 +05:00
ammarahm-ed
536dead44d mobile: always load notes on init 2023-04-26 14:59:05 +05:00
ammarahm-ed
39d74e80a9 mobile: ensure that overlay gets hidden when entering foreground 2023-04-26 14:59:05 +05:00
ammarahm-ed
46e03dd248 mobile: only show app lock for main activity 2023-04-26 14:59:05 +05:00
ammarahm-ed
152fee2c29 mobile: reload editor if rendered view lost 2023-04-26 14:59:05 +05:00
ammarahm-ed
492a4d16b2 mobile: fix note options ui 2023-04-26 14:58:37 +05:00
ammarahm-ed
3d7c1fa1e7 mobile: fix configure toolbar sheet close with swipe 2023-04-26 14:58:21 +05:00
Ammar Ahmed
8a138d960d Update apps/mobile/app/services/notifications.ts
Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co>
Signed-off-by: Ammar Ahmed <40239442+ammarahm-ed@users.noreply.github.com>
2023-04-26 14:57:06 +05:00
ammarahm-ed
69bb0e3656 editor: fix toolbar dropdown buttons size on mobile 2023-04-26 14:54:30 +05:00
ammarahm-ed
4875cfa108 core: duplicate note without content 2023-04-26 14:47:52 +05:00
ammarahm-ed
a28beb62c6 core: deep clone note when duplicating 2023-04-26 14:46:24 +05:00
Abdullah Atta
21c8960146 web: fix "Unauthorized" error on subscription cancel 2023-04-26 11:39:48 +05:00
ammarahm-ed
59442b9107 mobile: sync quick notes 2023-04-26 09:51:24 +05:00
Abdullah Atta
2ba638b123 web: fix font family on input field labels 2023-04-25 14:47:29 +05:00
16 changed files with 70 additions and 46 deletions

View File

@@ -44,8 +44,10 @@ import Paragraph from "../ui/typography/paragraph";
import { LoginSteps, useLogin } from "./use-login";
function getObfuscatedEmail(email) {
if (!email) return null;
return email.replace(/(.{2})(.*)(?=@)/, function (gp1, gp2, gp3) {
if (!email) return "";
const [username, provider] = email.split("@");
if (username.length === 1) return `****@${provider}`;
return email.replace(/(.{1})(.*)(?=@)/, function (gp1, gp2, gp3) {
for (let i = 0; i < gp3.length; i++) {
gp2 += "*";
}

View File

@@ -37,6 +37,7 @@ import { useNoteStore } from "../../stores/use-notes-store";
import { useSettingStore } from "../../stores/use-setting-store";
import { useThemeStore } from "../../stores/use-theme-store";
import { useUserStore } from "../../stores/use-user-store";
import { AndroidModule } from "../../utils";
import { eOpenAnnouncementDialog } from "../../utils/events";
import { getGithubVersion } from "../../utils/github-version";
import { SIZE } from "../../utils/size";
@@ -192,6 +193,11 @@ const Launcher = React.memo(
const onUnlockBiometrics = useCallback(async () => {
if (!(await BiometricService.isBiometryAvailable())) return;
if (Platform.OS === "android") {
const activityName = await AndroidModule.getActivityName();
if (activityName !== "MainActivity") return;
}
let verified = await BiometricService.validateUser(
"Unlock to access your notes",
""

View File

@@ -116,11 +116,11 @@ export const Items = ({ item, buttons, close }) => {
key={item.id}
testID={"icon-" + item.id}
customStyle={{
alignItems: "center",
alignSelf: "flex-start",
width: topBarItemWidth,
marginBottom: 10,
marginRight: isLast ? 0 : 10,
backgroundColor: "transparent"
backgroundColor: "transparent",
paddingHorizontal: 0
}}
>
<PressableButton
@@ -150,11 +150,7 @@ export const Items = ({ item, buttons, close }) => {
/>
</PressableButton>
<Paragraph
size={SIZE.xxs + 1}
style={{ textAlign: "center" }}
textBreakStrategy="simple"
>
<Paragraph size={SIZE.xxs + 1} style={{ textAlign: "center" }}>
{item.title}
</Paragraph>
</PressableButton>

View File

@@ -613,7 +613,7 @@ export const useActions = ({ close = () => null, item }) => {
},
{
id: "pin",
title: item.pinned ? "Unpin" : "Pin",
title: "Pin",
icon: item.pinned ? "pin-off-outline" : "pin-outline",
func: pinItem,
close: false,
@@ -623,7 +623,7 @@ export const useActions = ({ close = () => null, item }) => {
},
{
id: "favorite",
title: !item.favorite ? "Favorite" : "Unfavorite",
title: "Favorite",
icon: item.favorite ? "star-off" : "star-outline",
func: addToFavorites,
close: false,

View File

@@ -571,8 +571,8 @@ export const useAppEvents = () => {
if (notesAddedFromIntent || shareExtensionOpened) {
let id = useEditorStore.getState().currentEditingNote;
let note = id && db.notes.note(id).data;
eSendEvent("loadingNote", note);
eSendEvent("webview_reset");
setTimeout(() => eSendEvent("loadingNote", note), 1);
MMKV.removeItem("shareExtensionOpened");
}
} catch (e) {

View File

@@ -580,22 +580,21 @@ export const useEditor = (
const onReady = useCallback(async () => {
if (!(await isEditorLoaded(editorRef, sessionIdRef.current))) {
overlay(true);
setLoading(true);
eSendEvent("webview_reset");
} else {
isDefaultEditor && restoreEditorState();
}
}, [overlay, isDefaultEditor, restoreEditorState]);
}, [isDefaultEditor, restoreEditorState]);
useEffect(() => {
state.current.saveCount = 0;
async () => {
(async () => {
await commands.setSessionId(sessionIdRef.current);
if (sessionIdRef.current) {
if (!state.current?.ready) return;
await onReady();
}
};
})();
}, [sessionId, loading, commands, onReady]);
const onLoad = useCallback(async () => {
@@ -636,6 +635,7 @@ export const useEditor = (
saveContent,
onContentChanged,
editorId: editorId,
markImageLoaded
markImageLoaded,
overlay
};
};

View File

@@ -51,6 +51,7 @@ export const EditorWrapper = ({ width }) => {
if (editorState().movedAway) return;
if (state === "active") {
editorController.current.onReady();
editorController.current.overlay(false);
}
};

View File

@@ -86,8 +86,9 @@ async function getNextMonthlyReminderDate(
}
async function initDatabase(notes = true) {
if (db.isInitialized) return;
await db.initCollections();
if (!db.isInitialized) {
await db.initCollections();
}
if (notes) {
await db.notes?.init();
}
@@ -202,14 +203,15 @@ const onEvent = async ({ type, detail }: Event) => {
reply_button_text: "Take note",
reply_placeholder_text: "Write something..."
});
await initDatabase(false);
if (!db.isInitialized) await db.init();
await db.notes?.init();
await db.notes?.add({
content: {
type: "tiptap",
data: `<p>${input} </p>`
}
});
await db.notes?.init();
await db.sync(false, false);
useNoteStore.getState().setNotes();
break;
}

View File

@@ -4,6 +4,7 @@ package com.streetwriters.notesnook;
import android.graphics.Color;
import android.view.WindowManager;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactApplicationContext;
@@ -36,6 +37,16 @@ public class RCTNNativeModule extends ReactContextBaseJavaModule {
}
}
@ReactMethod
public void getActivityName(Promise promise) {
try {
promise.resolve(getCurrentActivity().getClass().getSimpleName());
} catch (Exception e) {
promise.resolve(null);
}
}
@ReactMethod
public void setSecureMode(final boolean mode) {

View File

@@ -26,12 +26,12 @@ import {
Keyboard,
Platform,
SafeAreaView,
ScrollView,
StatusBar,
Text,
TouchableOpacity,
useWindowDimensions,
View,
ScrollView
useWindowDimensions
} from "react-native";
import {
SafeAreaProvider,
@@ -45,10 +45,9 @@ import Storage from "../app/common/database/storage";
import { eSendEvent } from "../app/services/event-manager";
import { getElevation } from "../app/utils";
import { eOnLoadNote } from "../app/utils/events";
import { sleep } from "../app/utils/time";
import { Editor } from "./editor";
import { Search } from "./search";
import { initDatabase, useShareStore } from "./store";
import { Editor } from "./editor";
const getLinkPreview = (url) => {
return getPreviewData(url, 5000);
};
@@ -315,7 +314,6 @@ const ShareView = ({ quicknote = false }) => {
const onPress = async () => {
setLoading(true);
await initDatabase();
await sleep(1500);
if (!noteContent.current) return;
if (appendNote && !db.notes.note(appendNote.id)) {
useShareStore.getState().setAppendNote(null);
@@ -358,6 +356,7 @@ const ShareView = ({ quicknote = false }) => {
}
}
}
await db.sync(false, false);
await Storage.write("notesAddedFromIntent", "added");
close();
setLoading(false);

View File

@@ -29,10 +29,9 @@ import { db } from "../app/common/database";
export async function initDatabase() {
if (!db.isInitialized) {
// Only load collections in database.
await db.initCollections();
await db.notes.init();
await db.init();
}
await db.notes.init();
}
const StorageKeys = {

View File

@@ -92,6 +92,7 @@ function Field(props) {
sx={{
fontSize: "subtitle",
fontWeight: "bold",
fontFamily: "body",
color: "icon",
flexDirection: "column",
...styles.label

View File

@@ -1019,13 +1019,14 @@ function openURL(url: string, force?: boolean) {
function maskEmail(email: string) {
if (!email) return "";
const [username, domain] = email.split("@");
const maskChars = "*".repeat(
username.substring(2, username.length - 2).length
);
return `${username.substring(0, 2)}${maskChars}${username.substring(
username.length - 2
)}@${domain}`;
const [username, provider] = email.split("@");
if (username.length === 1) return `****@${provider}`;
return email.replace(/(.{1})(.*)(?=@)/, function (gp1, gp2, gp3) {
for (let i = 0; i < gp3.length; i++) {
gp2 += "*";
}
return gp2;
});
}
function isSessionExpired() {

View File

@@ -29,13 +29,13 @@ export default class Subscriptions {
}
async cancel() {
const token = this._tokenManager.getAccessToken();
const token = await this._tokenManager.getAccessToken();
if (!token) return;
await http.delete(`${hosts.SUBSCRIPTIONS_HOST}/subscriptions`, token);
}
async updateUrl() {
const token = this._tokenManager.getAccessToken();
const token = await this._tokenManager.getAccessToken();
if (!token) return;
return await http.get(
`${hosts.SUBSCRIPTIONS_HOST}/subscriptions/update_url`,

View File

@@ -24,6 +24,7 @@ import { getContentFromData } from "../content-types";
import { CHECK_IDS, checkIsUserPremium } from "../common";
import { addItem, deleteItem } from "../utils/array";
import { formatDate } from "../utils/date";
import qclone from "qclone";
export default class Note {
/**
@@ -135,12 +136,14 @@ export default class Note {
async duplicate() {
const content = await this._db.content.raw(this._note.contentId);
return await this._db.notes.add({
...this._note,
...qclone(this._note),
id: undefined,
content: {
type: content.type,
data: content.data
},
content: content
? {
type: content.type,
data: content.data
}
: undefined,
readonly: false,
favorite: false,
pinned: false,

View File

@@ -64,6 +64,7 @@ export function Dropdown(props: DropdownProps) {
m: 0,
bg: isPopupOpen ? "hover" : "transparent",
mr: 1,
flexShrink: 0,
display: "flex",
alignItems: "center",
":hover": { bg: "hover" },
@@ -75,7 +76,9 @@ export function Dropdown(props: DropdownProps) {
onMouseDown={(e) => e.preventDefault()}
>
{typeof selectedItem === "string" ? (
<Text sx={{ fontSize: "subBody", mr: 1, color: "text" }}>
<Text
sx={{ fontSize: "subBody", mr: 1, color: "text", flexShrink: 0 }}
>
{selectedItem}
</Text>
) : (