This commit is contained in:
Eric van der Vlist 2022-10-04 11:18:22 +02:00
parent 2376d4daba
commit 330b4bb721
8 changed files with 13 additions and 15 deletions

View File

@ -39,7 +39,7 @@ const GpxExport: React.FC<{ gpx: any }> = (props: { gpx: any }) => {
const filenameToTest = const filenameToTest =
i === 0 ? `${filename}.${extension}` : `${filename}(${i}).${extension}`; i === 0 ? `${filename}.${extension}` : `${filename}(${i}).${extension}`;
try { try {
const statResult = await Filesystem.stat({ await Filesystem.stat({
path: filenameToTest, path: filenameToTest,
directory: Directory.Documents, directory: Directory.Documents,
}); });

View File

@ -1,4 +1,4 @@
import React, { Fragment, useEffect, useRef, useState } from 'react'; import React, { Fragment, useRef, useState } from 'react';
import { useDB, useFind } from 'react-pouchdb'; import { useDB, useFind } from 'react-pouchdb';

View File

@ -1,4 +1,4 @@
import React, { Fragment, useEffect, useRef, useState } from 'react'; import React, { Fragment, useEffect, useRef } from 'react';
import { useDB } from 'react-pouchdb'; import { useDB } from 'react-pouchdb';
@ -16,7 +16,7 @@ import {
IonTitle, IonTitle,
IonToolbar, IonToolbar,
} from '@ionic/react'; } from '@ionic/react';
import { options, text } from 'ionicons/icons'; import { options } from 'ionicons/icons';
import { enterAnimation, leaveAnimation } from '../../lib/animation'; import { enterAnimation, leaveAnimation } from '../../lib/animation';
import { useDispatch, useSelector } from 'react-redux'; import { useDispatch, useSelector } from 'react-redux';
import { settingsActions, SettingsState } from '../../store/settings'; import { settingsActions, SettingsState } from '../../store/settings';
@ -38,7 +38,7 @@ const Settings: React.FC<{}> = () => {
} catch {} } catch {}
}; };
initFromDb(); initFromDb();
}, []); }, [db, dispatch]);
const settingsState = useSelector( const settingsState = useSelector(
(state: { settings: SettingsState }) => state.settings (state: { settings: SettingsState }) => state.settings
@ -65,7 +65,7 @@ const Settings: React.FC<{}> = () => {
}; };
settingsFromRedux(); settingsFromRedux();
} }
}, [settingsState]); }, [db, settingsState]);
const pseudo = useRef<HTMLIonInputElement>(null); const pseudo = useRef<HTMLIonInputElement>(null);
const minTimeInterval = useRef<HTMLIonInputElement>(null); const minTimeInterval = useRef<HTMLIonInputElement>(null);

View File

@ -10,12 +10,11 @@ import {
IonItem, IonItem,
IonList, IonList,
IonModal, IonModal,
IonSpinner,
IonTitle, IonTitle,
IonToolbar, IonToolbar,
} from '@ionic/react'; } from '@ionic/react';
import { trash } from 'ionicons/icons'; import { trash } from 'ionicons/icons';
import React, { Fragment, Suspense, useRef } from 'react'; import React, { Fragment, useRef } from 'react';
import { useFind, useDB } from 'react-pouchdb'; import { useFind, useDB } from 'react-pouchdb';
import { deleteGps } from '../../db/gpx'; import { deleteGps } from '../../db/gpx';
import { enterAnimation, leaveAnimation } from '../../lib/animation'; import { enterAnimation, leaveAnimation } from '../../lib/animation';

View File

@ -1,4 +1,4 @@
import React, { Suspense } from 'react'; import React from 'react';
import { useFind } from 'react-pouchdb'; import { useFind } from 'react-pouchdb';

View File

@ -27,7 +27,7 @@ import TileServerChooserDialog from './TileServerChooserDialog';
import TrackBrowser from './TracksBrowser'; import TrackBrowser from './TracksBrowser';
import Settings from './Settings'; import Settings from './Settings';
const Map: react.FC<{}> = (props: {}) => { const Map: react.FC<{}> = () => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const resizeHandler = () => { const resizeHandler = () => {

View File

@ -49,13 +49,11 @@ export const pushGpx = async (db: any, payload: any) => {
for (var point in points) { for (var point in points) {
const docPoint = { type: 'trkpt', gpx: _id, trkpt: points[point] }; const docPoint = { type: 'trkpt', gpx: _id, trkpt: points[point] };
console.log(JSON.stringify(docPoint)); console.log(JSON.stringify(docPoint));
const response = await db.post(docPoint); await db.post(docPoint);
console.log(JSON.stringify(docPoint)); console.log(JSON.stringify(docPoint));
} }
}; };
const CURRENT_GPX = '---current gpx---';
const initialGpx = { const initialGpx = {
type: 'gpx', type: 'gpx',
subtype: 'current', subtype: 'current',
@ -187,6 +185,7 @@ export const getGpx = async (db: any, gpxId: string) => {
); );
trkpts.map((trkptDoc: any) => { trkpts.map((trkptDoc: any) => {
gpx.trk[0].trkseg[0].trkpt.push(trkptDoc.trkpt); gpx.trk[0].trkseg[0].trkpt.push(trkptDoc.trkpt);
return undefined;
}); });
return gpx; return gpx;
}; };

View File

@ -1,4 +1,4 @@
import _, { constant } from 'lodash'; import _ from 'lodash';
import uri from '../lib/ids'; import uri from '../lib/ids';
const dbDefinitionId = uri('dbdef', {}); const dbDefinitionId = uri('dbdef', {});
@ -74,7 +74,7 @@ export const initDb = async (db: any, setDbReady: any) => {
} }
} }
for (var index of requiredIndexes) { for (index of requiredIndexes) {
if (!findIndex(existingIndexes, index)) { if (!findIndex(existingIndexes, index)) {
// console.log(`db.createIndex(${JSON.stringify(index)})`); // console.log(`db.createIndex(${JSON.stringify(index)})`);
await db.createIndex({ name: index.name, ...index.def }); await db.createIndex({ name: index.name, ...index.def });