39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import React from 'react';
|
|
import { StyleSheet, View } from 'react-native';
|
|
|
|
import { sessionManager } from '../../services/security/sessionManager';
|
|
|
|
interface ActivityTrackerProps {
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
/**
|
|
* Records that the user is still there, app-wide.
|
|
*
|
|
* Needed because the server's idle window only resets on an authenticated call,
|
|
* and most of this app reads from fixtures — someone can browse the dashboard
|
|
* for five minutes without one, and be signed out while actively using it.
|
|
*
|
|
* `onStartShouldSetResponderCapture` sees every touch on the way down and
|
|
* returning false declines to become the responder, so it never swallows a tap,
|
|
* a scroll or a gesture. A wrapper that actually captured touches would break
|
|
* every pressable beneath it.
|
|
*/
|
|
export const ActivityTracker = ({ children }: ActivityTrackerProps) => (
|
|
<View
|
|
style={styles.fill}
|
|
onStartShouldSetResponderCapture={() => {
|
|
sessionManager.noteInteraction();
|
|
return false;
|
|
}}
|
|
>
|
|
{children}
|
|
</View>
|
|
);
|
|
|
|
const styles = StyleSheet.create({
|
|
fill: {
|
|
flex: 1,
|
|
},
|
|
});
|