fix: artist name
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { BlurView } from 'expo-blur'
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { Modal, Pressable, StyleSheet, Text, View } from 'react-native'
|
||||
import { Modal, Platform, Pressable, StyleSheet, Text, View } from 'react-native'
|
||||
import useMinuit from 'react-native-minuit/src/hooks/useMinuit'
|
||||
import BorderGradientButton from '../../components/BorderGradientButton'
|
||||
import FullscreenIntroVideo from '../../components/FullscreenIntroVideo'
|
||||
@@ -18,9 +18,12 @@ import { buildFullName } from '../../utils/artistName'
|
||||
import { background } from '../../assets'
|
||||
|
||||
export const ChooseCoverType = () => {
|
||||
const isIOS = Platform.OS === 'ios'
|
||||
const [showIntro, setShowIntro] = useState(true)
|
||||
const [choiceVisible, setChoiceVisible] = useState(false)
|
||||
const [pseudoVisible, setPseudoVisible] = useState(false)
|
||||
const [choiceDismissAction, setChoiceDismissAction] = useState(null)
|
||||
const [pseudoDismissAction, setPseudoDismissAction] = useState(null)
|
||||
const [pseudo, setPseudo] = useState('')
|
||||
const [pendingAction, setPendingAction] = useState(null)
|
||||
const [savingChoice, setSavingChoice] = useState(false)
|
||||
@@ -115,13 +118,45 @@ export const ChooseCoverType = () => {
|
||||
|
||||
const closeChoiceModal = useCallback(() => {
|
||||
setChoiceVisible(false)
|
||||
setChoiceDismissAction(null)
|
||||
setPendingAction(null)
|
||||
}, [])
|
||||
|
||||
const openPseudoModal = useCallback(() => {
|
||||
if (isIOS) {
|
||||
setChoiceDismissAction('OPEN_PSEUDO')
|
||||
setChoiceVisible(false)
|
||||
return
|
||||
}
|
||||
setChoiceVisible(false)
|
||||
setPseudoVisible(true)
|
||||
}, [])
|
||||
}, [isIOS])
|
||||
|
||||
const handleChoiceModalDismiss = useCallback(async () => {
|
||||
if (choiceDismissAction === 'OPEN_PSEUDO') {
|
||||
setChoiceDismissAction(null)
|
||||
setPseudoVisible(true)
|
||||
return
|
||||
}
|
||||
|
||||
if (choiceDismissAction === 'RUN_PENDING_ACTION') {
|
||||
setChoiceDismissAction(null)
|
||||
await runPendingAction()
|
||||
return
|
||||
}
|
||||
|
||||
setChoiceDismissAction(null)
|
||||
}, [choiceDismissAction, runPendingAction])
|
||||
|
||||
const handlePseudoModalDismiss = useCallback(async () => {
|
||||
if (pseudoDismissAction === 'RUN_PENDING_ACTION') {
|
||||
setPseudoDismissAction(null)
|
||||
await runPendingAction()
|
||||
return
|
||||
}
|
||||
|
||||
setPseudoDismissAction(null)
|
||||
}, [pseudoDismissAction, runPendingAction])
|
||||
|
||||
const handleUseRealName = useCallback(async () => {
|
||||
if (!currentUID) return
|
||||
@@ -130,8 +165,13 @@ export const ChooseCoverType = () => {
|
||||
type: 'error',
|
||||
text: "Renseigne ton prénom et nom dans ton profil ou crée un nom d'artiste.",
|
||||
})
|
||||
setChoiceVisible(false)
|
||||
setPseudoVisible(true)
|
||||
if (isIOS) {
|
||||
setChoiceDismissAction('OPEN_PSEUDO')
|
||||
setChoiceVisible(false)
|
||||
} else {
|
||||
setChoiceVisible(false)
|
||||
setPseudoVisible(true)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -146,8 +186,13 @@ export const ChooseCoverType = () => {
|
||||
await usersRef.doc(currentUID).set(updates, { merge: true })
|
||||
await applyDisplayNameToProjects(realName)
|
||||
setTooltip({ type: 'success', text: "Nom d'artiste mis à jour" })
|
||||
setChoiceVisible(false)
|
||||
await runPendingAction()
|
||||
if (isIOS) {
|
||||
setChoiceDismissAction('RUN_PENDING_ACTION')
|
||||
setChoiceVisible(false)
|
||||
} else {
|
||||
setChoiceVisible(false)
|
||||
await runPendingAction()
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('handleUseRealName error', e?.message)
|
||||
setTooltip({
|
||||
@@ -165,10 +210,12 @@ export const ChooseCoverType = () => {
|
||||
realName,
|
||||
runPendingAction,
|
||||
setTooltip,
|
||||
isIOS,
|
||||
])
|
||||
|
||||
const handleCancelPseudo = useCallback(() => {
|
||||
setPseudoVisible(false)
|
||||
setPseudoDismissAction(null)
|
||||
setPendingAction(null)
|
||||
}, [])
|
||||
|
||||
@@ -195,8 +242,13 @@ export const ChooseCoverType = () => {
|
||||
)
|
||||
await applyDisplayNameToProjects(value)
|
||||
setTooltip({ type: 'success', text: 'Pseudo enregistré' })
|
||||
setPseudoVisible(false)
|
||||
await runPendingAction()
|
||||
if (isIOS) {
|
||||
setPseudoDismissAction('RUN_PENDING_ACTION')
|
||||
setPseudoVisible(false)
|
||||
} else {
|
||||
setPseudoVisible(false)
|
||||
await runPendingAction()
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('handleSavePseudo error', e?.message)
|
||||
setTooltip({
|
||||
@@ -206,7 +258,7 @@ export const ChooseCoverType = () => {
|
||||
} finally {
|
||||
setSavingPseudo(false)
|
||||
}
|
||||
}, [applyDisplayNameToProjects, currentUID, pseudo, runPendingAction, setTooltip])
|
||||
}, [applyDisplayNameToProjects, currentUID, pseudo, runPendingAction, setTooltip, isIOS])
|
||||
|
||||
return (
|
||||
<Page backgroundImg={background.studioBG2} backgroundColor={'#2A2E33'} headerType="NONE">
|
||||
@@ -238,6 +290,7 @@ export const ChooseCoverType = () => {
|
||||
transparent
|
||||
animationType="fade"
|
||||
onRequestClose={closeChoiceModal}
|
||||
onDismiss={handleChoiceModalDismiss}
|
||||
>
|
||||
<View style={styles.modalBackdrop}>
|
||||
<Pressable
|
||||
@@ -272,6 +325,7 @@ export const ChooseCoverType = () => {
|
||||
transparent
|
||||
animationType="fade"
|
||||
onRequestClose={handleCancelPseudo}
|
||||
onDismiss={handlePseudoModalDismiss}
|
||||
>
|
||||
<View style={styles.modalBackdrop}>
|
||||
<Pressable
|
||||
|
||||
Reference in New Issue
Block a user