Skip to content

Commit 6a0e624

Browse files
authored
Save context when creating mod notes (#746)
1 parent 743e305 commit 6a0e624

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

extension/data/modules/modnotes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,14 @@ function updateModNotesBadge ($badge, note) {
205205
* @param {object} data Data associated with the popup
206206
* @param {string} data.user Name of the relevant user
207207
* @param {string} data.subreddit Name of the relevant subreddit
208+
* @param {string} [data.contextID] Fullname of the item the popup was opened from, used to write note context
208209
* @param {object[]} [data.notes] Note objects for the user, or null/undefined
209210
* @returns {jQuery} The created popup
210211
*/
211212
function createModNotesPopup ({
212213
user,
213214
subreddit,
215+
contextID,
214216
notes,
215217
defaultTabName,
216218
defaultNoteLabel,
@@ -274,6 +276,7 @@ function createModNotesPopup ({
274276
});
275277
$popup.attr('data-user', user);
276278
$popup.attr('data-subreddit', subreddit);
279+
$popup.attr('data-context-id', contextID);
277280

278281
updateModNotesPopup($popup, {
279282
notes,
@@ -462,6 +465,7 @@ export default new Module({
462465
TBListener.on('author', async e => {
463466
const subreddit = e.detail.data.subreddit.name;
464467
const author = e.detail.data.author;
468+
const contextID = e.detail.data.comment?.id || e.detail.data.post?.id;
465469

466470
// Deleted users can't have notes
467471
if (author === '[deleted]') {
@@ -509,6 +513,7 @@ export default new Module({
509513
user: author,
510514
subreddit,
511515
notes,
516+
contextID,
512517
defaultTabName,
513518
defaultNoteLabel,
514519
})
@@ -551,6 +556,7 @@ export default new Module({
551556
subreddit: $popup.attr('data-subreddit'),
552557
note: $textInput.val(),
553558
label: $labelSelect.val() || undefined,
559+
redditID: $popup.attr('data-context-id'),
554560
});
555561
$textInput.val('');
556562
textFeedback('Note saved', FEEDBACK_POSITIVE);

0 commit comments

Comments
 (0)