mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
completed relocation of modal edit
This commit is contained in:
parent
5053907fa6
commit
fc53b9e7c9
@ -13,8 +13,6 @@ import { TopicItem } from './topicItem/TopicItem';
|
||||
export function ConversationHeader({ closeConversation, openDetails }) {
|
||||
const navigation = useNavigation();
|
||||
const { state, actions } = useConversation();
|
||||
console.log(state.editing);
|
||||
|
||||
|
||||
const setDetails = () => {
|
||||
openDetails(navigation);
|
||||
@ -47,6 +45,20 @@ export function ConversationBody() {
|
||||
}
|
||||
}
|
||||
|
||||
const updateTopic = async () => {
|
||||
try {
|
||||
await actions.updateTopic();
|
||||
actions.hideEdit();
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err);
|
||||
Alert.alert(
|
||||
'Failed to Update Message',
|
||||
'Please try again.',
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
return (
|
||||
@ -93,7 +105,7 @@ export function ConversationBody() {
|
||||
<TouchableOpacity style={styles.cancel} onPress={actions.hideEdit}>
|
||||
<Text>Cancel</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity style={styles.save} onPress={actions.updateTopic}>
|
||||
<TouchableOpacity style={styles.save} onPress={updateTopic}>
|
||||
<Text style={styles.saveText}>Save</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
@ -46,20 +46,6 @@ export function TopicItem({ item, focused, focus, hosting, remove, update, block
|
||||
);
|
||||
}
|
||||
|
||||
const editMessage = async () => {
|
||||
try {
|
||||
await update(item.topicId, { ...state.editData, text: state.editMessage });
|
||||
actions.hideEdit();
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err);
|
||||
Alert.alert(
|
||||
'Failed to Update Message',
|
||||
'Please try again.',
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const hideMessage = () => {
|
||||
Alert.alert(
|
||||
"Blocking Message",
|
||||
@ -197,31 +183,6 @@ export function TopicItem({ item, focused, focus, hosting, remove, update, block
|
||||
/>
|
||||
</View>
|
||||
</Modal>
|
||||
<Modal
|
||||
animationType="fade"
|
||||
transparent={true}
|
||||
visible={state.editing}
|
||||
supportedOrientations={['portrait', 'landscape']}
|
||||
onRequestClose={actions.hideEdit}
|
||||
>
|
||||
<KeyboardAvoidingView behavior="height" style={styles.modal}>
|
||||
<View style={styles.editContainer}>
|
||||
<Text style={styles.editHeader}>Edit Message Text:</Text>
|
||||
<View style={styles.inputField}>
|
||||
<TextInput style={styles.input} value={state.editMessage} onChangeText={actions.setEditMessage}
|
||||
autoCapitalize="sentences" placeholder="Message Text" multiline={true} />
|
||||
</View>
|
||||
<View style={styles.editControls}>
|
||||
<Touchy style={styles.cancel} onPress={actions.hideEdit}>
|
||||
<Text>Cancel</Text>
|
||||
</Touchy>
|
||||
<Touchy style={styles.save} onPress={editMessage}>
|
||||
<Text style={styles.saveText}>Save</Text>
|
||||
</Touchy>
|
||||
</View>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
</Modal>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
@ -22,9 +22,6 @@ export function useTopicItem(item, hosting, remove) {
|
||||
fontColor: Colors.text,
|
||||
editable: false,
|
||||
deletable: false,
|
||||
editing: false,
|
||||
editMessage: null,
|
||||
editData: null,
|
||||
});
|
||||
|
||||
const profile = useContext(ProfileContext);
|
||||
@ -142,17 +139,6 @@ export function useTopicItem(item, hosting, remove) {
|
||||
setActive: (activeId) => {
|
||||
updateState({ activeId });
|
||||
},
|
||||
block: async () => {
|
||||
},
|
||||
showEdit: () => {
|
||||
updateState({ editing: true });
|
||||
},
|
||||
hideEdit: () => {
|
||||
updateState({ editing: false });
|
||||
},
|
||||
setEditMessage: (editMessage) => {
|
||||
updateState({ editMessage });
|
||||
},
|
||||
};
|
||||
|
||||
return { state, actions };
|
||||
|
@ -61,15 +61,13 @@ export function useConversation() {
|
||||
await conversation.actions.removeTopic(topicId);
|
||||
},
|
||||
editTopic: async (topicId, data) => {
|
||||
console.log("EDITING!");
|
||||
updateState({ editing: true, editTopicId: topicId, editData: data });
|
||||
//await conversation.actions.setTopicSubject(topicId, data);
|
||||
updateState({ editing: true, editTopicId: topicId, editMessage: data.text, editData: data });
|
||||
},
|
||||
hideEdit: () => {
|
||||
updateState({ editing: false });
|
||||
},
|
||||
updateTopic: () => {
|
||||
updateState({ editing: false });
|
||||
updateTopic: async () => {
|
||||
await conversation.actions.setTopicSubject(state.editTopicId, { ...state.editData, text: state.editMessage });
|
||||
},
|
||||
setEditMessage: (editMessage) => {
|
||||
updateState({ editMessage });
|
||||
|
Loading…
Reference in New Issue
Block a user