Don't reset editor state if props didn't change. Fixes #34
This commit is contained in:
parent
0e4cea6f52
commit
5704b3e53b
@ -8,7 +8,13 @@ class BaseMainView extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
this.setState(Object.assign(this.initialState, nextProps.entry))
|
const newState = Object.assign(this.initialState, nextProps.entry)
|
||||||
|
for (const key of this.entryKeys) {
|
||||||
|
if (this.props.entry[key] === nextProps.entry[key]) {
|
||||||
|
newState[key] = this.state[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.setState(newState)
|
||||||
}
|
}
|
||||||
|
|
||||||
delete = async () => {
|
delete = async () => {
|
||||||
@ -25,8 +31,12 @@ class BaseMainView extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get entryKeys() {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
get initialState() {
|
get initialState() {
|
||||||
throw Error("Not implemented")
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
get hasInstances() {
|
get hasInstances() {
|
||||||
|
@ -46,6 +46,11 @@ class Client extends BaseMainView {
|
|||||||
this.deleteFunc = api.deleteClient
|
this.deleteFunc = api.deleteClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get entryKeys() {
|
||||||
|
return ["id", "displayname", "homeserver", "avatar_url", "access_token", "sync",
|
||||||
|
"autojoin", "enabled", "started"]
|
||||||
|
}
|
||||||
|
|
||||||
get initialState() {
|
get initialState() {
|
||||||
return {
|
return {
|
||||||
id: "",
|
id: "",
|
||||||
|
@ -40,6 +40,10 @@ class Instance extends BaseMainView {
|
|||||||
this.updateClientOptions()
|
this.updateClientOptions()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get entryKeys() {
|
||||||
|
return ["id", "primary_user", "enabled", "started", "type", "config"]
|
||||||
|
}
|
||||||
|
|
||||||
get initialState() {
|
get initialState() {
|
||||||
return {
|
return {
|
||||||
id: "",
|
id: "",
|
||||||
|
Loading…
Reference in New Issue
Block a user