mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 02:08:47 +00:00
allow delete without refreshing page
This commit is contained in:
parent
9fff6ed81c
commit
445c8b39de
@ -70,12 +70,15 @@ const styles = {
|
||||
};
|
||||
|
||||
class user extends Component {
|
||||
state = {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = {
|
||||
profile: null,
|
||||
imageUrl: null,
|
||||
topics: null,
|
||||
newTopic: null
|
||||
};
|
||||
}
|
||||
|
||||
handleDelete = topic => {
|
||||
console.log(topic);
|
||||
@ -83,8 +86,16 @@ class user extends Component {
|
||||
.post(`/deleteTopic`, {
|
||||
unfollow: topic
|
||||
})
|
||||
.then(function() {
|
||||
location.reload();
|
||||
.then(() => {
|
||||
let tempTopics = this.state.topics;
|
||||
tempTopics.forEach((oldTopic, index) => {
|
||||
if (oldTopic === topic) {
|
||||
tempTopics.splice(index, 1);
|
||||
}
|
||||
});
|
||||
this.setState({
|
||||
topics: tempTopics
|
||||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.log(err);
|
||||
@ -96,8 +107,13 @@ class user extends Component {
|
||||
.post("/putTopic", {
|
||||
following: this.state.newTopic
|
||||
})
|
||||
.then(function() {
|
||||
location.reload();
|
||||
.then(() => {
|
||||
let tempTopics = this.state.topics;
|
||||
tempTopics.push(this.state.newTopic);
|
||||
this.setState({
|
||||
topics: tempTopics,
|
||||
newTopic: ""
|
||||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.log(err);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user