feat(anchor): bglost notification scroll to permissions + wip
This commit is contained in:
parent
c1b220f007
commit
fd081d46a6
7 changed files with 111 additions and 8 deletions
|
@ -0,0 +1,23 @@
|
||||||
|
import { navActions } from "~/stores";
|
||||||
|
import { createLogger } from "~/lib/logger";
|
||||||
|
import { BACKGROUND_SCOPES } from "~/lib/logger/scopes";
|
||||||
|
|
||||||
|
const backgroundGeolocationLogger = createLogger({
|
||||||
|
module: BACKGROUND_SCOPES.NOTIFICATIONS,
|
||||||
|
feature: "action-open-background-geolocation-settings",
|
||||||
|
});
|
||||||
|
|
||||||
|
export default function actionOpenBackgroundGeolocationSettings({ data }) {
|
||||||
|
backgroundGeolocationLogger.debug(
|
||||||
|
"actionOpenBackgroundGeolocationSettings called",
|
||||||
|
);
|
||||||
|
|
||||||
|
navActions.setNextNavigation([
|
||||||
|
{
|
||||||
|
name: "Params",
|
||||||
|
params: {
|
||||||
|
anchor: "permissions",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
|
@ -1,9 +1,26 @@
|
||||||
import { navActions } from "~/stores";
|
import { navActions } from "~/stores";
|
||||||
|
import { createLogger } from "~/lib/logger";
|
||||||
|
import { BACKGROUND_SCOPES } from "~/lib/logger/scopes";
|
||||||
|
|
||||||
|
const settingsLogger = createLogger({
|
||||||
|
module: BACKGROUND_SCOPES.NOTIFICATIONS,
|
||||||
|
feature: "action-open-settings",
|
||||||
|
});
|
||||||
|
|
||||||
export default function actionOpenSettings({ data }) {
|
export default function actionOpenSettings({ data }) {
|
||||||
|
settingsLogger.debug("actionOpenSettings called", {
|
||||||
|
data,
|
||||||
|
hasData: !!data,
|
||||||
|
dataKeys: data ? Object.keys(data) : [],
|
||||||
|
});
|
||||||
|
|
||||||
navActions.setNextNavigation([
|
navActions.setNextNavigation([
|
||||||
{
|
{
|
||||||
name: "Params",
|
name: "Params",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
settingsLogger.debug("Navigation set to Params screen", {
|
||||||
|
navigationTarget: "Params",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,18 @@ export default async function notifBackgroundGeolocationLost(data) {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// DEBUG: Log notification configuration for diagnosis
|
||||||
|
backgroundGeolocationLogger.info(
|
||||||
|
"DEBUG: Background geolocation notification config",
|
||||||
|
{
|
||||||
|
channelId,
|
||||||
|
pressActionId: "open-settings",
|
||||||
|
launchActivity: "default",
|
||||||
|
hasData: !!data,
|
||||||
|
dataKeys: data ? Object.keys(data) : [],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
// Generate notification content
|
// Generate notification content
|
||||||
const { title, body, bigText } =
|
const { title, body, bigText } =
|
||||||
generateBackgroundGeolocationLostContent(data);
|
generateBackgroundGeolocationLostContent(data);
|
||||||
|
@ -34,14 +46,14 @@ export default async function notifBackgroundGeolocationLost(data) {
|
||||||
bigText,
|
bigText,
|
||||||
android: {
|
android: {
|
||||||
pressAction: {
|
pressAction: {
|
||||||
id: "open-settings",
|
id: "open-background-geolocation-settings",
|
||||||
launchActivity: "default",
|
launchActivity: "default",
|
||||||
},
|
},
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
title: "Paramètres",
|
title: "Paramètres",
|
||||||
pressAction: {
|
pressAction: {
|
||||||
id: "open-settings",
|
id: "open-background-geolocation-settings",
|
||||||
launchActivity: "default",
|
launchActivity: "default",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -84,10 +84,13 @@ export const createNotificationHandlers = (handlers) => {
|
||||||
suggest_keep_open: async (data) => await openAlert({ data }),
|
suggest_keep_open: async (data) => await openAlert({ data }),
|
||||||
relative_invitation: async (data) => await openRelatives({ data }),
|
relative_invitation: async (data) => await openRelatives({ data }),
|
||||||
relative_allow_ask: async (data) => await openRelatives({ data }),
|
relative_allow_ask: async (data) => await openRelatives({ data }),
|
||||||
background_geolocation_lost: async (data) => {
|
background_geolocation_lost: async (_data) => {
|
||||||
navActions.setNextNavigation([
|
navActions.setNextNavigation([
|
||||||
{
|
{
|
||||||
name: "Params",
|
name: "Params",
|
||||||
|
params: {
|
||||||
|
anchor: "permissions",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,6 +15,7 @@ import actionRelativeAllowReject from "./actions/actionRelativeAllowReject";
|
||||||
import actionRelativeInvitationAccept from "./actions/actionRelativeInvitationAccept";
|
import actionRelativeInvitationAccept from "./actions/actionRelativeInvitationAccept";
|
||||||
import actionRelativeInvitationReject from "./actions/actionRelativeInvitationReject";
|
import actionRelativeInvitationReject from "./actions/actionRelativeInvitationReject";
|
||||||
import actionOpenSettings from "./actions/actionOpenSettings";
|
import actionOpenSettings from "./actions/actionOpenSettings";
|
||||||
|
import actionOpenBackgroundGeolocationSettings from "./actions/actionOpenBackgroundGeolocationSettings";
|
||||||
|
|
||||||
import { navActions } from "~/stores";
|
import { navActions } from "~/stores";
|
||||||
|
|
||||||
|
@ -97,11 +98,12 @@ export const onNotificationOpenedAppEvent = async (remoteMessage) => {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
try {
|
try {
|
||||||
eventLogger.info("Processing background notification tap", {
|
eventLogger.debug("Processing background notification tap", {
|
||||||
messageId: remoteMessage?.messageId,
|
messageId: remoteMessage?.messageId,
|
||||||
data: remoteMessage?.data,
|
data: remoteMessage?.data,
|
||||||
notification: remoteMessage?.notification,
|
notification: remoteMessage?.notification,
|
||||||
clickAction: remoteMessage?.notification?.android?.clickAction,
|
clickAction: remoteMessage?.notification?.android?.clickAction,
|
||||||
|
notificationType: remoteMessage?.data?.type || "unknown",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!remoteMessage?.notification) {
|
if (!remoteMessage?.notification) {
|
||||||
|
@ -275,8 +277,27 @@ export const onEvent = async ({ type, notification, pressAction }) => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "open-settings": {
|
case "open-settings": {
|
||||||
|
eventLogger.debug("Processing open-settings action", {
|
||||||
|
data,
|
||||||
|
actionId,
|
||||||
|
notificationId: notification?.id,
|
||||||
|
launchActivity: pressAction?.launchActivity,
|
||||||
|
});
|
||||||
await actionOpenSettings({ data });
|
await actionOpenSettings({ data });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "open-background-geolocation-settings": {
|
||||||
|
eventLogger.debug(
|
||||||
|
"Processing open-background-geolocation-settings action",
|
||||||
|
{
|
||||||
|
data,
|
||||||
|
actionId,
|
||||||
|
notificationId: notification?.id,
|
||||||
|
launchActivity: pressAction?.launchActivity,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
await actionOpenBackgroundGeolocationSettings({ data });
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -123,6 +123,11 @@ export default async function setActionCategories() {
|
||||||
title: "Paramètres",
|
title: "Paramètres",
|
||||||
foreground: true,
|
foreground: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "open-background-geolocation-settings",
|
||||||
|
title: "Paramètres",
|
||||||
|
foreground: true,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React from "react";
|
import React, { useCallback, useRef } from "react";
|
||||||
import { View, ScrollView } from "react-native";
|
import { View, ScrollView, InteractionManager } from "react-native";
|
||||||
import { createStyles } from "~/theme";
|
import { createStyles } from "~/theme";
|
||||||
import ParamsNotifications from "./Notifications";
|
import ParamsNotifications from "./Notifications";
|
||||||
import ParamsRadius from "./Radius";
|
import ParamsRadius from "./Radius";
|
||||||
|
@ -7,12 +7,34 @@ import ParamsEmergencyCall from "./EmergencyCall";
|
||||||
import ThemeSwitcher from "./ThemeSwitcher";
|
import ThemeSwitcher from "./ThemeSwitcher";
|
||||||
import Permissions from "./Permissions";
|
import Permissions from "./Permissions";
|
||||||
import SentryOptOut from "./SentryOptOut";
|
import SentryOptOut from "./SentryOptOut";
|
||||||
|
import { useRoute, useFocusEffect } from "@react-navigation/native";
|
||||||
|
|
||||||
export default function ParamsView({ data }) {
|
export default function ParamsView({ data }) {
|
||||||
const styles = useStyles();
|
const styles = useStyles();
|
||||||
|
|
||||||
|
const scrollRef = useRef(null);
|
||||||
|
const { params } = useRoute();
|
||||||
|
const didScroll = useRef(false);
|
||||||
|
|
||||||
|
const recordLayout = useCallback(
|
||||||
|
(key) =>
|
||||||
|
({
|
||||||
|
nativeEvent: {
|
||||||
|
layout: { y },
|
||||||
|
},
|
||||||
|
}) => {
|
||||||
|
if (didScroll.current || params?.anchor !== key) return;
|
||||||
|
|
||||||
|
InteractionManager.runAfterInteractions(() => {
|
||||||
|
scrollRef.current?.scrollTo({ y, animated: true });
|
||||||
|
didScroll.current = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[params?.anchor],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView style={styles.scrollView}>
|
<ScrollView ref={scrollRef} style={styles.scrollView}>
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
<ThemeSwitcher />
|
<ThemeSwitcher />
|
||||||
|
@ -29,7 +51,7 @@ export default function ParamsView({ data }) {
|
||||||
<View style={styles.section}>
|
<View style={styles.section}>
|
||||||
<SentryOptOut />
|
<SentryOptOut />
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.section}>
|
<View onLayout={recordLayout("permissions")} style={styles.section}>
|
||||||
<Permissions />
|
<Permissions />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
Loading…
Add table
Reference in a new issue