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

Feature/geolocation permission #128

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { calculateEnrollmentStatus, EnrollmentStatus } from '@involvemint/shared
import { parseDate } from '@involvemint/shared/util';
import { formatDistanceToNow } from 'date-fns';
import { tap } from 'rxjs/operators';
import { StatusService } from '@involvemint/client/shared/util';

interface State {
projects: ProjectFeedStoreModel[];
Expand All @@ -28,12 +29,13 @@ export class BrowseProjectsComponent extends StatefulComponent<State> implements
constructor(
private readonly user: UserFacade,
private readonly route: RouteService,
private readonly viewProfile: ImViewProfileModalService
private readonly viewProfile: ImViewProfileModalService,
private readonly status: StatusService,
) {
super({ projects: [], loaded: false });
}

ngOnInit() {
async ngOnInit() {
this.effect(() =>
this.user.projects.selectors.projects$.pipe(
tap(({ projects, loaded }) =>
Expand All @@ -46,6 +48,31 @@ export class BrowseProjectsComponent extends StatefulComponent<State> implements
)
)
);

try { // only show permissions modal if supported and not granted
const permissionStatus = await navigator.permissions.query({ name: 'geolocation' });
if ('permissions' in navigator && permissionStatus.state != 'granted') {
if ( permissionStatus.state == 'prompt') {
this.status.presentAlertWithAction({
alertData: {
title: 'Enable Location Services',
description: 'Please enable location services on your device to enjoy the full features of our app. Your privacy is important to us, and we assure you that we use location data responsibly to improve your app experience.'
},
buttonText: 'Enable',
cancelButtonText: 'Remind me Later',
buttonCssClass: 'im-alert-confirm',
})
.then((res) => { if (res) navigator.geolocation.getCurrentPosition(() => {}) });
}

else if ( permissionStatus.state == 'denied') {
this.status.presentAlert({
title: 'Disabled Location Services',
description: "You have prevented involveMINT from accessing location services on this device. Some of our features will not be fully functional. To enable location services, please go to your device settings and allow our app to access your location. If you need any assistance, feel free to reach out to our support team at <a>[email protected]</a>."
});
}
}
} catch (error) { console.error('Error checking location permission:', error); }
}

refresh() {
Expand Down
3 changes: 2 additions & 1 deletion libs/client/shell/src/lib/projects/projects.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import { ProjectCoverPageComponent } from './project-cover-page/project-cover-pa
ImCardModule,
ImLoadingRouteDirectiveModule,
ImViewProfileModalModule,
],

]
})
export class BrowseProjectsModule {}

Expand Down
68 changes: 0 additions & 68 deletions libs/shared/domain/src/lib/environments/environment.ts

This file was deleted.

2 changes: 1 addition & 1 deletion libs/shared/domain/src/lib/environments/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './environment';
export * from './environment.org';