Skip to content

Commit

Permalink
fix: Fixed bottom sheet not closing when going to play item
Browse files Browse the repository at this point in the history
  • Loading branch information
TriPSs committed Oct 7, 2020
1 parent 0b8dde5 commit d400282
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 45 deletions.
14 changes: 11 additions & 3 deletions app/mobile/components/ItemOptions/ItemOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export const ItemOptions = ({
animatable,
onClose,
onTorrentPress,
canOpenBottomSheet
canOpenBottomSheet,
}) => {
const [openBottomSheet, updateBottomSheet] = useBottomSheet()
const [openBottomSheet, updateBottomSheet, closeBottomSheet] = useBottomSheet()

const getBottomSheetConfig = () => {
// When allTorrents changes update the content heights
Expand Down Expand Up @@ -94,6 +94,14 @@ export const ItemOptions = ({

}, [visible])

const handleTorrentPress = !onTorrentPress
? undefined
: React.useCallback((torrent, download) => {
closeBottomSheet()

onTorrentPress(torrent, download)
}, [])

const renderBottomSheetContent = React.useCallback(() => {
return (
<View>
Expand All @@ -108,7 +116,7 @@ export const ItemOptions = ({
item={item}
variant={variant}
torrents={allTorrents}
onPress={onTorrentPress} />
onPress={handleTorrentPress} />

{variant === constants.TYPE_DOWNLOAD && (
<>
Expand Down
2 changes: 1 addition & 1 deletion app/mobile/screens/Home/ShowsSlider/ShowsSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const ShowsSlider = ({ handleGoTo, onPress }) => {
<CardSlider
onPress={onPress}
title={i18n.t('Shows')}
items={!data || !data.shows ? [] : data.shows.filter(show => !show.bookmarked)}
items={!data || !data.shows ? [] : data.shows.filter((show) => !show.bookmarked)}
goToMore={handleGoTo('Shows')}
loading={loading}
onEndReached={fetchMoreUpdateQuery('shows', data, fetchMore)}
Expand Down
11 changes: 7 additions & 4 deletions app/modules/BottomSheetManager/BottomSheetProvider.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import { StyleSheet, View } from 'react-native'
import BottomSheet from 'reanimated-bottom-sheet'
import ReAnimated from 'react-native-reanimated'
Expand Down Expand Up @@ -56,7 +55,7 @@ export const BottomSheetProvider = ({ children }) => {

useBackButton(() => {
if (visible && sheetRef.current) {
sheetRef.current.snapTo(bottomSheetConfig.snapPoints.length - 1)
closeBottomSheet()

return true
}
Expand Down Expand Up @@ -88,8 +87,12 @@ export const BottomSheetProvider = ({ children }) => {
}
}

const closeBottomSheet = () => {
sheetRef.current.snapTo(bottomSheetConfig.snapPoints.length - 1)
}

return (
<BottomSheetContext.Provider value={[openBottomSheet, updateBottomSheet]}>
<BottomSheetContext.Provider value={[openBottomSheet, updateBottomSheet, closeBottomSheet]}>

{children}

Expand Down Expand Up @@ -124,7 +127,7 @@ export const BottomSheetProvider = ({ children }) => {
style={{
height: bottomSheetConfig.biggestSnapPoint,
}}>
{bottomSheetConfig.renderContent()}
{visible && bottomSheetConfig.renderContent()}
</Container>
)}
/>
Expand Down
6 changes: 3 additions & 3 deletions app/modules/GraphQL/Apollo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CachePersistor } from 'apollo-cache-persist'
import { WebSocketLink } from '@apollo/client/link/ws'
import { getMainDefinition } from '@apollo/client/utilities'

const SCHEMA_VERSION = '7' // Must be a string.
const SCHEMA_VERSION = '9' // Must be a string.
const SCHEMA_VERSION_KEY = 'apollo-schema-version'

export default async(host) => {
Expand Down Expand Up @@ -44,8 +44,8 @@ export default async(host) => {
const definition = getMainDefinition(query)

return (
definition.kind === 'OperationDefinition' &&
definition.operation === 'subscription'
definition.kind === 'OperationDefinition'
&& definition.operation === 'subscription'
)
},
new WebSocketLink({
Expand Down
1 change: 0 additions & 1 deletion app/modules/GraphQL/ShowsGraphQL.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const MostWatchedShowsQuery = gql`
${showMinimalFragment}
`


export default gql`
query shows($offset: Float!, $query: String) {
shows(limit: 25, offset: $offset, query: $query) {
Expand Down
1 change: 1 addition & 0 deletions app/modules/GraphQL/fragments/movieFragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const movieMinimalFragment = gql`
_id
title
type
bookmarked
watched {
complete
progress
Expand Down
3 changes: 1 addition & 2 deletions app/modules/GraphQL/helpers/fetchMoreUpdateQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let fetchingMore = false
export default (type, data, fetchMore) => () => {
// Make sure we are only fetching more once
if (fetchingMore || !data) {
return
return null
}

fetchingMore = true
Expand All @@ -33,4 +33,3 @@ export default (type, data, fetchMore) => () => {
},
})
}

3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ enableScreens()

LogBox.ignoreLogs([
'Debugger and device times',
'Cache data may be lost when replacing'
'Cache data may be lost when replacing',
'The updateQuery callback for fetchMore is deprecated'
])

import App from './app/index'
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
},
"dependencies": {
"@apollo/client": "^3.2.2",
"@react-native-community/async-storage": "1.12.0",
"@react-native-community/async-storage": "1.12.1",
"@react-native-community/masked-view": "^0.1.10",
"@react-native-community/netinfo": "5.9.7",
"@react-native-community/slider": "3.0.3",
"@react-navigation/native": "5.7.5",
"@react-navigation/stack": "5.9.2",
"@react-navigation/native": "5.7.6",
"@react-navigation/stack": "5.9.3",
"apollo-cache-persist": "^0.1.1",
"graphql": "15.3.0",
"graphql-tag": "2.11.0",
Expand All @@ -44,7 +44,7 @@
"react": "16.13.1",
"react-native": "0.63.3",
"react-native-animatable": "1.3.3",
"react-native-device-info": "6.0.4",
"react-native-device-info": "6.2.0",
"react-native-fs": "2.16.6",
"react-native-gesture-handler": "1.8.0",
"react-native-google-cast": "github:pct-org/react-native-google-cast#7e409ca7c129d628d5c2902944790bc611b64aaa",
Expand Down
52 changes: 26 additions & 26 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1413,10 +1413,10 @@
"@nodelib/fs.scandir" "2.1.3"
fastq "^1.6.0"

"@react-native-community/async-storage@1.12.0":
version "1.12.0"
resolved "https://registry.yarnpkg.com/@react-native-community/async-storage/-/async-storage-1.12.0.tgz#d2fc65bc08aa1c3e9514bbe9fe7095eab8e8aca3"
integrity sha512-y3zVxuVyiOxI8TXrvajmYfDbIt2vFNxzV5MiA28v15DQTxDk6uJH3rpc9my+la7u2Tiwt3PpdU2+59ZgZ4h7wA==
"@react-native-community/async-storage@1.12.1":
version "1.12.1"
resolved "https://registry.yarnpkg.com/@react-native-community/async-storage/-/async-storage-1.12.1.tgz#25f821b4f6b13abe005ad67e47c6f1cee9f27b24"
integrity sha512-70WGaH3PKYASi4BThuEEKMkyAgE9k7VytBqmgPRx3MzJx9/MkspwqJGmn3QLCgHLIFUgF1pit2mWICbRJ3T3lg==
dependencies:
deep-assign "^3.0.0"

Expand Down Expand Up @@ -1554,24 +1554,24 @@
resolved "https://registry.yarnpkg.com/@react-native-community/slider/-/slider-3.0.3.tgz#830167fd757ba70ac638747ba3169b2dbae60330"
integrity sha512-8IeHfDwJ9/CTUwFs6x90VlobV3BfuPgNLjTgC6dRZovfCWigaZwVNIFFJnHBakK3pW2xErAPwhdvNR4JeNoYbw==

"@react-navigation/core@^5.12.4":
version "5.12.4"
resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-5.12.4.tgz#1bd0c81d098895c8ffe49f8624fae60c9abc5684"
integrity sha512-vhaVIJGfSgln4dIoO4R2HeX9p3Vc7OJLa0/JpKHpXn/DZgNVn+RP7ktk1CRZ16ikUJ0k8CxzuvRxeRIg7EhA7w==
"@react-navigation/core@^5.12.5":
version "5.12.5"
resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-5.12.5.tgz#434a34893368de1c9daca9508fdd7be94d1ec642"
integrity sha512-+QdQDtC75K1sBfACwCUNFlrCOYf36GYGr9YURHugm3LDEHUwAj7HPJA8FFLw1Rmp5N/P5q9Uct2B/XxJhYzKqA==
dependencies:
"@react-navigation/routers" "^5.4.12"
escape-string-regexp "^4.0.0"
nanoid "^3.1.12"
query-string "^6.13.1"
query-string "^6.13.5"
react-is "^16.13.0"
use-subscription "^1.4.0"

"@react-navigation/native@5.7.5":
version "5.7.5"
resolved "https://registry.yarnpkg.com/@react-navigation/native/-/native-5.7.5.tgz#478579435549a1c5c9901c9c6b3c1f75fa7dbf0c"
integrity sha512-HZpfxXF740XsA0HkeohGETo/zOmlMFb65XElQOk9+dPoN+36y2olZC/f7HuqpucsU925zg7jrnyUnW6tCtc3IA==
"@react-navigation/native@5.7.6":
version "5.7.6"
resolved "https://registry.yarnpkg.com/@react-navigation/native/-/native-5.7.6.tgz#47546c512488d0e9c343219af635e1a44881761d"
integrity sha512-u+o9Ifs4//Ah6UczXiaAV+hiWPL0NyTbErj5WayeQUd6K5IIbA1UwumRVWs2Xp8q/4Q9h6FpPHUcKOyiTxhaqA==
dependencies:
"@react-navigation/core" "^5.12.4"
"@react-navigation/core" "^5.12.5"
nanoid "^3.1.12"

"@react-navigation/routers@^5.4.12":
Expand All @@ -1581,10 +1581,10 @@
dependencies:
nanoid "^3.1.12"

"@react-navigation/stack@5.9.2":
version "5.9.2"
resolved "https://registry.yarnpkg.com/@react-navigation/stack/-/stack-5.9.2.tgz#68841c9ef032177d15664b14cff62e16698f89c7"
integrity sha512-imEvTuCNsIo3ZriN6eIreGaxypuuB9ZOqdUXfxJznzMCkb7lN4OR/YVztAJW3QQzhuD4vwly+7jDvt7SxyfSuw==
"@react-navigation/stack@5.9.3":
version "5.9.3"
resolved "https://registry.yarnpkg.com/@react-navigation/stack/-/stack-5.9.3.tgz#c12cbd7cc8436e3995aa291d7617c5b8f7a950ea"
integrity sha512-/CJ5Rsrc9bMI20dD8oC/QSZHARMFuUv8DeoiYE7R2N0M44cFupF1CrzaZBBC/S4Zi1ahZ0A+Hj/gAzAEQrNTvA==
dependencies:
color "^3.1.2"
react-native-iphone-x-helper "^1.2.1"
Expand Down Expand Up @@ -7476,10 +7476,10 @@ qs@~6.5.2:
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==

query-string@^6.13.1:
version "6.13.1"
resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.13.1.tgz#d913ccfce3b4b3a713989fe6d39466d92e71ccad"
integrity sha512-RfoButmcK+yCta1+FuU8REvisx1oEzhMKwhLUNcepQTPGcNMp1sIqjnfCtfnvGSQZQEhaBHvccujtWoUV3TTbA==
query-string@^6.13.5:
version "6.13.5"
resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.13.5.tgz#99e95e2fb7021db90a6f373f990c0c814b3812d8"
integrity sha512-svk3xg9qHR39P3JlHuD7g3nRnyay5mHbrPctEBDUxUkHRifPHXJDhBUycdCC0NBjXoDf44Gb+IsOZL1Uwn8M/Q==
dependencies:
decode-uri-component "^0.2.0"
split-on-first "^1.0.0"
Expand Down Expand Up @@ -7545,10 +7545,10 @@ react-native-animatable@1.3.3:
dependencies:
prop-types "^15.7.2"

react-native-device-info@6.0.4:
version "6.0.4"
resolved "https://registry.yarnpkg.com/react-native-device-info/-/react-native-device-info-6.0.4.tgz#88ef9f19715186d0b016b37e738d08b990fcf9e3"
integrity sha512-nLwQ2yPmR0Z/msVP7vD0dZe1qzBMpzYpyY5q4/t31pPHT08bu0D5MYVr0K+MnPZMISu1UOUZpVARvfVMLZBMJg==
react-native-device-info@6.2.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/react-native-device-info/-/react-native-device-info-6.2.0.tgz#6eda29dee048b73b29b57b7ec0c21545bd89dada"
integrity sha512-UtAk/ZAdCVCepEmRNM/3Kx7dWbLwmEPh527HTjoQUQy1utpoXm3y4sYtCrP2tjczSIyeMs5nLP4Wf3c8bc0fwQ==

react-native-fit-image@^1.5.2:
version "1.5.5"
Expand Down

0 comments on commit d400282

Please sign in to comment.