KartikTalwar / gmail.js

Gmail JavaScript API
MIT License
3.74k stars 455 forks source link

is_inside_email broken for popout of thread "In new window" #696

Open cancan101 opened 2 years ago

cancan101 commented 2 years ago

When a thread is poped out by clicking the "In new window" button, is_inside_email reports false when run from within the poped out window.

cancan101 commented 2 years ago

I think this can be fixed with something like this (adding a is_popped_out), since the second half of the function works fine:

    api.check.is_inside_email = function() {
        if(api.get.current_page() !== "email" && !api.check.is_preview_pane()  && !api.check.is_popped_out()) {
            return false;
        }

        var items = $(".ii.gt .a3s");
        var ids = [];

        for(var i=0; i<items.length; i++) {
            var mail_id = items[i].getAttribute("class").split(" ")[2];
            if(mail_id !== "undefined" && mail_id !== undefined) {
                ids.push(items[i]);
            }
        }

        return ids.length > 0;
    };

and then is_popped_out just needs to be built to detect the popout

josteink commented 2 years ago

Sounds good to me. PRs welcome!