mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-22 14:45:20 +00:00
Only push notifs if on first page, and right local context. Fixes #131
This commit is contained in:
parent
829b617b17
commit
a4e207bde7
|
@ -716,6 +716,16 @@ export class Main extends Component<any, MainState> {
|
||||||
} else if (op == UserOperation.CreatePost) {
|
} else if (op == UserOperation.CreatePost) {
|
||||||
let data = wsJsonToRes<PostResponse>(msg).data;
|
let data = wsJsonToRes<PostResponse>(msg).data;
|
||||||
|
|
||||||
|
// NSFW check
|
||||||
|
let nsfw = data.post_view.post.nsfw || data.post_view.community.nsfw;
|
||||||
|
let nsfwCheck =
|
||||||
|
!nsfw ||
|
||||||
|
(nsfw &&
|
||||||
|
UserService.Instance.user &&
|
||||||
|
UserService.Instance.user.show_nsfw);
|
||||||
|
|
||||||
|
// Only push these if you're on the first page, and you pass the nsfw check
|
||||||
|
if (this.state.page == 1 && nsfwCheck) {
|
||||||
// If you're on subscribed, only push it if you're subscribed.
|
// If you're on subscribed, only push it if you're subscribed.
|
||||||
if (this.state.listingType == ListingType.Subscribed) {
|
if (this.state.listingType == ListingType.Subscribed) {
|
||||||
if (
|
if (
|
||||||
|
@ -726,22 +736,18 @@ export class Main extends Component<any, MainState> {
|
||||||
this.state.posts.unshift(data.post_view);
|
this.state.posts.unshift(data.post_view);
|
||||||
notifyPost(data.post_view, this.context.router);
|
notifyPost(data.post_view, this.context.router);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (this.state.listingType == ListingType.Local) {
|
||||||
// NSFW posts
|
// If you're on the local view, only push it if its local
|
||||||
let nsfw = data.post_view.post.nsfw || data.post_view.community.nsfw;
|
if (data.post_view.post.local) {
|
||||||
|
|
||||||
// Don't push the post if its nsfw, and don't have that setting on
|
|
||||||
if (
|
|
||||||
!nsfw ||
|
|
||||||
(nsfw &&
|
|
||||||
UserService.Instance.user &&
|
|
||||||
UserService.Instance.user.show_nsfw)
|
|
||||||
) {
|
|
||||||
this.state.posts.unshift(data.post_view);
|
this.state.posts.unshift(data.post_view);
|
||||||
notifyPost(data.post_view, this.context.router);
|
notifyPost(data.post_view, this.context.router);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.state.posts.unshift(data.post_view);
|
||||||
|
notifyPost(data.post_view, this.context.router);
|
||||||
}
|
}
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
|
}
|
||||||
} else if (
|
} else if (
|
||||||
op == UserOperation.EditPost ||
|
op == UserOperation.EditPost ||
|
||||||
op == UserOperation.DeletePost ||
|
op == UserOperation.DeletePost ||
|
||||||
|
|
Loading…
Reference in a new issue