Skip to content

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

remove import()

Ammar Ahmedfe1592e97c1e
diff --git a/apps/mobile/src/components/ui/input/index.tsx b/apps/mobile/src/components/ui/input/index.tsx
index 11d978698..83257c61b 100644
--- a/apps/mobile/src/components/ui/input/index.tsx
+++ b/apps/mobile/src/components/ui/input/index.tsx
@@ -117,7 +117,7 @@ const Input = ({
break;
case 'phonenumber':
// eslint-disable-next-line no-case-declarations
- const phone = await (await import('phone')).default;
+ const phone = require('phone').default;
// eslint-disable-next-line no-case-declarations
let result = phone(value, {
strictDetection: true,
diff --git a/apps/mobile/src/utils/database/index.js b/apps/mobile/src/utils/database/index.js
index ce0be4425..9609558e0 100644
--- a/apps/mobile/src/utils/database/index.js
+++ b/apps/mobile/src/utils/database/index.js
@@ -3,44 +3,49 @@ import filesystem from '../filesystem';
import EventSource from '../sse/even-source-ios';
import AndroidEventSource from '../sse/event-source';
import Storage from './storage';
+import Database from 'notes-core/api/index';
/**
* @type {import("notes-core/api/index").default}
*/
-export var db;
+export var db = new Database(
+ Storage,
+ Platform.OS === 'ios' ? EventSource : AndroidEventSource,
+ filesystem
+);
+
+db.host(
+ __DEV__
+ ? {
+ API_HOST: 'https://api.notesnook.com',
+ AUTH_HOST: 'https://auth.streetwriters.co',
+ SSE_HOST: 'https://events.streetwriters.co',
+ SUBSCRIPTIONS_HOST: 'https://subscriptions.streetwriters.co',
+ ISSUES_HOST: 'https://issues.streetwriters.co'
+ // API_HOST: 'http://192.168.10.29:5264',
+ // AUTH_HOST: 'http://192.168.10.29:8264',
+ // SSE_HOST: 'http://192.168.10.29:7264',
+ // SUBSCRIPTIONS_HOST: 'http://192.168.10.29:9264',
+ // ISSUES_HOST: 'http://192.168.10.29:2624'
+ }
+ : {
+ API_HOST: 'https://api.notesnook.com',
+ AUTH_HOST: 'https://auth.streetwriters.co',
+ SSE_HOST: 'https://events.streetwriters.co',
+ SUBSCRIPTIONS_HOST: 'https://subscriptions.streetwriters.co',
+ ISSUES_HOST: 'https://issues.streetwriters.co'
+ }
+);
-let DB = null;
export async function loadDatabase() {
- if (!DB) {
- let module = await import(/* webpackChunkName: "notes-core" */ 'notes-core/api/index');
- DB = module.default;
- }
- db = new DB(Storage, Platform.OS === 'ios' ? EventSource : AndroidEventSource, filesystem);
- //@ts-ignore
- if (DOMParser) {
- //@ts-ignore
- await DOMParser.prepare();
- }
- db.host(
- __DEV__
- ? {
- API_HOST: 'https://api.notesnook.com',
- AUTH_HOST: 'https://auth.streetwriters.co',
- SSE_HOST: 'https://events.streetwriters.co',
- SUBSCRIPTIONS_HOST: 'https://subscriptions.streetwriters.co',
- ISSUES_HOST: 'https://issues.streetwriters.co'
- // API_HOST: 'http://192.168.10.29:5264',
- // AUTH_HOST: 'http://192.168.10.29:8264',
- // SSE_HOST: 'http://192.168.10.29:7264',
- // SUBSCRIPTIONS_HOST: 'http://192.168.10.29:9264',
- // ISSUES_HOST: 'http://192.168.10.29:2624'
- }
- : {
- API_HOST: 'https://api.notesnook.com',
- AUTH_HOST: 'https://auth.streetwriters.co',
- SSE_HOST: 'https://events.streetwriters.co',
- SUBSCRIPTIONS_HOST: 'https://subscriptions.streetwriters.co',
- ISSUES_HOST: 'https://issues.streetwriters.co'
- }
- );
+ // if (!DB) {
+ // let module = await import(/* webpackChunkName: "notes-core" */ 'notes-core/api/index');
+ // DB = module.default;
+ // }
+ // db = new DB(Storage, Platform.OS === 'ios' ? EventSource : AndroidEventSource, filesystem);
+ // //@ts-ignore
+ // if (DOMParser) {
+ // //@ts-ignore
+ // await DOMParser.prepare();
+ // }
}
diff --git a/apps/mobile/src/utils/index.js b/apps/mobile/src/utils/index.js
index dfac923a2..b14361442 100755
--- a/apps/mobile/src/utils/index.js
+++ b/apps/mobile/src/utils/index.js
@@ -126,7 +126,7 @@ export async function toTXT(note, notitle) {
} else {
text = await db.notes.note(note.id).content();
}
- htmlToText = htmlToText || (await import('html-to-text'));
+ htmlToText = htmlToText || require('html-to-text');
text = htmlToText.convert(text, {
selectors: [{ selector: 'img', format: 'skip' }]
});