Skip to content

WIP for #716 - "New modmail: Option to always reply as self" #895

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 30 additions & 13 deletions extension/data/modules/newmodmailpro.js
Original file line number Diff line number Diff line change
@@ -48,12 +48,17 @@ export default new Module({
description: 'Open modmail in nightmode',
},
{
id: 'noReplyAsSelf',
type: 'boolean',
default: false,
id: 'modmailReplyAs',
type: 'selector',
values: [
'Leave Unchanged',
'Reply as Myself',
'Reply as the subreddit',
'Create a Private Moderator Note',
],
default: 'leave_unchanged',
advanced: true,
description:
'Automatically switch "reply as" selection away from "Reply as myself" to "Reply as subreddit".',
description: 'Automatically switch "reply as" selection',
},
{
id: 'showModmailPreview',
@@ -90,7 +95,7 @@ export default new Module({
}, ({
modmailnightmode: modMailNightmode,
lastreplytypecheck: lastReplyTypeCheck,
noReplyAsSelf,
modmailReplyAs,
showModmailPreview,
clickableReason,
sourceButton,
@@ -101,11 +106,23 @@ export default new Module({
}) => {
const $body = $('body');

function switchAwayFromReplyAsSelf () {
const current = $('.ThreadViewerReplyForm__replyOptions .FancySelect__valueText').text();
if (current === 'Reply as myself') {
$body.find('.FancySelect__value').click();
$body.find('.FancySelect__option:contains("Reply as the subreddit")').click();
function switchReplyAs () {
// Currently this is only working cosmetically; it'll change the text, but none of the ways I've tried here actually propogate and change
$body.find('#native-select-option').trigger('click');
switch (modmailReplyAs) {
case 'reply_as_myself':
$body.find('#native-select-option').val('null').trigger('click');
break;

case 'reply_as_the_subreddit':
$body.find('#native-select-option').val('isAuthorHidden').trigger('change');
break;

case 'create_a_private_moderator_note':
$body.find('#native-select-option').val('isInternal').trigger('change');
break;
default:
break;
}
}

@@ -248,11 +265,11 @@ export default new Module({
submitReplyForm();
};

if (noReplyAsSelf) {
if (modmailReplyAs !== 'leave_unchanged') {
window.addEventListener('TBNewPage', event => {
if (event.detail.pageType === 'modmailConversation') {
setTimeout(() => {
switchAwayFromReplyAsSelf();
switchReplyAs();
}, 1000);
}
});