Have setting to disable notifs for new posts. Fixes #132

This commit is contained in:
Dessalines 2021-07-19 10:06:22 -04:00
parent d964bd3d1f
commit d61efa1f2f
5 changed files with 52 additions and 9 deletions

View file

@ -69,7 +69,7 @@
"husky": "^7.0.1", "husky": "^7.0.1",
"import-sort-style-module": "^6.0.0", "import-sort-style-module": "^6.0.0",
"iso-639-1": "^2.1.9", "iso-639-1": "^2.1.9",
"lemmy-js-client": "0.11.0", "lemmy-js-client": "0.11.3-rc.2",
"lint-staged": "^11.0.1", "lint-staged": "^11.0.1",
"mini-css-extract-plugin": "^2.1.0", "mini-css-extract-plugin": "^2.1.0",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.1",

View file

@ -502,7 +502,9 @@ export class Community extends Component<any, State> {
} else if (op == UserOperation.CreatePost) { } else if (op == UserOperation.CreatePost) {
let data = wsJsonToRes<PostResponse>(msg).data; let data = wsJsonToRes<PostResponse>(msg).data;
this.state.posts.unshift(data.post_view); this.state.posts.unshift(data.post_view);
if (UserService.Instance.localUserView?.local_user.show_new_post_notifs) {
notifyPost(data.post_view, this.context.router); notifyPost(data.post_view, this.context.router);
}
this.setState(this.state); this.setState(this.state);
} else if (op == UserOperation.CreatePostLike) { } else if (op == UserOperation.CreatePostLike) {
let data = wsJsonToRes<PostResponse>(msg).data; let data = wsJsonToRes<PostResponse>(msg).data;

View file

@ -840,18 +840,32 @@ export class Home extends Component<any, HomeState> {
.includes(data.post_view.community.id) .includes(data.post_view.community.id)
) { ) {
this.state.posts.unshift(data.post_view); this.state.posts.unshift(data.post_view);
if (
UserService.Instance.localUserView?.local_user
.show_new_post_notifs
) {
notifyPost(data.post_view, this.context.router); notifyPost(data.post_view, this.context.router);
} }
}
} else if (this.state.listingType == ListingType.Local) { } else if (this.state.listingType == ListingType.Local) {
// If you're on the local view, only push it if its local // If you're on the local view, only push it if its local
if (data.post_view.post.local) { if (data.post_view.post.local) {
this.state.posts.unshift(data.post_view); this.state.posts.unshift(data.post_view);
if (
UserService.Instance.localUserView?.local_user
.show_new_post_notifs
) {
notifyPost(data.post_view, this.context.router); notifyPost(data.post_view, this.context.router);
} }
}
} else { } else {
this.state.posts.unshift(data.post_view); this.state.posts.unshift(data.post_view);
if (
UserService.Instance.localUserView?.local_user.show_new_post_notifs
) {
notifyPost(data.post_view, this.context.router); notifyPost(data.post_view, this.context.router);
} }
}
this.setState(this.state); this.setState(this.state);
} }
} else if ( } else if (

View file

@ -835,6 +835,26 @@ export class Person extends Component<any, PersonState> {
</label> </label>
</div> </div>
</div> </div>
<div class="form-group">
<div class="form-check">
<input
class="form-check-input"
id="user-show-new-post-notifs"
type="checkbox"
checked={this.state.saveUserSettingsForm.show_new_post_notifs}
onChange={linkEvent(
this,
this.handleUserSettingsShowNewPostNotifs
)}
/>
<label
class="form-check-label"
htmlFor="user-show-new-post-notifs"
>
{i18n.t("show_new_post_notifs")}
</label>
</div>
</div>
<div class="form-group"> <div class="form-group">
<div class="form-check"> <div class="form-check">
<input <input
@ -1023,6 +1043,11 @@ export class Person extends Component<any, PersonState> {
i.setState(i.state); i.setState(i.state);
} }
handleUserSettingsShowNewPostNotifs(i: Person, event: any) {
i.state.saveUserSettingsForm.show_new_post_notifs = event.target.checked;
i.setState(i.state);
}
handleUserSettingsShowScoresChange(i: Person, event: any) { handleUserSettingsShowScoresChange(i: Person, event: any) {
i.state.saveUserSettingsForm.show_scores = event.target.checked; i.state.saveUserSettingsForm.show_scores = event.target.checked;
UserService.Instance.localUserView.local_user.show_scores = UserService.Instance.localUserView.local_user.show_scores =
@ -1206,6 +1231,8 @@ export class Person extends Component<any, PersonState> {
UserService.Instance.localUserView.local_user.show_scores; UserService.Instance.localUserView.local_user.show_scores;
this.state.saveUserSettingsForm.show_read_posts = this.state.saveUserSettingsForm.show_read_posts =
UserService.Instance.localUserView.local_user.show_read_posts; UserService.Instance.localUserView.local_user.show_read_posts;
this.state.saveUserSettingsForm.show_new_post_notifs =
UserService.Instance.localUserView.local_user.show_new_post_notifs;
this.state.saveUserSettingsForm.email = this.state.saveUserSettingsForm.email =
UserService.Instance.localUserView.local_user.email; UserService.Instance.localUserView.local_user.email;
this.state.saveUserSettingsForm.bio = this.state.saveUserSettingsForm.bio =

View file

@ -5342,10 +5342,10 @@ lcid@^1.0.0:
dependencies: dependencies:
invert-kv "^1.0.0" invert-kv "^1.0.0"
lemmy-js-client@0.11.0: lemmy-js-client@0.11.3-rc.2:
version "0.11.0" version "0.11.3-rc.2"
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.11.0.tgz#aab1d445c55ca486eac3e396818371b9adfdf564" resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.11.3-rc.2.tgz#2debf0e524dbdade7056900ea1f202be8bde1e1c"
integrity sha512-maLAwvLXbq8ncFY1Bg3MkQ4b2yeDATPUKRldFqlLt7fvDF9Mkfa3udFrroLEyNep2t3vROAtwA1gjf+Fqop0+w== integrity sha512-4dMjUxUdEGS9SlxDJDDAwR5CxSEeHWR8tbHAel1tCVPdxJmFWqOlbucjWDGNyAQIUOEC8hhNdtf3dlIftEF2Rw==
levn@^0.4.1: levn@^0.4.1:
version "0.4.1" version "0.4.1"