Merge pull request #84 from tooot-app/main

Nightly 210323
This commit is contained in:
xmflsct 2021-03-24 00:10:28 +01:00 committed by GitHub
commit 98a24ce1d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 81 additions and 54 deletions

View File

@ -119,6 +119,8 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
routeRef.current = { routeRef.current = {
name: currentRoute?.name, name: currentRoute?.name,
params: currentRoute?.params params: currentRoute?.params
? JSON.stringify(currentRoute.params)
: undefined
} }
}, []) }, [])
const navigationContainerOnStateChange = useCallback(() => { const navigationContainerOnStateChange = useCallback(() => {
@ -144,7 +146,10 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
return ( return (
<> <>
<StatusBar barStyle={barStyle[mode]} backgroundColor={theme.backgroundDefault} /> <StatusBar
barStyle={barStyle[mode]}
backgroundColor={theme.backgroundDefault}
/>
<NavigationContainer <NavigationContainer
ref={navigationRef} ref={navigationRef}
theme={themes[mode]} theme={themes[mode]}

View File

@ -86,7 +86,7 @@ const HeaderRight: React.FC<Props> = ({
: undefined, : undefined,
minHeight: 44, minHeight: 44,
minWidth: 44, minWidth: 44,
marginLeft: native marginRight: native
? -StyleConstants.Spacing.S ? -StyleConstants.Spacing.S
: StyleConstants.Spacing.S, : StyleConstants.Spacing.S,
...(type === 'icon' && { ...(type === 'icon' && {

View File

@ -95,35 +95,37 @@ const AttachmentAudio: React.FC<Props> = ({
</> </>
)} )}
</View> </View>
<View {audio.meta.original.duration ? (
style={{ <View
alignSelf: 'flex-end', style={{
width: '100%', alignSelf: 'flex-end',
height: StyleConstants.Spacing.M + StyleConstants.Spacing.S * 2, width: '100%',
backgroundColor: theme.backgroundOverlayInvert, height: StyleConstants.Spacing.M + StyleConstants.Spacing.S * 2,
paddingHorizontal: StyleConstants.Spacing.Global.PagePadding, backgroundColor: theme.backgroundOverlayInvert,
borderRadius: 100, paddingHorizontal: StyleConstants.Spacing.Global.PagePadding,
opacity: sensitiveShown ? 0.35 : undefined borderRadius: 100,
}} opacity: sensitiveShown ? 0.35 : undefined
> }}
<Slider >
minimumValue={0} <Slider
maximumValue={audio.meta.original.duration * 1000} minimumValue={0}
value={audioPosition} maximumValue={audio.meta.original.duration * 1000}
minimumTrackTintColor={theme.secondary} value={audioPosition}
maximumTrackTintColor={theme.disabled} minimumTrackTintColor={theme.secondary}
// onSlidingStart={() => { maximumTrackTintColor={theme.disabled}
// audioPlayer?.pauseAsync() // onSlidingStart={() => {
// setAudioPlaying(false) // audioPlayer?.pauseAsync()
// }} // setAudioPlaying(false)
// onSlidingComplete={value => { // }}
// setAudioPosition(value) // onSlidingComplete={value => {
// }} // setAudioPosition(value)
enabled={false} // Bug in above sliding actions // }}
thumbSize={StyleConstants.Spacing.M} enabled={false} // Bug in above sliding actions
thumbTintColor={theme.primaryOverlay} thumbSize={StyleConstants.Spacing.M}
/> thumbTintColor={theme.primaryOverlay}
</View> />
</View>
) : null}
</View> </View>
) )
} }

View File

@ -23,32 +23,35 @@ import ImageViewer from './ImageViewer/Root'
const saveImage = async ( const saveImage = async (
image: Nav.RootStackParamList['Screen-ImagesViewer']['imageUrls'][0] image: Nav.RootStackParamList['Screen-ImagesViewer']['imageUrls'][0]
) => { ) => {
const hasAndroidPermission = async () => { if (Platform.OS === 'ios') {
const permission = PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE CameraRoll.save(image.url)
.then(() => haptics('Success'))
.catch(() => {
if (image.remote_url) {
CameraRoll.save(image.remote_url)
.then(() => haptics('Success'))
.catch(() => haptics('Error'))
} else {
haptics('Error')
}
})
} else if (Platform.OS === 'android') {
const hasAndroidPermission = async () => {
const permission = PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE
const hasPermission = await PermissionsAndroid.check(permission) const hasPermission = await PermissionsAndroid.check(permission)
if (hasPermission) { if (hasPermission) {
return true return true
}
const status = await PermissionsAndroid.request(permission)
return status === 'granted'
} }
const status = await PermissionsAndroid.request(permission) if (!(await hasAndroidPermission())) {
return status === 'granted' return
}
} }
if (Platform.OS === 'android' && !(await hasAndroidPermission())) {
return
}
CameraRoll.save(image.url)
.then(() => haptics('Success'))
.catch(() => {
if (image.remote_url) {
CameraRoll.save(image.remote_url)
.then(() => haptics('Success'))
.catch(() => haptics('Error'))
} else {
haptics('Error')
}
})
} }
const HeaderComponent = React.memo( const HeaderComponent = React.memo(
@ -109,6 +112,7 @@ const HeaderComponent = React.memo(
<HeaderLeft <HeaderLeft
content='X' content='X'
native={false} native={false}
background
onPress={() => navigation.goBack()} onPress={() => navigation.goBack()}
/> />
<HeaderCenter <HeaderCenter
@ -118,6 +122,7 @@ const HeaderComponent = React.memo(
<HeaderRight <HeaderRight
content='MoreHorizontal' content='MoreHorizontal'
native={false} native={false}
background
onPress={onPress} onPress={onPress}
/> />
</View> </View>

View File

@ -2,7 +2,7 @@ import { MenuContainer, MenuRow } from '@components/Menu'
import { updateInstancePush } from '@utils/slices/instances/updatePush' import { updateInstancePush } from '@utils/slices/instances/updatePush'
import { updateInstancePushAlert } from '@utils/slices/instances/updatePushAlert' import { updateInstancePushAlert } from '@utils/slices/instances/updatePushAlert'
import { updateInstancePushDecode } from '@utils/slices/instances/updatePushDecode' import { updateInstancePushDecode } from '@utils/slices/instances/updatePushDecode'
import { getInstancePush } from '@utils/slices/instancesSlice' import { clearPushLoading, getInstancePush } from '@utils/slices/instancesSlice'
import * as WebBrowser from 'expo-web-browser' import * as WebBrowser from 'expo-web-browser'
import * as Notifications from 'expo-notifications' import * as Notifications from 'expo-notifications'
import React, { useEffect, useMemo, useState } from 'react' import React, { useEffect, useMemo, useState } from 'react'
@ -36,6 +36,10 @@ const ScreenMeSettingsPush: React.FC = () => {
} }
}, []) }, [])
useEffect(() => {
dispatch(clearPushLoading())
}, [])
const isLoading = instancePush?.global.loading || instancePush?.decode.loading const isLoading = instancePush?.global.loading || instancePush?.decode.loading
const alerts = useMemo(() => { const alerts = useMemo(() => {

View File

@ -164,6 +164,16 @@ const instancesSlice = createSlice({
draft => draft.timestamp !== action.payload draft => draft.timestamp !== action.payload
) )
}, },
clearPushLoading: ({ instances }) => {
const activeIndex = findInstanceActive(instances)
instances[activeIndex].push.global.loading = false
instances[activeIndex].push.decode.loading = false
instances[activeIndex].push.alerts.favourite.loading = false
instances[activeIndex].push.alerts.follow.loading = false
instances[activeIndex].push.alerts.mention.loading = false
instances[activeIndex].push.alerts.poll.loading = false
instances[activeIndex].push.alerts.reblog.loading = false
},
disableAllPushes: ({ instances }) => { disableAllPushes: ({ instances }) => {
instances = instances.map(instance => { instances = instances.map(instance => {
let newInstance = instance let newInstance = instance
@ -352,6 +362,7 @@ export const {
updateInstanceNotificationsFilter, updateInstanceNotificationsFilter,
updateInstanceDraft, updateInstanceDraft,
removeInstanceDraft, removeInstanceDraft,
clearPushLoading,
disableAllPushes disableAllPushes
} = instancesSlice.actions } = instancesSlice.actions