From 8c01f67b5d7a08d780a2aa2a980a4f09a037f38a Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Wed, 19 Oct 2022 14:17:20 -0700 Subject: [PATCH] prevent sleep while in topic --- app/mobile/package.json | 1 + app/mobile/src/session/conversation/Conversation.jsx | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/app/mobile/package.json b/app/mobile/package.json index aa768ecf..b52aacc6 100644 --- a/app/mobile/package.json +++ b/app/mobile/package.json @@ -18,6 +18,7 @@ "axios": "^1.1.0", "expo": "~46.0.9", "expo-av": "^12.0.4", + "expo-keep-awake": "~10.2.0", "expo-splash-screen": "~0.16.2", "expo-status-bar": "~1.4.0", "moment": "^2.29.4", diff --git a/app/mobile/src/session/conversation/Conversation.jsx b/app/mobile/src/session/conversation/Conversation.jsx index fbb630d8..c149b172 100644 --- a/app/mobile/src/session/conversation/Conversation.jsx +++ b/app/mobile/src/session/conversation/Conversation.jsx @@ -1,4 +1,5 @@ import { KeyboardAvoidingView, Modal, Platform, TextInput, View, TouchableOpacity, Text, } from 'react-native'; +import { activateKeepAwake, deactivateKeepAwake } from 'expo-keep-awake'; import { FlatList, ScrollView } from '@stream-io/flat-list-mvcp'; import { memo, useState, useRef, useEffect } from 'react'; import { useConversation } from './useConversation.hook'; @@ -38,6 +39,11 @@ export function ConversationBody() { const ref = useRef(); + useEffect(() => { + activateKeepAwake(); + return () => { deactivateKeepAwake() }; + }, []); + const latch = () => { if (!state.momentum) { actions.latch();