mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: fix messagepad render, fix #1074
This commit is contained in:
4 files changed
+13
-20
No files matched your search
@@ -286,7 +286,6 @@ export default async function (env: { watch?: boolean, production?: boolean, mea
|
|||||||
}),
|
}),
|
||||||
new ExtractCssPlugin({
|
new ExtractCssPlugin({
|
||||||
filename: `[name]-${version}.css?[fullhash:6]`,
|
filename: `[name]-${version}.css?[fullhash:6]`,
|
||||||
chunkFilename: '[name]-[chunkhash:6].chunk.css',
|
|
||||||
}),
|
}),
|
||||||
new WebpackManifestPlugin({}),
|
new WebpackManifestPlugin({}),
|
||||||
new webpack.IgnorePlugin({ resourceRegExp: /(^\.\/locale$)/ }),
|
new webpack.IgnorePlugin({ resourceRegExp: /(^\.\/locale$)/ }),
|
||||||
|
|||||||
@@ -18,12 +18,9 @@ const mapStateToProps = (state) => ({
|
|||||||
|
|
||||||
// eslint-disable-next-line react-refresh/only-export-components
|
// eslint-disable-next-line react-refresh/only-export-components
|
||||||
export default connect(mapStateToProps)(class MessagePadDialogueContentContainer extends React.PureComponent {
|
export default connect(mapStateToProps)(class MessagePadDialogueContentContainer extends React.PureComponent {
|
||||||
componentDidMount() {
|
|
||||||
$(this.refs.list).scrollLock({ strict: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
const node = this.refs.list;
|
const node = this.state.ref;
|
||||||
|
|
||||||
if (this.props.activeId !== prevProps.activeId) {
|
if (this.props.activeId !== prevProps.activeId) {
|
||||||
this.scrollToBottom = true;
|
this.scrollToBottom = true;
|
||||||
this.scrollWithAnimation = false;
|
this.scrollWithAnimation = false;
|
||||||
@@ -32,6 +29,8 @@ export default connect(mapStateToProps)(class MessagePadDialogueContentContainer
|
|||||||
this.scrollWithAnimation = true;
|
this.scrollWithAnimation = true;
|
||||||
} else this.scrollToBottom = false;
|
} else this.scrollToBottom = false;
|
||||||
|
|
||||||
|
if (!node) return;
|
||||||
|
$(this.state.ref).scrollLock({ strict: true });
|
||||||
if (this.scrollToBottom) {
|
if (this.scrollToBottom) {
|
||||||
const targetScrollTop = node.scrollHeight - node.offsetHeight;
|
const targetScrollTop = node.scrollHeight - node.offsetHeight;
|
||||||
if (this.scrollWithAnimation) {
|
if (this.scrollWithAnimation) {
|
||||||
@@ -93,14 +92,13 @@ export default connect(mapStateToProps)(class MessagePadDialogueContentContainer
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="messagepad__header">
|
<div className="messagepad__header">
|
||||||
{ this.props.item
|
{this.props.item && (
|
||||||
&& (
|
<a className="messagepad__content__header__title" href={`/user/${this.props.item.udoc._id}`}>
|
||||||
<a className="messagepad__content__header__title" href={`/user/${this.props.item.udoc._id}`}>
|
{`${this.props.item.udoc.uname}(UID: ${this.props.item.udoc._id})`}
|
||||||
{`${this.props.item.udoc.uname}(UID: ${this.props.item.udoc._id})`}
|
</a>
|
||||||
</a>
|
)}
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<ol className="messagepad__content" ref="list">
|
<ol className="messagepad__content" ref={(ref) => { this.setState({ ...this.state, ref }); }}>
|
||||||
{this.renderInner()}
|
{this.renderInner()}
|
||||||
</ol>
|
</ol>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -23,10 +23,6 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
|
|
||||||
// eslint-disable-next-line react-refresh/only-export-components
|
// eslint-disable-next-line react-refresh/only-export-components
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(class MessagePadDialogueListContainer extends React.PureComponent {
|
export default connect(mapStateToProps, mapDispatchToProps)(class MessagePadDialogueListContainer extends React.PureComponent {
|
||||||
componentDidMount() {
|
|
||||||
$(this.refs.list).scrollLock({ strict: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const orderedDialogues = _.orderBy(
|
const orderedDialogues = _.orderBy(
|
||||||
_.values(this.props.dialogues),
|
_.values(this.props.dialogues),
|
||||||
@@ -36,7 +32,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class MessagePadDial
|
|||||||
'desc',
|
'desc',
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<ol className="messagepad__list" ref="list">
|
<ol className="messagepad__list" ref={(ref) => $(ref).scrollLock({ strict: true })}>
|
||||||
{_.map(orderedDialogues, (dialogue) => (
|
{_.map(orderedDialogues, (dialogue) => (
|
||||||
<ListItem
|
<ListItem
|
||||||
key={dialogue._id}
|
key={dialogue._id}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class MessagePadInpu
|
|||||||
);
|
);
|
||||||
if (this.focusInput) {
|
if (this.focusInput) {
|
||||||
const { scrollX, scrollY } = window;
|
const { scrollX, scrollY } = window;
|
||||||
this.refs.input.focus();
|
this.state.ref?.focus();
|
||||||
window.scrollTo(scrollX, scrollY);
|
window.scrollTo(scrollX, scrollY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class MessagePadInpu
|
|||||||
<div className={cn}>
|
<div className={cn}>
|
||||||
<div className="messagepad__textarea-container">
|
<div className="messagepad__textarea-container">
|
||||||
<textarea
|
<textarea
|
||||||
ref="input"
|
ref={(ref) => this.setState({ ...this.state, ref })}
|
||||||
data-markdown
|
data-markdown
|
||||||
disabled={this.props.isPosting}
|
disabled={this.props.isPosting}
|
||||||
value={this.props.inputValue}
|
value={this.props.inputValue}
|
||||||
|
|||||||
Reference in new issue
Block a user