Skip to content

Commit

Permalink
Save context when creating mod notes (#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
eritbh authored Apr 22, 2023
1 parent 743e305 commit 6a0e624
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions extension/data/modules/modnotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,14 @@ function updateModNotesBadge ($badge, note) {
* @param {object} data Data associated with the popup
* @param {string} data.user Name of the relevant user
* @param {string} data.subreddit Name of the relevant subreddit
* @param {string} [data.contextID] Fullname of the item the popup was opened from, used to write note context
* @param {object[]} [data.notes] Note objects for the user, or null/undefined
* @returns {jQuery} The created popup
*/
function createModNotesPopup ({
user,
subreddit,
contextID,
notes,
defaultTabName,
defaultNoteLabel,
Expand Down Expand Up @@ -274,6 +276,7 @@ function createModNotesPopup ({
});
$popup.attr('data-user', user);
$popup.attr('data-subreddit', subreddit);
$popup.attr('data-context-id', contextID);

updateModNotesPopup($popup, {
notes,
Expand Down Expand Up @@ -462,6 +465,7 @@ export default new Module({
TBListener.on('author', async e => {
const subreddit = e.detail.data.subreddit.name;
const author = e.detail.data.author;
const contextID = e.detail.data.comment?.id || e.detail.data.post?.id;

// Deleted users can't have notes
if (author === '[deleted]') {
Expand Down Expand Up @@ -509,6 +513,7 @@ export default new Module({
user: author,
subreddit,
notes,
contextID,
defaultTabName,
defaultNoteLabel,
})
Expand Down Expand Up @@ -551,6 +556,7 @@ export default new Module({
subreddit: $popup.attr('data-subreddit'),
note: $textInput.val(),
label: $labelSelect.val() || undefined,
redditID: $popup.attr('data-context-id'),
});
$textInput.val('');
textFeedback('Note saved', FEEDBACK_POSITIVE);
Expand Down

0 comments on commit 6a0e624

Please sign in to comment.