Procházet zdrojové kódy

Fixing @user in comments doesn't work if it's in a separate line

Sam X. Chen před 5 roky
rodič
revize
e0046032e8
2 změnil soubory, kde provedl 13 přidání a 7 odebrání
  1. 4 0
      client/components/main/layouts.styl
  2. 9 7
      models/activities.js

+ 4 - 0
client/components/main/layouts.styl

@@ -381,6 +381,10 @@ a
   display: block
   word-wrap: break-word
 
+  table
+    word-wrap: normal
+    word-break: normal
+
   ol
     list-style-type: decimal
     padding-left: 20px

+ 9 - 7
models/activities.js

@@ -180,7 +180,7 @@ if (Meteor.isServer) {
       const comment = activity.comment();
       params.comment = comment.text;
       if (board) {
-        const atUser = /(?:^|>|\b|\s)@(\S+)(?:\s|$|<|\b)/g;
+        const atUser = /(?:^|>|\b|\s)@(\S+?)(?:\s|$|<|\b)/g;
         const comment = params.comment;
         if (comment.match(atUser)) {
           const commenter = params.user;
@@ -192,12 +192,14 @@ if (Meteor.isServer) {
             }
             const atUser =
               Users.findOne(username) || Users.findOne({ username });
-            const uid = atUser && atUser._id;
-            params.atUsername = username;
-            params.atEmails = atUser.emails;
-            if (board.hasMember(uid)) {
-              title = 'act-atUserComment';
-              watchers = _.union(watchers, [uid]);
+            if (atUser && atUser._id) {
+              const uid = atUser._id;
+              params.atUsername = username;
+              params.atEmails = atUser.emails;
+              if (board.hasMember(uid)) {
+                title = 'act-atUserComment';
+                watchers = _.union(watchers, [uid]);
+              }
             }
           }
         }