benjaffe / chrome-okc-plugin

OkCupid Poly Plugin
MIT License
63 stars 32 forks source link

Make suggest questions mode persistent (issue #88) #89

Closed studgeek closed 10 years ago

studgeek commented 10 years ago

First rough draft at making suggestions persistent (suggestion #88). Its rough and needs cleanup, but shows the idea.

It makes the following changes:

Work still to do:

studgeek commented 10 years ago

I added a couple more commits: The main one Updates the answer parsing code to handle the new question style (that has no their_answer). Fixes answerText, score, weight. I also refactored some duplicated code.

studgeek commented 10 years ago

One thing that needs to be fixed with my code is I am using unscoped keys for localStorage. I had not realized it was shared with page for content scripts. It probably needs to be prefixed.

benjaffe commented 10 years ago

Yes, all stored data should be properties on localStorage.okcp. I also use, .okcpRecentProfiles, or .okcpSettings (which I actually haven't been using)

On Tue, Jun 17, 2014 at 5:46 PM, David Rees notifications@github.com wrote:

One thing that needs to be fixed with my code is I am using unscoped keys for localStorage. I had not realized it was shared with page for content scripts. It probably needs to be prefixed.

— Reply to this email directly or view it on GitHub https://github.com/benjaffe/chrome-okc-plugin/pull/89#issuecomment-46383974 .

Ben Jaffe • Developer, Instructor, GeekSpeak, KUSP 510.545.2365 • benjaffe.me • Github https://github.com/benjaffe/

LinkedIn https://www.linkedin.com/in/benjaffe

benjaffe commented 10 years ago

@studgeek , for adding keys, check out the util I wrote for it -- https://github.com/benjaffe/chrome-okc-plugin/blob/master/plugin/storage.js

_OKCP.storage('messages') // getter
_OKCP.storage('messages', myVar) // setter
studgeek commented 10 years ago

Agreed on everything, good suggestions (and consistency is always important). Will also move it to using its own on/off flag rather than devMode as you suggested elsewhere. I will post comment once I have applied the suggested changes.

benjaffe commented 10 years ago

Sweet, thanks David -- you rock!

On Fri, Jun 20, 2014 at 7:05 PM, David Rees notifications@github.com wrote:

Agreed on everything, good suggestions (and consistency is always important). Will also move it to using its own on/off flag rather than devMode as you suggested elsewhere. I will post comment once I have applied the suggested changes.

— Reply to this email directly or view it on GitHub https://github.com/benjaffe/chrome-okc-plugin/pull/89#issuecomment-46741850 .

Ben Jaffe • Developer, Instructor, GeekSpeak, KUSP 510.545.2365 • benjaffe.me • Github https://github.com/benjaffe/

LinkedIn https://www.linkedin.com/in/benjaffe

studgeek commented 10 years ago

Ok, I think I have all the suggested changes in there. Plus a few more tweaks. FYI, I rebased it to clean up commit history a bit.

benjaffe commented 10 years ago

@studgeek , Can you update the wiki to describe how users suggest questions? I already have a page you can modify. Also, I'm having trouble getting the buttons to show up, even though;

localStorage.okcpDevMode === "true" //true

I should see the buttons on the questions pages right? I'm not seeing them either on other users' questions pages, or my own. Any ideas?

studgeek commented 9 years ago

Sorry I didn't see your comment until now.

I have updated the wiki with the updated instructions.

And suggest mode is working for me in the master branch. Once I run localStorage.setItem("okcpSuggestMode", true) I see the Suggest Question buttons: screen region 2014-08-03 at 17 47 05 And the JSON at the bottom screen region 2014-08-03 at 17 47 30

studgeek commented 9 years ago

Actually, I found a small bug. The Clear Questions button was not visible.

studgeek commented 9 years ago

Pull request #104 makes the Clear Questions button visible. I updated the wiki with that info. clear questions

benjaffe commented 9 years ago

Cool! Yeah, I was just missing localStorage.okcpSuggestQuestions . Awesome, thank you! It'll be published within an hour.

studgeek commented 9 years ago

The original suggestQuestions code generates a "weight" array, but I don't see it used in the questions files. Is weight no longer used and should I take it out of suggestQuestions?

benjaffe commented 9 years ago

It's definitely used for some questions. I didn't integrate it fully in suggest questions because I figured it'd be confusing to most users. I was manually adding the weight when adding the question into the plugin. Sorry for the quick response... On mobile and on the go!

Sent from my phone, so excuse the brevity. On Jan 18, 2015 1:25 PM, "David Rees" notifications@github.com wrote:

The original suggestQuestions code generates a "weight" array, but I don't see it used in the questions files. Is weight no longer used and should I take it out of suggestQuestions?

— Reply to this email directly or view it on GitHub https://github.com/benjaffe/chrome-okc-plugin/pull/89#issuecomment-70426770 .