]> Untitled Git - lemmy-ui.git/commitdiff
Have setting to disable notifs for new posts. Fixes #132 (#345)
authorDessalines <dessalines@users.noreply.github.com>
Thu, 22 Jul 2021 20:18:13 +0000 (16:18 -0400)
committerGitHub <noreply@github.com>
Thu, 22 Jul 2021 20:18:13 +0000 (16:18 -0400)
package.json
src/shared/components/community/community.tsx
src/shared/components/home/home.tsx
src/shared/components/person/person.tsx
yarn.lock

index 270dad9787a864b0979939ea748c5dcba05e30fa..3b03e3c90fcee177ad7e3d04425216354387bc4e 100644 (file)
@@ -69,7 +69,7 @@
     "husky": "^7.0.1",
     "import-sort-style-module": "^6.0.0",
     "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",
     "mini-css-extract-plugin": "^2.1.0",
     "node-fetch": "^2.6.1",
index 09bc837a084562889c7d1cafc417996e422b41dc..64db8e1fda6c667a4f9d932517af8a8f78345cf0 100644 (file)
@@ -490,7 +490,9 @@ export class Community extends Component<any, State> {
     } else if (op == UserOperation.CreatePost) {
       let data = wsJsonToRes<PostResponse>(msg).data;
       this.state.posts.unshift(data.post_view);
-      notifyPost(data.post_view, this.context.router);
+      if (UserService.Instance.localUserView?.local_user.show_new_post_notifs) {
+        notifyPost(data.post_view, this.context.router);
+      }
       this.setState(this.state);
     } else if (op == UserOperation.CreatePostLike) {
       let data = wsJsonToRes<PostResponse>(msg).data;
index 3a74901416aeb8067b21fc0a675ca4337e7f5c1d..ab2df75e61d9ce3d48ac70176bc8162b0f4cc925 100644 (file)
@@ -849,17 +849,31 @@ export class Home extends Component<any, HomeState> {
               .includes(data.post_view.community.id)
           ) {
             this.state.posts.unshift(data.post_view);
-            notifyPost(data.post_view, this.context.router);
+            if (
+              UserService.Instance.localUserView?.local_user
+                .show_new_post_notifs
+            ) {
+              notifyPost(data.post_view, this.context.router);
+            }
           }
         } else if (this.state.listingType == ListingType.Local) {
           // If you're on the local view, only push it if its local
           if (data.post_view.post.local) {
             this.state.posts.unshift(data.post_view);
-            notifyPost(data.post_view, this.context.router);
+            if (
+              UserService.Instance.localUserView?.local_user
+                .show_new_post_notifs
+            ) {
+              notifyPost(data.post_view, this.context.router);
+            }
           }
         } else {
           this.state.posts.unshift(data.post_view);
-          notifyPost(data.post_view, this.context.router);
+          if (
+            UserService.Instance.localUserView?.local_user.show_new_post_notifs
+          ) {
+            notifyPost(data.post_view, this.context.router);
+          }
         }
         this.setState(this.state);
       }
index b6cc4b394d6e6dec9db0b192cefdddea6237b571..2259367b6430e99e686b3003f89d52affae97220 100644 (file)
@@ -830,6 +830,26 @@ export class Person extends Component<any, PersonState> {
               </label>
             </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-check">
               <input
@@ -1016,6 +1036,11 @@ export class Person extends Component<any, PersonState> {
     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) {
     i.state.saveUserSettingsForm.show_scores = event.target.checked;
     UserService.Instance.localUserView.local_user.show_scores =
@@ -1199,6 +1224,8 @@ export class Person extends Component<any, PersonState> {
         UserService.Instance.localUserView.local_user.show_scores;
       this.state.saveUserSettingsForm.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 =
         UserService.Instance.localUserView.local_user.email;
       this.state.saveUserSettingsForm.bio =
index 9ed1bffa179fd4a3ed516b9e3ef32215107d2cc7..8e30236fdde5b844d3cc6f5688144140ecd96394 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -5342,10 +5342,10 @@ lcid@^1.0.0:
   dependencies:
     invert-kv "^1.0.0"
 
-lemmy-js-client@0.11.0:
-  version "0.11.0"
-  resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.11.0.tgz#aab1d445c55ca486eac3e396818371b9adfdf564"
-  integrity sha512-maLAwvLXbq8ncFY1Bg3MkQ4b2yeDATPUKRldFqlLt7fvDF9Mkfa3udFrroLEyNep2t3vROAtwA1gjf+Fqop0+w==
+lemmy-js-client@0.11.3-rc.2:
+  version "0.11.3-rc.2"
+  resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.11.3-rc.2.tgz#2debf0e524dbdade7056900ea1f202be8bde1e1c"
+  integrity sha512-4dMjUxUdEGS9SlxDJDDAwR5CxSEeHWR8tbHAel1tCVPdxJmFWqOlbucjWDGNyAQIUOEC8hhNdtf3dlIftEF2Rw==
 
 levn@^0.4.1:
   version "0.4.1"