mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-14 08:23:59 +00:00
Fixing an issue with comments clearing out forms. Fixes #1045
This commit is contained in:
parent
dee5c302a8
commit
c76e72b747
6 changed files with 36 additions and 23 deletions
31
ui/src/components/inbox.tsx
vendored
31
ui/src/components/inbox.tsx
vendored
|
@ -275,21 +275,21 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
combined(): Array<ReplyType> {
|
||||||
|
return [
|
||||||
|
...this.state.replies,
|
||||||
|
...this.state.mentions,
|
||||||
|
...this.state.messages,
|
||||||
|
].sort((a, b) => b.published.localeCompare(a.published));
|
||||||
|
}
|
||||||
|
|
||||||
all() {
|
all() {
|
||||||
let combined: Array<ReplyType> = [];
|
|
||||||
|
|
||||||
combined.push(...this.state.replies);
|
|
||||||
combined.push(...this.state.mentions);
|
|
||||||
combined.push(...this.state.messages);
|
|
||||||
|
|
||||||
// Sort it
|
|
||||||
combined.sort((a, b) => b.published.localeCompare(a.published));
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{combined.map(i =>
|
{this.combined().map(i =>
|
||||||
isCommentType(i) ? (
|
isCommentType(i) ? (
|
||||||
<CommentNodes
|
<CommentNodes
|
||||||
|
key={i.id}
|
||||||
nodes={[{ comment: i }]}
|
nodes={[{ comment: i }]}
|
||||||
noIndent
|
noIndent
|
||||||
markable
|
markable
|
||||||
|
@ -298,7 +298,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
enableDownvotes={this.state.site.enable_downvotes}
|
enableDownvotes={this.state.site.enable_downvotes}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<PrivateMessage privateMessage={i} />
|
<PrivateMessage key={i.id} privateMessage={i} />
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -325,6 +325,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
<div>
|
<div>
|
||||||
{this.state.mentions.map(mention => (
|
{this.state.mentions.map(mention => (
|
||||||
<CommentNodes
|
<CommentNodes
|
||||||
|
key={mention.id}
|
||||||
nodes={[{ comment: mention }]}
|
nodes={[{ comment: mention }]}
|
||||||
noIndent
|
noIndent
|
||||||
markable
|
markable
|
||||||
|
@ -341,7 +342,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{this.state.messages.map(message => (
|
{this.state.messages.map(message => (
|
||||||
<PrivateMessage privateMessage={message} />
|
<PrivateMessage key={message.id} privateMessage={message} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -565,7 +566,6 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
} else if (data.comment.creator_id == UserService.Instance.user.id) {
|
} else if (data.comment.creator_id == UserService.Instance.user.id) {
|
||||||
toast(i18n.t('reply_sent'));
|
toast(i18n.t('reply_sent'));
|
||||||
}
|
}
|
||||||
this.setState(this.state);
|
|
||||||
} else if (res.op == UserOperation.CreatePrivateMessage) {
|
} else if (res.op == UserOperation.CreatePrivateMessage) {
|
||||||
let data = res.data as PrivateMessageResponse;
|
let data = res.data as PrivateMessageResponse;
|
||||||
if (data.message.recipient_id == UserService.Instance.user.id) {
|
if (data.message.recipient_id == UserService.Instance.user.id) {
|
||||||
|
@ -597,7 +597,10 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
this.state.replies.filter(r => !r.read).length +
|
this.state.replies.filter(r => !r.read).length +
|
||||||
this.state.mentions.filter(r => !r.read).length +
|
this.state.mentions.filter(r => !r.read).length +
|
||||||
this.state.messages.filter(
|
this.state.messages.filter(
|
||||||
r => !r.read && r.creator_id !== UserService.Instance.user.id
|
r =>
|
||||||
|
UserService.Instance.user &&
|
||||||
|
!r.read &&
|
||||||
|
r.creator_id !== UserService.Instance.user.id
|
||||||
).length
|
).length
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
1
ui/src/components/navbar.tsx
vendored
1
ui/src/components/navbar.tsx
vendored
|
@ -431,6 +431,7 @@ export class Navbar extends Component<any, NavbarState> {
|
||||||
// The login
|
// The login
|
||||||
if (data.my_user) {
|
if (data.my_user) {
|
||||||
UserService.Instance.user = data.my_user;
|
UserService.Instance.user = data.my_user;
|
||||||
|
WebSocketService.Instance.userJoin();
|
||||||
// On the first load, check the unreads
|
// On the first load, check the unreads
|
||||||
if (this.state.isLoggedIn == false) {
|
if (this.state.isLoggedIn == false) {
|
||||||
this.requestNotificationPermission();
|
this.requestNotificationPermission();
|
||||||
|
|
13
ui/src/components/private-message.tsx
vendored
13
ui/src/components/private-message.tsx
vendored
|
@ -45,7 +45,10 @@ export class PrivateMessage extends Component<
|
||||||
}
|
}
|
||||||
|
|
||||||
get mine(): boolean {
|
get mine(): boolean {
|
||||||
return UserService.Instance.user.id == this.props.privateMessage.creator_id;
|
return (
|
||||||
|
UserService.Instance.user &&
|
||||||
|
UserService.Instance.user.id == this.props.privateMessage.creator_id
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -113,6 +116,7 @@ export class PrivateMessage extends Component<
|
||||||
<PrivateMessageForm
|
<PrivateMessageForm
|
||||||
privateMessage={message}
|
privateMessage={message}
|
||||||
onEdit={this.handlePrivateMessageEdit}
|
onEdit={this.handlePrivateMessageEdit}
|
||||||
|
onCreate={this.handlePrivateMessageCreate}
|
||||||
onCancel={this.handleReplyCancel}
|
onCancel={this.handleReplyCancel}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
@ -280,9 +284,14 @@ export class PrivateMessage extends Component<
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePrivateMessageCreate() {
|
handlePrivateMessageCreate(message: PrivateMessageI) {
|
||||||
|
if (
|
||||||
|
UserService.Instance.user &&
|
||||||
|
message.creator_id == UserService.Instance.user.id
|
||||||
|
) {
|
||||||
this.state.showReply = false;
|
this.state.showReply = false;
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
toast(i18n.t('message_sent'));
|
toast(i18n.t('message_sent'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
2
ui/src/components/search.tsx
vendored
2
ui/src/components/search.tsx
vendored
|
@ -289,6 +289,7 @@ export class Search extends Component<any, SearchState> {
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
{i.type_ == 'posts' && (
|
{i.type_ == 'posts' && (
|
||||||
<PostListing
|
<PostListing
|
||||||
|
key={(i.data as Post).id}
|
||||||
post={i.data as Post}
|
post={i.data as Post}
|
||||||
showCommunity
|
showCommunity
|
||||||
enableDownvotes={this.state.site.enable_downvotes}
|
enableDownvotes={this.state.site.enable_downvotes}
|
||||||
|
@ -297,6 +298,7 @@ export class Search extends Component<any, SearchState> {
|
||||||
)}
|
)}
|
||||||
{i.type_ == 'comments' && (
|
{i.type_ == 'comments' && (
|
||||||
<CommentNodes
|
<CommentNodes
|
||||||
|
key={(i.data as Comment).id}
|
||||||
nodes={[{ comment: i.data as Comment }]}
|
nodes={[{ comment: i.data as Comment }]}
|
||||||
locked
|
locked
|
||||||
noIndent
|
noIndent
|
||||||
|
|
2
ui/src/components/user-details.tsx
vendored
2
ui/src/components/user-details.tsx
vendored
|
@ -150,6 +150,7 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
|
||||||
<div>
|
<div>
|
||||||
{i.type === 'posts' ? (
|
{i.type === 'posts' ? (
|
||||||
<PostListing
|
<PostListing
|
||||||
|
key={(i.data as Post).id}
|
||||||
post={i.data as Post}
|
post={i.data as Post}
|
||||||
admins={this.props.admins}
|
admins={this.props.admins}
|
||||||
showCommunity
|
showCommunity
|
||||||
|
@ -158,6 +159,7 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<CommentNodes
|
<CommentNodes
|
||||||
|
key={(i.data as Comment).id}
|
||||||
nodes={[{ comment: i.data as Comment }]}
|
nodes={[{ comment: i.data as Comment }]}
|
||||||
admins={this.props.admins}
|
admins={this.props.admins}
|
||||||
noBorder
|
noBorder
|
||||||
|
|
4
ui/src/services/WebSocketService.ts
vendored
4
ui/src/services/WebSocketService.ts
vendored
|
@ -82,10 +82,6 @@ export class WebSocketService {
|
||||||
this.ws.onopen = () => {
|
this.ws.onopen = () => {
|
||||||
console.log(`Connected to ${wsUri}`);
|
console.log(`Connected to ${wsUri}`);
|
||||||
|
|
||||||
if (UserService.Instance.user) {
|
|
||||||
this.userJoin();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!firstConnect) {
|
if (!firstConnect) {
|
||||||
let res: WebSocketJsonResponse = {
|
let res: WebSocketJsonResponse = {
|
||||||
reconnect: true,
|
reconnect: true,
|
||||||
|
|
Loading…
Reference in a new issue