Skip to content

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

mobile: fix build ang bugs

Ammar Ahmedbaa2d1a38940
diff --git a/apps/mobile/app/common/database/index.js b/apps/mobile/app/common/database/index.js
index a7331e2cd..1160372ad 100644
--- a/apps/mobile/app/common/database/index.js
+++ b/apps/mobile/app/common/database/index.js
@@ -36,11 +36,11 @@ database.host(
SSE_HOST: "https://events.streetwriters.co",
SUBSCRIPTIONS_HOST: "https://subscriptions.streetwriters.co",
ISSUES_HOST: "https://issues.streetwriters.co"
- // API_HOST: "http://192.168.43.108:5264",
- // AUTH_HOST: "http://192.168.43.108:8264",
- // SSE_HOST: "http://192.168.43.108:7264",
- // SUBSCRIPTIONS_HOST: "http://192.168.43.108:9264",
- // ISSUES_HOST: "http://192.168.43.108:2624"
+ // API_HOST: "http://192.168.43.5:5264",
+ // AUTH_HOST: "http://192.168.43.5:8264",
+ // SSE_HOST: "http://192.168.43.5:7264",
+ // SUBSCRIPTIONS_HOST: "http://192.168.43.5:9264",
+ // ISSUES_HOST: "http://192.168.43.5:2624"
}
: {
API_HOST: "https://api.notesnook.com",
@@ -61,18 +61,15 @@ database.setup({
},
batchSize: 500,
sqliteOptions: {
- dialect: {
- createDriver: () =>
- new RNSqliteDriver({ async: true, dbName: "test.db" }),
+ dialect: (name) => ({
+ createDriver: () => {
+ return new RNSqliteDriver({ async: true, dbName: name });
+ },
createAdapter: () => new SqliteAdapter(),
createIntrospector: (db) => new SqliteIntrospector(db),
createQueryCompiler: () => new SqliteQueryCompiler()
- }
- // journalMode: "MEMORY",
- // synchronous: "normal",
- // pageSize: 8192,
- // cacheSize: -16000,
- // lockingMode: "exclusive"
+ }),
+ tempStore: "memory"
}
});
diff --git a/apps/mobile/app/common/database/sqlite.kysely.ts b/apps/mobile/app/common/database/sqlite.kysely.ts
index 1ac2fb407..e4d9e855d 100644
--- a/apps/mobile/app/common/database/sqlite.kysely.ts
+++ b/apps/mobile/app/common/database/sqlite.kysely.ts
@@ -45,15 +45,15 @@ export class RNSqliteDriver implements Driver {
}
async beginTransaction(connection: DatabaseConnection): Promise<void> {
- await connection.executeQuery(CompiledQuery.raw("begin"));
+ await connection.executeQuery(CompiledQuery.raw("BEGIN TRANSACTION"));
}
async commitTransaction(connection: DatabaseConnection): Promise<void> {
- await connection.executeQuery(CompiledQuery.raw("commit"));
+ await connection.executeQuery(CompiledQuery.raw("COMMIT"));
}
async rollbackTransaction(connection: DatabaseConnection): Promise<void> {
- await connection.executeQuery(CompiledQuery.raw("rollback"));
+ await connection.executeQuery(CompiledQuery.raw("ROLLBACK"));
}
async releaseConnection(): Promise<void> {
diff --git a/apps/mobile/app/components/merge-conflicts/index.js b/apps/mobile/app/components/merge-conflicts/index.js
index 2d5f36a89..18cff390e 100644
--- a/apps/mobile/app/components/merge-conflicts/index.js
+++ b/apps/mobile/app/components/merge-conflicts/index.js
@@ -62,7 +62,7 @@ const MergeConflicts = () => {
const applyChanges = async () => {
let _content = keep;
- let note = db.notes.note(_content.noteId).data;
+ let note = await db.notes.note(_content.noteId);
await db.notes.add({
id: note.id,
conflicted: false,
@@ -100,7 +100,7 @@ const MergeConflicts = () => {
};
const show = async (item) => {
- let noteContent = await db.content.raw(item.contentId);
+ let noteContent = await db.content.get(item.contentId);
content.current = { ...noteContent };
if (__DEV__) {
if (!noteContent.conflicted) {
@@ -320,7 +320,7 @@ const MergeConflicts = () => {
readonly
editorId=":conflictPrimary"
onLoad={async () => {
- const note = db.notes.note(content.current?.noteId)?.data;
+ const note = await db.notes.note(content.current?.noteId);
if (!note) return;
await sleep(300);
eSendEvent(eOnLoadNote + ":conflictPrimary", {
@@ -357,7 +357,7 @@ const MergeConflicts = () => {
readonly
editorId=":conflictSecondary"
onLoad={async () => {
- const note = db.notes.note(content.current?.noteId)?.data;
+ const note = await db.notes.note(content.current?.noteId);
if (!note) return;
await sleep(300);
eSendEvent(eOnLoadNote + ":conflictSecondary", {
diff --git a/apps/mobile/app/components/sheets/add-to/index.tsx b/apps/mobile/app/components/sheets/add-to/index.tsx
index b28db189b..9de5afe20 100644
--- a/apps/mobile/app/components/sheets/add-to/index.tsx
+++ b/apps/mobile/app/components/sheets/add-to/index.tsx
@@ -136,7 +136,7 @@ const MoveNoteSheet = ({
const renderNotebook = useCallback(
({ item, index }: { item: string | number; index: number }) => (
- <NotebookItem items={notebooks} id={item as string} index={index} />
+ <NotebookItem items={notebooks} id={index} index={index} />
),
[notebooks]
);
diff --git a/apps/mobile/app/components/sheets/add-to/notebook-item.tsx b/apps/mobile/app/components/sheets/add-to/notebook-item.tsx
index 88ead4212..bf3b5843b 100644
--- a/apps/mobile/app/components/sheets/add-to/notebook-item.tsx
+++ b/apps/mobile/app/components/sheets/add-to/notebook-item.tsx
@@ -52,8 +52,10 @@ export const NotebookItem = ({
parent?: NotebookParentProp;
items?: VirtualizedGrouping<Notebook>;
}) => {
- const expanded = useNotebookExpandedStore((state) => state.expanded[id]);
- const { nestedNotebooks, notebook: item } = useNotebook(id, items, expanded);
+ const { nestedNotebooks, notebook: item } = useNotebook(id, items, true);
+ const expanded = useNotebookExpandedStore((state) =>
+ item?.id ? state.expanded[item?.id] : false
+ );
const { totalNotes: totalNotes, getTotalNotes } = useTotalNotes("notebook");
const focusedRouteId = useNavigationStore((state) => state.focusedRouteId);
const { colors } = useThemeColors("sheet");
@@ -240,8 +242,8 @@ export const NotebookItem = ({
? null
: nestedNotebooks?.ids.map((id, index) => (
<NotebookItem
- key={item?.id + "_" + id}
- id={id}
+ key={item?.id + "_" + index}
+ id={index}
index={index}
currentLevel={currentLevel + 1}
items={nestedNotebooks}
diff --git a/apps/mobile/app/components/sheets/notebook-sheet/index.tsx b/apps/mobile/app/components/sheets/notebook-sheet/index.tsx
index 5ad0929c6..0f66523c4 100644
--- a/apps/mobile/app/components/sheets/notebook-sheet/index.tsx
+++ b/apps/mobile/app/components/sheets/notebook-sheet/index.tsx
@@ -16,7 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { GroupHeader, Notebook, VirtualizedGrouping } from "@notesnook/core";
+import { Notebook, VirtualizedGrouping } from "@notesnook/core";
import { useThemeColors } from "@notesnook/theme";
import React, {
createContext,
@@ -149,7 +149,7 @@ export const NotebookSheet = () => {
}) => (
<NotebookItem
items={notebooks}
- id={item as string}
+ id={index}
index={index}
totalNotes={totalNotes}
/>
@@ -588,7 +588,7 @@ const NotebookItem = ({
: item &&
nestedNotebooks?.ids.map((id, index) => (
<NotebookItem
- key={item.id + "_" + id}
+ key={item.id + "_" + index}
id={index}
index={index}
totalNotes={nestedNotebookNotesCount}
diff --git a/apps/mobile/app/components/side-menu/menu-item.js b/apps/mobile/app/components/side-menu/menu-item.js
index e761e0042..4baee6244 100644
--- a/apps/mobile/app/components/side-menu/menu-item.js
+++ b/apps/mobile/app/components/side-menu/menu-item.js
@@ -44,7 +44,10 @@ export const MenuItem = React.memo(
item.func();
} else {
if (useNavigationStore.getState().currentRoute !== item.name) {
- Navigation.push(item.name, { canGoBack: false, beta: item.isBeta });
+ Navigation.navigate(item.name, {
+ canGoBack: false,
+ beta: item.isBeta
+ });
}
}
if (item.close) {
diff --git a/apps/mobile/app/services/notifications.ts b/apps/mobile/app/services/notifications.ts
index 122b7ad42..821300f77 100644
--- a/apps/mobile/app/services/notifications.ts
+++ b/apps/mobile/app/services/notifications.ts
@@ -364,17 +364,18 @@ async function scheduleNotification(
}
});
}
+
await notifee.createTriggerNotification(
{
id: trigger.id,
- title: title,
- body: description,
+ title: !title ? undefined : title,
+ body: !description ? undefined : description,
data: {
type: "reminder",
payload: payload || "",
dateModified: reminder.dateModified + ""
},
- subtitle: description,
+ subtitle: !description ? undefined : description,
android: {
channelId: await getChannelId(priority),
smallIcon: "ic_stat_name",
diff --git a/apps/mobile/native/webpack.config.js b/apps/mobile/native/webpack.config.js
index 651715522..49bd744fe 100644
--- a/apps/mobile/native/webpack.config.js
+++ b/apps/mobile/native/webpack.config.js
@@ -100,6 +100,7 @@ module.exports = (env) => {
"react-native-blob-util": path.join(__dirname, "../node_modules/react-native-blob-util"),
"@mdi/js": path.join(__dirname, "../node_modules/@mdi/js/mdi.js"),
"katex": path.join(__dirname, "../node_modules/katex"),
+ "tinycolor2": path.join(__dirname, "../node_modules/tinycolor2"),
},
},
/**