Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make profile overlay search accessible via URL options #388

Closed
eritbh opened this issue Oct 6, 2020 · 4 comments · Fixed by #397
Closed

Make profile overlay search accessible via URL options #388

eritbh opened this issue Oct 6, 2020 · 4 comments · Fixed by #397
Assignees
Labels
enhancement New feature or request module: profile
Milestone

Comments

@eritbh
Copy link
Member

eritbh commented Oct 6, 2020

Suggested here. We probably wouldn't want to use a proper query string for this, but doing something similar to the hash fragments RES adds when scrolling through NER pages could probably be doable.

@eritbh eritbh added enhancement New feature or request module: profile labels Oct 6, 2020
@creesch
Copy link
Member

creesch commented Oct 6, 2020

Not sure how suitable our current code is for this but we already have some stuff to deal with hash parameters.

We do have TBHelpers.getHashParameter https://github.com/toolbox-team/reddit-moderator-toolbox/blob/master/extension/data/tbhelpers.js#L625-L641

Modbar uses it to open the settings dialogue https://github.com/toolbox-team/reddit-moderator-toolbox/blob/master/extension/data/modules/modbar.js#L497-L530 (side note, that interval mechanism is a bit odd, we might at one point look at doing that in a different manner possibly hook it into the url change mechanism)

@creesch
Copy link
Member

creesch commented Oct 6, 2020

Thinking about it, it would be great if we could work it into TBNewPage (or at least that area) and make it event based for modules to listen to. Something like TBHashParams.

@creesch
Copy link
Member

creesch commented Oct 6, 2020

To continue my spam (I'll make this the last comment for now), it seems that browser.tabs.onUpdated does also trigger on hash changes which is good. So we can probably include something in the newpage trigger like the code below which is based on how we currently use it as I don't want to change the format because that would break all settings links out there.

if (window.location.hash) {
        const hash = window.location.hash.substring(1);

        // To make sure we only trigger on toolbox hashes we check that the first param starts with `tb`.
        // This because `tbsettings` is already used for settings. 
        if(hash.startsWith('?tb')) {
            const paramObject = {};
            const params = hash.split('&');
            params.forEach(param => {
                const keyval = param.split('=');
                const key = keyval[0].replace('?', ''),
                      val = keyval[1];

                paramObject[key] = val;
  
            });
            window.dispatchEvent(new CustomEvent('TBHashParams', {detail: contextObject}));
        }
}

@creesch
Copy link
Member

creesch commented Oct 13, 2020

As the hashing mechanism is now implemented I figure I'd start work on this. Before I do however I want to properly work out the parameters used. So far I am thinking about the following

  • tbprofile mandatory which will be one of overview, comments or posts.
  • user optional if not given on when on a profile page it will use that user and otherwise give an error message.
  • subreddit optional when present will initiate a profile search on opening of profile.
  • content optional when present will initiate a profile search on opening of profile.

Do we also want a param for sort? I am leaning towards yes as it is an option in makeProfile() anyway.

I also need to take the Always open toolbox profile overlay on reddit profiles. setting in account to make sure it doesn't cause any conflicts there.

Finally in regards to the actual implementation I want to try to avoid adding too much mechanics to specifically make this possible. For example, when initiating search I am planning to input the given params into the actual search fields and submitting the form.

However to tell makeProfile() to init a search I am going to need to add options there.

@creesch creesch self-assigned this Oct 13, 2020
creesch added a commit that referenced this issue Oct 22, 2020
* Basic intial hash param initiated user profile

* Profile search through hash params

* Update extension/data/modules/profile.js

Co-authored-by: Geo <georgej1088@gmail.com>

* Update extension/data/modules/profile.js

Co-authored-by: Geo <georgej1088@gmail.com>

Co-authored-by: Geo <georgej1088@gmail.com>
@eritbh eritbh added this to the v5.5 milestone Dec 10, 2020
eritbh added a commit that referenced this issue Sep 5, 2024
* Basic intial hash param initiated user profile

* Profile search through hash params

* Update extension/data/modules/profile.js

Co-authored-by: Geo <georgej1088@gmail.com>

* Update extension/data/modules/profile.js

Co-authored-by: Geo <georgej1088@gmail.com>

Co-authored-by: Geo <georgej1088@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request module: profile
Projects
None yet
2 participants