Skip to content

Add the ability to hide racer avatar display while in a race - #140

Draft
nihonjinrxs wants to merge 1 commit into
racetimeGG:masterfrom
nihonjinrxs:hide-avatars-while-racing
Draft

Add the ability to hide racer avatar display while in a race#140
nihonjinrxs wants to merge 1 commit into
racetimeGG:masterfrom
nihonjinrxs:hide-avatars-while-racing

Conversation

@nihonjinrxs

@nihonjinrxs nihonjinrxs commented Jul 31, 2021

Copy link
Copy Markdown
Contributor

Closes #133

Add a new boolean user setting hide_avatars_while_racing to enable users to turn off racer avatar display while in a race.

(This PR is still a work in progress.)

…le users to turn off racer avatar display while in a race
@nihonjinrxs

Copy link
Copy Markdown
Contributor Author

I posted in Discord about this, but I'll outline the current trouble here too.

I've created a new @property method on the User model that returns a boolean type. (I've tested this and I'm sure that's the case.)

When I use the user partial template (inside the entrant row partial here) with a boolean directly, it behaves as I expect:

<!-- avatar not shown -->
{% include 'racetime/pops/user.html' with user=entrant.user extra_class='inline' 
hide_avatar=True %}

<!-- avatar shown -->
{% include 'racetime/pops/user.html' with user=entrant.user extra_class='inline' hide_avatar=False %}

When I use the new property method, it seems to just ignore it:

<!-- always displays avatars no matter the return value -->
{% include 'racetime/pops/user.html' with user=entrant.user extra_class='inline' hide_avatar=request.user.hide_all_avatars %}

Help appreciated.

@nihonjinrxs

Copy link
Copy Markdown
Contributor Author

So with a bit more digging, using this code in the on the entrant row partial, I can see the information passed in that I need for this, but then it seems to get wiped out by the websocket message renders.

        request.user = "{{ request.user.name }}#{{ request.user.discriminator }}"
        user = "{{ user.name }}#{{ user.discriminator }}"
        entrant.user = "{{ entrant.user.name }}#{{ entrant.user.discriminator }}"
        request.user.hide_all_avatars = ({{ request.user.hide_all_avatars }})
        {% include 'racetime/pops/user.html' with user=entrant.user extra_class='inline' hide_avatar=request.user.hide_all_avatars %}

I'm going to look into memoizing that request.user data on page load so that I can make use of it later, irrespective of what comes in on the websocket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Disable animated avatars or hide avatars in general

1 participant