Переглянути джерело

Commit 7-5-1: Demonstrate the order that posts appear using a sleep.

Frederic G. MARAND 9 роки тому
батько
коміт
91c7b1a476
2 змінених файлів з 12 додано та 1 видалено
  1. 4 1
      client/templates/posts/post_submit.js
  2. 8 0
      lib/collections/posts.js

+ 4 - 1
client/templates/posts/post_submit.js

@@ -25,7 +25,10 @@ Template.postSubmit.events({
         alert("This link has already been posted");
       }
 
-      Router.go('postPage', { _id: result._id });
+      // Router.go('postPage', { _id: result._id });
     });
+
+    // Return to list page without waiting for the insert.
+    Router.go('postsList');
   }
 });

+ 8 - 0
lib/collections/posts.js

@@ -21,6 +21,14 @@ Meteor.methods({
       url: String
     });
 
+    if (Meteor.isServer) {
+      postAttributes.title += " (server)";
+      Meteor._sleepForMs(5000);
+    }
+    else {
+      postAttributes.title += " (client)";
+    }
+
     var postWithSameLink = Posts.findOne({ url: postAttributes.url });
     if (postWithSameLink) {
       // Return to skip the insert.