LastSessionsView

- added missing localization
- no reload on delete
This commit is contained in:
Martin Bauer
2023-10-02 09:41:48 +02:00
parent 9b6bb7f126
commit a576e91290
4 changed files with 28 additions and 12 deletions

View File

@@ -55,7 +55,7 @@ function SessionCardBehindSwipe(props) {
style={sessionCardStyles.deleteButton}
onPress={props.onDelete}
>
<Text style={{ fontSize: 18, color: "white" }}>Löschen</Text>
<Text style={{ fontSize: 18, color: "white" }}>{i18n.t('delete_session_button')}</Text>
</TouchableOpacity>
</View>
);
@@ -137,9 +137,6 @@ function parsePropfind(text) {
const parser = new XMLParser();
const xmlDoc = parser.parseFromString(text);
//const parser = new DOMParser();
//const xmlDoc = parser.parseFromString(text, "text/xml");
const responses = xmlDoc.getElementsByTagName("D:response");
let result = [];
for (let i = 0; i < responses.length; ++i) {
@@ -183,6 +180,7 @@ async function getFullData(swimTrackerHost, analysisSettings) {
const da = new DataAnalysis();
e.analysis = da.analyze(analysisSettings, e.startTime, e.values);
}
console.log("full data", parsed);
return parsed;
}
@@ -203,9 +201,14 @@ class LastSessionsView extends React.Component {
render() {
const deleteSession = async sessionFileName => {
this.setState({ sessions: null });
await request({ url: "http://" + this.props.swimTrackerHost + "/webdav/" + sessionFileName, method: "DELETE" });
this.setState({ sessions: await getFullData(this.props.swimTrackerHost, this.props.analysisSettings) });
const filteredSession = this.state.sessions.filter((element) => element.name != sessionFileName);
this.setState({ sessions: filteredSession });
request({ url: "http://" + this.props.swimTrackerHost + "/webdav/" + sessionFileName, method: "DELETE" })
.then((value) => console.log("Successfully deleted", sessionFileName, value))
.catch((err) => console.error("Failed to delete", sessionFileName, err));
//this.setState({ sessions: null });
//await request({ url: "http://" + this.props.swimTrackerHost + "/webdav/" + sessionFileName, method: "DELETE" });
//this.setState({ sessions: await getFullData(this.props.swimTrackerHost, this.props.analysisSettings) });
};
const onRefresh = async () => {