feat: unauthenticated tab
This commit is contained in:
@@ -30,6 +30,7 @@ import { getArtistDisplayName } from '../../utils/artistName';
|
||||
import { Palette } from '../../styles';
|
||||
import { FONT_FAMILY } from '../../styles/Fonts';
|
||||
import ProfilePicture from '../ProfilePicture';
|
||||
import { ensureAuthenticated } from '../../utils/authRedirect';
|
||||
|
||||
let externalOpen;
|
||||
let externalClose;
|
||||
@@ -72,6 +73,16 @@ const CommentsBottomSheet = () => {
|
||||
const [text, setText] = useState('');
|
||||
const [typing, setTyping] = useState(false);
|
||||
|
||||
const requireAuth = useCallback(() => {
|
||||
return ensureAuthenticated(currentUID, {
|
||||
onIntercept: () => {
|
||||
try {
|
||||
modalRef.current?.dismiss?.();
|
||||
} catch (_error) {}
|
||||
},
|
||||
});
|
||||
}, [currentUID]);
|
||||
|
||||
useEffect(() => {
|
||||
externalOpen = (pid) => {
|
||||
setProjectId(pid || null);
|
||||
@@ -127,7 +138,8 @@ const CommentsBottomSheet = () => {
|
||||
|
||||
const onSend = async () => {
|
||||
const value = (text || '').trim();
|
||||
if (!value || !projectId || !currentUID) return;
|
||||
if (!value || !projectId) return;
|
||||
if (!requireAuth()) return;
|
||||
try {
|
||||
setText('');
|
||||
const docRef = await projectsRef
|
||||
@@ -354,11 +366,23 @@ const CommentsBottomSheet = () => {
|
||||
placeholderTextColor='#FFFFFFAA'
|
||||
value={text}
|
||||
onChangeText={(t) => {
|
||||
if (!currentUID && !requireAuth()) {
|
||||
return;
|
||||
}
|
||||
setText(t);
|
||||
}}
|
||||
onFocus={() => {
|
||||
if (!requireAuth()) {
|
||||
setTyping(false);
|
||||
return;
|
||||
}
|
||||
setTyping(true);
|
||||
}}
|
||||
onPressIn={() => {
|
||||
if (!requireAuth()) {
|
||||
setTyping(false);
|
||||
}
|
||||
}}
|
||||
onBlur={() => setTyping(false)}
|
||||
style={{
|
||||
flex: 1,
|
||||
|
||||
Reference in New Issue
Block a user