How to disable Incoming Email modal

How should I make this email icon nonclickable?

image

How should I disable this Incoming Email model?

Screenshot 2023-11-28 233500

And how to disable this

Today I Learned that that icon is clickable.

1 Like

Haha yea, it is, annoying :laughing:

Btw Happy Birthday :grin: :star2:

I suspect it’s staff only, just checked on a forum where I don’t have staff, and I cannot click on the icon. (on my phone at least)

Thanks! (though that’s partially timezones, it’s not my birthday here yet :upside_down_face:)

1 Like

I have to see this, thanks for telling me about it. :grinning:

Here It shows a cake icon next to your name haha anyway happy birthday in advance I guess I am the first one to say this :joy:

1 Like

Aa it is only visible to admins so no issues with it.

Anyways, if anyone else like me wants to disable this but can’t find a way here what I did with GPT and it worked great :slight_smile:

<script type="text/discourse-plugin" version="0.8">
  api.onPageChange((url, title) => {
    // Wait for the page to fully load
    Ember.run.scheduleOnce('afterRender', function() {
      // Find and remove all details elements with class "elided"
      var elidedDetailsList = document.querySelectorAll('details.elided');
      elidedDetailsList.forEach(function(elidedDetails) {
        elidedDetails.remove();
      });
    });
  });
</script>

Hi kynic,

onPageChange might be a little too broad for usage (and unreliable if you load/update posts).
You can use decorateCookedElement instead. It’s called for every post-cooked element.

Additionally, here is a way to disable the email indicator. It’s just some hack to not include the HTML. If you are curious, you can see the original code here.

<script type="text/discourse-plugin" version="0.8">
    api.reopenWidget("post-meta-data", {
        html(attrs) {
            if (!attrs.via_email) {
                return this._super(attrs);
            }
          
            // Do not generate "post-email-indicator" widget.
            attrs.via_email = false;
            const html = this._super(attrs);
            attrs.via_email = true;
          
            return html;
        }
    })

    api.decorateCookedElement((element, helper) => {
        if (helper?.getModel().via_email) {
            element.querySelector('details.elided').remove();
        }
        
    }, { onlyStream: true });
</script>

You could also use CSS only to hide them.

.post-info.via-email,
.cooked details.elided {
    display: none;
}
6 Likes

Thanks :grinning:

I removed the post metadata part as I want this email icon to be shown. :slight_smile:

This is what I am using now to remove the content and hide it via CSS just in case.

<script type="text/discourse-plugin" version="0.8">
    api.decorateCookedElement((element, helper) => {
        if (helper?.getModel().via_email) {
            element.querySelector('details.elided').remove();
        }
        
    }, { onlyStream: true });
</script>

.cooked details.elided {
    display: none;
}

Thank you for this code :rocket: :blush:

3 Likes

You’re welcome :slight_smile:

Also, you’re right; only staff can click on the icon! My bad. :smile:

2 Likes

Nice work :slight_smile:

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.