Computed property never updating?


#1

I have the following in my template:

{{isViewingOwnProfile}}

In my route I have the following:

setupController: function(controller, models) {
	this._super(controller, models);

	controller.set('loggedInUser', models.loggedInUser);
	controller.set('user', models.user);
}

The models variable contains the correct values i.e.:

{
    id: 1,
    username: 'some user'
}

In my controller I have the following:

isViewingOwnProfile: function() {
	if (!this.get('session.isAuthenticated')) {
		return false;
	}

	var result = this.get('loggedInUser.id') == this.get('user.id');
	this.set('isViewingOwnProfile', result)
	return result
}.property('user.id')

Now - when the page loads this works as expected - however - transitioning to another users profile page doesn’t cause isViewingOwnProfile to get re-calculated?

I am setting the value correctly in setupController - the breakpoint hits with the new values - meaning that user.id has a different value.

Anyone got any clues as to what I am missing?


#2

I think this may be the culprit, does it work if you take that out? There’s no need to set the property value like that as you always want to rely on the return from the CP.


#3

AHAAAAA!!

Brilliant! Thank you :slight_smile: