diff --git a/package.json b/package.json index 43424aa..ffc753b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "tidgi-mobile", "main": "node_modules/expo/AppEntry.js", "scripts": { - "android": "expo start --go --android", + "android": "cross-env NODE_ENV=development expo start --go --android", "build:plugin": "zx scripts/buildPlugins.mjs", "build:android-apk": "eas build --profile preview --platform android --non-interactive", "build:expo-sdk": "eas build --profile development --platform android --non-interactive", @@ -72,6 +72,7 @@ "@types/react": "~18.2.21", "babel-plugin-import": "^1.13.8", "babel-plugin-transform-typescript-metadata": "^0.3.2", + "cross-env": "^7.0.3", "eslint-config-tidgi": "^1.1.5", "eslint-plugin-react-native": "^4.0.0", "react-native-reanimated": "3.3.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cee7855..e17614d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -181,6 +181,9 @@ devDependencies: babel-plugin-transform-typescript-metadata: specifier: ^0.3.2 version: 0.3.2(@babel/core@7.22.11) + cross-env: + specifier: ^7.0.3 + version: 7.0.3 eslint-config-tidgi: specifier: ^1.1.5 version: 1.1.5(typescript@5.2.2) @@ -3953,6 +3956,14 @@ packages: js-yaml: 3.14.1 parse-json: 4.0.0 + /cross-env@7.0.3: + resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==} + engines: {node: '>=10.14', npm: '>=6', yarn: '>=1'} + hasBin: true + dependencies: + cross-spawn: 7.0.3 + dev: true + /cross-fetch@3.1.8: resolution: {integrity: sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==} dependencies: diff --git a/src/pages/MainMenu/EditItemModel/WikiChangesModelContent.tsx b/src/pages/MainMenu/EditItemModel/WikiChangesModelContent.tsx index 5cc9929..b53852c 100644 --- a/src/pages/MainMenu/EditItemModel/WikiChangesModelContent.tsx +++ b/src/pages/MainMenu/EditItemModel/WikiChangesModelContent.tsx @@ -15,7 +15,9 @@ interface WikiEditModalProps { export function WikiChangesModelContent({ id, onClose }: WikiEditModalProps): JSX.Element { const { t } = useTranslation(); - const wiki = useWorkspaceStore(state => id === undefined ? undefined : state.workspaces.find((w): w is IWikiWorkspace => w.id === id && w.type === 'wiki')); + const wiki = useWorkspaceStore(state => + id === undefined ? undefined : state.workspaces.find((w): w is IWikiWorkspace => w.id === id && (w.type === undefined || w.type === 'wiki')) + ); const availableServersToPick = useServerStore(state => Object.entries(state.servers).filter(([id]) => wiki?.syncedServers?.map(item => item.serverID)?.includes?.(id)).map(([id, server]) => { const lastSync = wiki?.syncedServers?.find(item => item.serverID === id)?.lastSync; diff --git a/src/pages/MainMenu/EditItemModel/WikiModelContent.tsx b/src/pages/MainMenu/EditItemModel/WikiModelContent.tsx index 8849add..198759b 100644 --- a/src/pages/MainMenu/EditItemModel/WikiModelContent.tsx +++ b/src/pages/MainMenu/EditItemModel/WikiModelContent.tsx @@ -25,7 +25,9 @@ interface WikiEditModalProps { export function WikiEditModalContent({ id, onClose }: WikiEditModalProps): JSX.Element { const { t } = useTranslation(); - const wiki = useWorkspaceStore(state => id === undefined ? undefined : state.workspaces.find((w): w is IWikiWorkspace => w.id === id && w.type === 'wiki')); + const wiki = useWorkspaceStore(state => + id === undefined ? undefined : state.workspaces.find((w): w is IWikiWorkspace => w.id === id && (w.type === undefined || w.type === 'wiki')) + ); const [updateWiki, addServerToWiki, deleteWiki, setServerActive] = useWorkspaceStore(state => [state.update, state.addServer, state.remove, state.setServerActive]); const availableServersToPick = useServerStore(state => Object.entries(state.servers).map(([id, server]) => ({ id, label: `${server.name} (${server.uri})` }))); diff --git a/src/pages/MainMenu/EditItemModel/index.tsx b/src/pages/MainMenu/EditItemModel/index.tsx index 83b78f8..32ab560 100644 --- a/src/pages/MainMenu/EditItemModel/index.tsx +++ b/src/pages/MainMenu/EditItemModel/index.tsx @@ -8,6 +8,7 @@ export function EditItemModel({ id, onClose }: { id?: string; onClose: () => voi const workspace = useWorkspaceStore(state => id === undefined ? undefined : state.workspaces.find((w) => w.id === id)); switch (workspace?.type) { + case undefined: case 'wiki': { return ; } diff --git a/src/pages/WikiWebView/WebPageViewer.tsx b/src/pages/WikiWebView/WebPageViewer.tsx index a067ffc..ebdf2aa 100644 --- a/src/pages/WikiWebView/WebPageViewer.tsx +++ b/src/pages/WikiWebView/WebPageViewer.tsx @@ -44,12 +44,8 @@ export const WebPageViewer = ({ webPageWorkspace }: WikiViewerProps) => { originWhitelist={['*']} mediaPlaybackRequiresUserAction={false} allowsInlineMediaPlayback - javaScriptCanOpenWindowsAutomatically allowsBackForwardNavigationGestures allowsProtectedMedia - allowFileAccess - allowFileAccessFromFileURLs - allowUniversalAccessFromFileURLs focusable geolocationEnabled importantForAccessibility='yes' @@ -58,6 +54,8 @@ export const WebPageViewer = ({ webPageWorkspace }: WikiViewerProps) => { mixedContentMode='always' allowsAirPlayForMediaPlayback allowsFullscreenVideo + cacheEnabled={false} + cacheMode='LOAD_NO_CACHE' userAgent={FAKE_USER_AGENT} source={{ uri: webPageWorkspace.uri }} renderError={(errorName) => {errorName}} diff --git a/src/pages/WikiWebView/index.tsx b/src/pages/WikiWebView/index.tsx index 591516a..0aa866f 100644 --- a/src/pages/WikiWebView/index.tsx +++ b/src/pages/WikiWebView/index.tsx @@ -25,6 +25,7 @@ export const WikiWebView: React.FC diff --git a/src/services/NativeService/hooks.ts b/src/services/NativeService/hooks.ts index 84d686a..d186605 100644 --- a/src/services/NativeService/hooks.ts +++ b/src/services/NativeService/hooks.ts @@ -20,6 +20,9 @@ export function useRequestNativePermissions() { export function useRegisterReceivingShareIntent() { useEffect(() => { try { + if (process.env.NODE_ENV === 'development') { + return; + } nativeService.registerReceivingShareIntent(); } catch (error) { console.log( diff --git a/src/services/SQLiteService/hooks.ts b/src/services/SQLiteService/hooks.ts index 14cf7c0..4f5fd16 100644 --- a/src/services/SQLiteService/hooks.ts +++ b/src/services/SQLiteService/hooks.ts @@ -10,8 +10,8 @@ export function useCloseSQLite(workspace?: IWorkspace) { void (async () => { try { if (databaseToCloseReference.current === undefined) return; - console.log(`Closing sqlite database for ${databaseToCloseReference.current.id} in useSQLiteService`); if (databaseToCloseReference.current?.type === 'wiki') { + console.log(`Closing sqlite database for ${databaseToCloseReference.current.id} in useSQLiteService`); // eslint-disable-next-line react-hooks/exhaustive-deps await sqliteServiceService.closeDatabase(databaseToCloseReference.current); }