mirror of
https://github.com/balzack/databag.git
synced 2025-03-13 00:50:03 +00:00
block send if share sheet adds unsupported asset type
This commit is contained in:
parent
9539a1f038
commit
a9cb556392
@ -53,7 +53,7 @@ export function AddTopic({ contentKey, shareIntent, setShareIntent }) {
|
||||
|
||||
const sendMessage = async () => {
|
||||
try {
|
||||
if (state.message || state.assets.length > 0) {
|
||||
if (!state.conflict && (state.message || state.assets.length > 0)) {
|
||||
await actions.addTopic();
|
||||
}
|
||||
}
|
||||
@ -183,13 +183,16 @@ export function AddTopic({ contentKey, shareIntent, setShareIntent }) {
|
||||
{ state.busy && (
|
||||
<ActivityIndicator color={Colors.primary} />
|
||||
)}
|
||||
{ state.locked && !contentKey && (
|
||||
{ state.conflict && (
|
||||
<MatIcons name="send-outline" size={20} color={Colors.alert} />
|
||||
)}
|
||||
{ !state.conflict && state.locked && !contentKey && (
|
||||
<MatIcons name="lock" size={20} color={Colors.lightgrey} />
|
||||
)}
|
||||
{ !state.busy && (!state.locked || contentKey) && (state.message || state.assets.length > 0) && (
|
||||
{ !state.conflict && !state.busy && (!state.locked || contentKey) && (state.message || state.assets.length > 0) && (
|
||||
<MatIcons name="send-outline" size={20} color={Colors.text} />
|
||||
)}
|
||||
{ !state.busy && (!state.locked || contentKey) && !(state.message || state.assets.length > 0) && (
|
||||
{ !state.conflict && !state.busy && (!state.locked || contentKey) && !(state.message || state.assets.length > 0) && (
|
||||
<MatIcons name="send-outline" size={20} color={Colors.lightgrey} />
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
|
@ -23,6 +23,7 @@ export function useAddTopic(contentKey) {
|
||||
enableAudio: false,
|
||||
enableVideo: false,
|
||||
locked: true,
|
||||
conflict: false,
|
||||
});
|
||||
|
||||
const assetId = useRef(0);
|
||||
@ -34,6 +35,25 @@ export function useAddTopic(contentKey) {
|
||||
setState((s) => ({ ...s, ...value }));
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let conflict = false;
|
||||
if (state.locked) {
|
||||
conflict = true;
|
||||
}
|
||||
state.assets.forEach(asset => {
|
||||
if (asset.type === 'image' && !state.enableImage) {
|
||||
conflict = true;
|
||||
}
|
||||
if (asset.video === 'video' && !state.enableVideo) {
|
||||
conflict = true;
|
||||
}
|
||||
if (asset.audio === 'audio' && !state.enableAudio) {
|
||||
conflict = true;
|
||||
}
|
||||
});
|
||||
updateState({ conflict });
|
||||
}, [state.assets, state.locked, state.enableImage, state.enableAudio, state.enableVideo]);
|
||||
|
||||
useEffect(() => {
|
||||
const cardId = conversation.state.card?.card?.cardId;
|
||||
const channelId = conversation.state.channel?.channelId;
|
||||
|
Loading…
Reference in New Issue
Block a user