britto icon indicating copy to clipboard operation
britto copied to clipboard

No Live Updates on Blog Posts

Open joeyjoejoejr opened this issue 12 years ago • 18 comments

I've been messing around with the blog a bit and can't seem to get live updates on the blog#show action, unless I navigate to another page and come back. All other pages seem to work fine.

I'm working on an in-place-editing feature that requires live updating to work. Any ideas why this might be happening? I've been scratching my head over it for a couple days now.

How to replicate:

-Open two windows of the britto blog: http://britto.meteor.com (make sure you're logged in to at least one) -Navigate both to a blog show page -Edit one -- the other doesn't update -On the one that didn't update click any link and then navigate back to that same blog post -Now Edit the first one -- the other now updates properly

joeyjoejoejr avatar May 29 '12 14:05 joeyjoejoejr

Ok, I'm still completely lost but it seems like this might have something to do with controller "show" actions. I'll do a little more testing to see.

It seems that the first time through there are no queries on the Posts model(Posts._collection.queries). Once you go somewhere else there querries are added and they keep up to date.

Since it seems to be that can click on any stellar handled link to fix it, it seems like it might be something in the execution order, but I've been looking at it for two days and can't figure it out.

joeyjoejoejr avatar May 29 '12 17:05 joeyjoejoejr

hi joey :)

is there a fork i can look at to see your changes? i have been thinking about in page editing too, just havent started to implement it yet because other things are of bigger importance imho :)

the optimum would be to enable the user to change anything inpage, every image, many of the margins and so on, but this will for sure take some time, especially because it means that we will have to move a lot of the template content into the database and pass it into a new collection. but this is planned nonetheless. the text and image edit will come as soon as i add the german translation,

soon there should be a plugin api though, in page editing for sure is a plugin not a base feature (many people get confused by it, i am serious here ;) )

i can liveupdate on http://britto-manarius.meteor.com btw, i guess the problem lies in your implementation?

have fun manarius

jaeh avatar May 29 '12 19:05 jaeh

I will take a look at this later... should be something simple it could be an issue with Stellar though.

jonathanKingston avatar May 29 '12 19:05 jonathanKingston

Thanks,

I've been looking through Stellar too and have come up short. I figure you might be able to find it since you built it.

Also, Manarius --

I just checked your implementation. It does the same thing. If you follow the steps, you'll see it.

joeyjoejoejr avatar May 29 '12 19:05 joeyjoejoejr

Confirmed even on the updated version, content doesn't get updated on the actual blog page itself.

What is odd, I just deployed to britto.meteor.com and all the data just got wiped :/ has anyone else seen this issue?

jonathanKingston avatar May 29 '12 19:05 jonathanKingston

Also Manarius --

I'll show you a fork asap, but I'm waiting for this issue to be resolved. You really don't need anymore information to be in the database than before. You simply need a Handlebars helper that does the work for you on each individual field.

joeyjoejoejr avatar May 29 '12 19:05 joeyjoejoejr

Argh... I know why, bad times. All the posts are unpublished. Next step, migrations but at least for Britto.

jonathanKingston avatar May 29 '12 19:05 jonathanKingston

hey again, sorry, i did overread that you mean at the first load time, will read more thorough in the future :D

no hurry with the fork, i just am curious and still addicted to see how others work with node/meteor :)

jaeh avatar May 29 '12 23:05 jaeh

BlogController.show = function() {
  Session.set('blogshow', Stellar.page.params['show']);
  //TODO  Meteor.subscribe("postcomments", post._id, init);
  Meteor.autosubscribe(function() {
    Meteor.subscribe("post",Session.get('blogshow'));
    post = Posts.findOne({slug:Session.get('blogshow')});

    if(post) {  
      Stellar.render('postView', {post: post});
      }
  });

This seems to have fixed the problem but I'm not sure why exactly. Does the autosubscibe keep records of find calls made in the onComplete function of a nested subscribe? I'm making a note to test that in a more sterile environment.

PS- I read your post about dropping out of the Meteor community? Does that mean that you won't be working on this project? I'd be sad to see that happen, and this seems to be the most developed Meteor project out there.

joeyjoejoejr avatar May 31 '12 18:05 joeyjoejoejr

I have a feeling that is the way it is supposed to be used... I will fix the live code tonight thank you :).

This project will likely be kept on yes. I'm just having a little break at the moment. After the weekend I might have something better to show.

jonathanKingston avatar Jun 01 '12 08:06 jonathanKingston

Alright, I've pushed a first version of my inplace editing system. It's based on an earlier version of the blog, so I'll need to try and merge it with the recent updates but you can see the basic idea here.

https://github.com/joeyjoejoejr/britto/tree/inplace

It gives you an <#ipFormFor> helper that takes the a reference to the current record and a hash with the name of the model. it also gives you <#ipTextField> and <#ipTextArea> helpers that take a reference to the attribute to edit. If you are logged in you can click and update on the spot, and if you are not logged in it's not clickable.

Let me know what you guys think.

joeyjoejoejr avatar Jun 02 '12 10:06 joeyjoejoejr

Hey do you have a example address I can see? You might want to change your SSH key as you committed that by mistake (I'm guessing).

jonathanKingston avatar Jun 03 '12 01:06 jonathanKingston

Well, that was dumb. I'm not even sure how that file got there. Thanks for the heads up.

I just deployed an example: http://inplacebritto.meteor.com/

joeyjoejoejr avatar Jun 03 '12 13:06 joeyjoejoejr

I try my best to do git status before "git add ." as everyone makes mistakes right?

I really like that, can I merge that into master as a plugin? So the user has to enable it but once they can then it works like that?

jonathanKingston avatar Jun 04 '12 14:06 jonathanKingston

Yeah, feel free. I thought you might not want it to be default behavior. Do you want me to submit it as a pull request?

joeyjoejoejr avatar Jun 04 '12 14:06 joeyjoejoejr

What I will do is pull it from your repo, then I can alter it as I want to keep the default styles for now. But that way you should be still visible as commits :)

jonathanKingston avatar Jun 04 '12 14:06 jonathanKingston

i just realised that using autosubscribe leads to all fields being published to the client at all times, even if you later just fetch some fields from the collection

would be great if one of you could test this too.

this means that autosubscribe shouldnt be used, and it explained a lot of the problems i had in the tests i did the last days ;)

jaeh avatar Jun 15 '12 01:06 jaeh

If using subscribe, autosubscribe can't be used.

jonathanKingston avatar Jun 15 '12 09:06 jonathanKingston