Skip to content

Commit

Permalink
saveComments: Fix ID (#3546)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsjohnsen authored and erikdesjardins committed Oct 24, 2016
1 parent a4eb495 commit 6264819
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/modules/saveComments.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
isPageType,
niceKeyCode,
watchForElement,
Thing,
} from '../utils';
import { Storage } from '../environment';
import * as KeyboardNav from './keyboardNav';
Expand Down Expand Up @@ -86,17 +87,14 @@ function addSaveLinks(ele = document.body) {
}

function addSaveLinkToComment(commentObj) {
const commentsUL = commentObj.querySelector('ul.flat-list');
const permaLink = commentsUL.querySelector('li.first a.bylink');
const thing = new Thing(commentObj);
const permaLink = thing.getCommentPermalink();

if (!permaLink) return;

// Insert the link right after Reddit Gold's "save" comment link
const userLink = commentObj.querySelector('a.author');
const saveUser = userLink ? userLink.innerText : '[deleted]';

const saveHref = permaLink.href;
const saveID = saveHref.split('/').slice(-1)[0];
const saveID = thing.getFullname().split('_').slice(-1)[0];
const saveUser = thing.getAuthor() || '[deleted]';

const $saveLink = $('<li>');

Expand All @@ -110,7 +108,8 @@ function addSaveLinkToComment(commentObj) {
.data('saveUser', saveUser);
}

const whereToInsert = commentsUL.querySelector('.comment-save-button');
// Insert the link right after Reddit Gold's "save" comment link
const whereToInsert = commentObj.querySelector('.comment-save-button');
$saveLink.insertAfter(whereToInsert);
}

Expand Down Expand Up @@ -277,6 +276,7 @@ async function drawSavedComments() {

function unsaveComment(id, unsaveLink) {
Storage.deletePath('RESmodules.saveComments.savedComments', id);
savedCommentIDs.delete(id);
if ($savedCommentsContent) {
$savedCommentsContent.remove();
drawSavedComments();
Expand Down

0 comments on commit 6264819

Please sign in to comment.