mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
fix ctx for settings items
This commit is contained in:
parent
bec5a2b5d0
commit
d02bd49231
@ -7,6 +7,10 @@ import "./index.less"
|
||||
export default (props) => {
|
||||
const [value, setValue] = React.useState(props.ctx.currentValue)
|
||||
|
||||
React.useEffect(() => {
|
||||
setValue(props.ctx.currentValue)
|
||||
}, [props.ctx.currentValue])
|
||||
|
||||
return <div className="imageUploader">
|
||||
{
|
||||
!props.noPreview && value && <div className="uploadPreview">
|
||||
|
@ -1,4 +1,3 @@
|
||||
import React from "react"
|
||||
import UserModel from "models/user"
|
||||
import loadable from "@loadable/component"
|
||||
import UploadButton from "components/UploadButton"
|
||||
@ -105,7 +104,6 @@ export default {
|
||||
UploadButton
|
||||
],
|
||||
"defaultValue": (ctx) => {
|
||||
console.log(ctx)
|
||||
return ctx.userData.avatar
|
||||
},
|
||||
"onUpdate": async (value) => {
|
||||
@ -118,7 +116,6 @@ export default {
|
||||
return value
|
||||
}
|
||||
},
|
||||
"debounced": true,
|
||||
},
|
||||
{
|
||||
"id": "cover",
|
||||
@ -143,7 +140,6 @@ export default {
|
||||
return value
|
||||
}
|
||||
},
|
||||
"debounced": true,
|
||||
},
|
||||
{
|
||||
"id": "description",
|
||||
|
@ -419,6 +419,7 @@ export default class SettingItemComponent extends React.PureComponent {
|
||||
currentValue: this.state.value,
|
||||
dispatchUpdate: this.dispatchUpdate,
|
||||
onUpdateItem: this.onUpdateItem,
|
||||
processedCtx: this.props.ctx,
|
||||
},
|
||||
ref: this.componentRef,
|
||||
|
||||
@ -469,7 +470,18 @@ export default class SettingItemComponent extends React.PureComponent {
|
||||
{
|
||||
this.props.setting.extraActions.map((action, index) => {
|
||||
if (typeof action === "function") {
|
||||
return React.createElement(action)
|
||||
return React.createElement(action, {
|
||||
ctx: {
|
||||
updateCurrentValue: (updateValue) => this.setState({
|
||||
value: updateValue
|
||||
}),
|
||||
getCurrentValue: () => this.state.value,
|
||||
currentValue: this.state.value,
|
||||
dispatchUpdate: this.dispatchUpdate,
|
||||
onUpdateItem: this.onUpdateItem,
|
||||
processedCtx: this.props.ctx
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const handleOnClick = () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user