Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geolocation and position packages #37

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

suenot
Copy link
Member

@suenot suenot commented Jan 22, 2023

No description provided.

@FreePhoenix888 FreePhoenix888 self-requested a review January 22, 2023 14:32
@FreePhoenix888 FreePhoenix888 added the help wanted Extra attention is needed label Jan 22, 2023
@FreePhoenix888 FreePhoenix888 linked an issue Jan 22, 2023 that may be closed by this pull request
3 tasks
in: { data: {
type_id: containTypeLinkId,
from_id: packageLinkId,
string: { data: { value: 'earth' } },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Earth

@@ -0,0 +1,15 @@
import { Geolocation } from '@capacitor/geolocation';

export const checkPermissions = async ({callback}: {callback?: ({newPermissionStatus}: {newPermissionStatus: any}) => any}) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are not you able to add type to newPermissionStatus from capacitor?

export const clearWatch = async ({watchId, callback}: { watchId: string, callback?: ({ result, error }: { result?: string, error?: any }) => void} ) => {
try {
await Geolocation.clearWatch({id: watchId});
callback && callback({result: 'success'});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callback?.()

callback && callback({result: 'success'});
} catch (error) {
console.error(error);
callback && callback({error})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callback?.()

export const getCurrentPosition = async ({callback}: {callback?: ({coordinates: Position}) => void}) => {
try {
const coordinates: Position = await Geolocation.getCurrentPosition();
callback && callback({coordinates});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callback?.()

return coordinates;
} catch (error) {
console.log(error);
callback && callback({coordinates: null});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callback?.()

const newWatchId = await Geolocation.watchPosition(options, (newPosition, error) => {
if (error) {
console.error(error);
callback && callback({error});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callback?.()

callback && callback({error});
return {error};
}
callback && callback({newPosition});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callback?.()

}
callback && callback({newPosition});
});
callback && callback({newWatchId});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callback?.()

return {newWatchId};
} catch (error) {
console.error(error);
callback && callback({error});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

callback?.()

@suenot
Copy link
Member Author

suenot commented Jan 28, 2023

Fixed

},
] },
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (coordinates?.x) {
const {
data: [{ id: xLinkId }],
} = await deep.insert({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduce amount of deep network requests

This comment applies to all the places working like these lines of code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Save geolocation by using https://capacitorjs.com/docs/apis/geolocation
2 participants