you are viewing a single comment's thread.

view the rest of the comments →

[–]magnora7[S] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (21 children)

It's on our to do list, but we haven't figured out how to code it yet. There's a per-thread per-user setting in the database (which is what that box unchecks) but there's no per-user setting for that outside of a thread.

So we'd have to create a new database entry for every user (which we have never done before), as well as write new javascript functionality to access it, as well as properly set up new users to have correct database arrangements, and then add it in the html of the preferences page.

Or alternatively we need a per-user setting that hijacks some existing setting we don't use, so we don't have to create a new entry, then applies that automatically to the per-thread per-user setting when a new thread is created or viewed. Not sure which the best way is.

It's a 5-10 hour project potentially and you're the only person to have mentioned it. That's why it's not done yet. But we'll get there eventually.

[–][deleted] 3 insightful - 1 fun3 insightful - 0 fun4 insightful - 1 fun -  (20 children)

Your second method is how I'd do it. We introduce a new user preference that will override the state of the checkbox on the submit post form. Nothing new happens or is tracked once the post is submitted.

[–]magnora7[S] 3 insightful - 1 fun3 insightful - 0 fun4 insightful - 1 fun -  (19 children)

We introduce a new user preference that will override the state of the checkbox on the submit post form

Oh that's even simpler. We just need to find a setting that every user has that isn't being used I guess?

[–][deleted] 3 insightful - 1 fun3 insightful - 0 fun4 insightful - 1 fun -  (18 children)

New user preferences are super easy, like the ones we added for chat. They end up in the DB, but it's all handled automatically, we just add it to some list and it's managed for us.

[–]magnora7[S] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (0 children)

Alright well then add the preference to the list, and I'll figure out how to hook it up to that checkbox and let's get this done.

[–]magnora7[S] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (16 children)

/r2/r2/templates/newlink.html

<input class="nomargin" type="checkbox" checked="checked" name="sendreplies" id="sendreplies" data-send-checked="true"/>

checkbox="checked" needs to be removed if the user prefers that.

In Preferences, under the category "messaging options" we can add a default-checked box "receive replies to posts as messages".

Or, how about this d3rr, we make it so that when Orangutan unchecks the box while submitting, it remembers that preference. And we don't add anything to the Preferences page at all. That might be even simpler? Not sure how to do that though.

We can add in preferences.py

pref_post_sends_replies=Vboolean('post_sends_replies'),

I'm just not sure how to load preferences.py in to newlink.html. I don't see where it's loaded in to prefoptions.html.

But in place of the code in newlink.html we should have:

${checkbox(_("send replies to my inbox"), "post_sends_replies")}

So we have to change the checkbox from an HTML element to this

[–][deleted] 3 insightful - 1 fun3 insightful - 0 fun4 insightful - 1 fun -  (12 children)

Or, how about this d3rr, we make it so that when Orangutan unchecks the box while submitting, it remembers that preference. And we don't add anything to the Preferences page at all.

Oh shit, that's it. Love it. So we'll still use a preference for this, we just won't add it to the preferences page at all. Let me dig up some code examples.

[–]magnora7[S] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (11 children)

Maybe we can add

 pref_post_sends_replies=Vboolean("post_sends_replies"),

in to preferences.py

Then we just have to add this line to the start of newlink.html, which is also at the start of prefoptions.html

 <%def name="checkbox(text, name, disabled = False, disabled_text = '', prefix = 'pref_')">

then also later in the file at the checkbox add

${checkbox(_("send replies to my inbox"), "post_sends_replies")}

This might be a problem with users who don't have an account though? And how to we set it default to on?

[–][deleted] 3 insightful - 1 fun3 insightful - 0 fun4 insightful - 1 fun -  (10 children)

I think we can skip any preferences.py changes since we're not going to be showing this preference.

So I think we'd want

${checkbox(_("send replies to my inbox"), c.user.pref_sendreplies)}

So the final missing piece is hooking into the post submit functionality, to set the user's preference to whatever checkbox state they just used.

[–]magnora7[S] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (6 children)

c.user.pref_sendreplies

Do we have to create this first somewhere?

pref_post_sends_replies=VBoolean("post_sends_replies"),

has to be added to the top of newlink.html or something then? Doesn't that need to be in a python file?

[–][deleted] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (5 children)

Do we have to create this first somewhere?

Yes, see here https://github.com/libertysoft3/reddit-ae/blob/88b6edc4e2361a903215ed57ce4767043f4ef5c3/r2/r2/models/account.py#L166

pref_post_sends_replies=VBoolean("post_sends_replies"),

I don't think we need this at all, this is only to validate form input for the preferences page. "post_sends_replies" would be the form field name, but it doesn't exist.

[–]magnora7[S] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (2 children)

So the final missing piece is hooking into the post submit functionality, to set the user's preference to whatever checkbox state they just used.

That's the exact functionality we have in the preferences page, so I think your code should already accomplish that, as long as c.user.pref_sendreplies is defined correctly as a preference somewhere

[–][deleted] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 1 fun -  (1 child)

I don't know if we're on the same page anymore. I was imagining this with no preferences page interactions. Wanna chat in saiditdev?

[–][deleted] 3 insightful - 1 fun3 insightful - 0 fun4 insightful - 1 fun -  (2 children)

example, adding a boolean preference "pref_chat_enabled". i'd call it "pref_sendreplies" to match the existing "sendreplies" but no biggie.

adding the preference: https://github.com/libertysoft3/reddit-ae/blob/88b6edc4e2361a903215ed57ce4767043f4ef5c3/r2/r2/models/account.py#L166

getting user's preference state:

c.user.pref_chat_enabled # boolean

You will have to do a flush and maybe a restart before the permission gets created.

[–]magnora7[S] 3 insightful - 2 fun3 insightful - 1 fun4 insightful - 2 fun -  (0 children)

Haha that's the exact variable I referenced to make my example I just sent to you. I think we've almost got it here.

[–]magnora7[S] 3 insightful - 1 fun3 insightful - 0 fun4 insightful - 1 fun -  (0 children)

okay I will add the preference right now.