Skip to content

Commit a16b5f8

Browse files
committed
misc cleanup
1 parent 96941c8 commit a16b5f8

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

src/features/quote_replies.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { timelineObject } from '../utils/react_props.js';
1414

1515
const storageKey = 'quote_replies.draftLocation';
1616
const buttonClass = 'xkit-quote-replies';
17-
const meatballButtonId = 'quote_replies';
17+
const meatballButtonId = 'quote-replies';
1818
const dropdownButtonClass = 'xkit-quote-replies-dropdown';
1919

2020
const originalPostTagStorageKey = 'quick_tags.preferences.originalPostTag';
@@ -72,10 +72,16 @@ const quoteReply = async (tumblelogName, notificationProps) => {
7272
if (!reply) throw new Error('No replies found on target post.');
7373
if (Math.floor(reply.timestamp) !== timestamp) throw new Error('Reply not found.');
7474

75-
const replyingBlogName = reply.blog.name;
76-
const replyingBlogUuid = reply.blog.uuid;
77-
78-
openQuoteReplyPost({ type, replyingBlogName, replyingBlogUuid, reply, postSummary: targetPostSummary, postUrl, targetBlogUuid: uuid, targetBlogName: tumblelogName });
75+
openQuoteReplyPost({
76+
type,
77+
replyingBlogName: reply.blog.name,
78+
replyingBlogUuid: reply.blog.uuid,
79+
reply,
80+
postSummary: targetPostSummary,
81+
postUrl,
82+
targetBlogUuid: uuid,
83+
targetBlogName: tumblelogName
84+
});
7985
};
8086

8187
const openQuoteReplyPost = async ({ type, replyingBlogName, replyingBlogUuid, postSummary, postUrl, reply, targetBlogUuid, targetBlogName }) => {
@@ -133,8 +139,8 @@ const processNoteProps = ([noteProps, parentNoteProps]) => {
133139
targetBlogName: noteProps.blog.name
134140
};
135141
}
136-
for (const { formatting } of noteProps.note.content) {
137-
for (const { type, blog } of formatting ?? []) {
142+
for (const { formatting = [] } of noteProps.note.content) {
143+
for (const { type, blog } of formatting) {
138144
if (type === 'mention' && userBlogNames.includes(blog.name)) {
139145
return {
140146
type: 'note_mention',

src/main_world/test_parent_element.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default function testParentElement (selector) {
2-
const menuElement = this;
3-
const reactKey = Object.keys(menuElement).find(key => key.startsWith('__reactFiber'));
4-
let fiber = menuElement[reactKey];
2+
const element = this;
3+
const reactKey = Object.keys(element).find(key => key.startsWith('__reactFiber'));
4+
let fiber = element[reactKey];
55

66
while (fiber !== null) {
77
if (fiber.stateNode?.matches?.(selector)) {

src/main_world/unbury_note_props.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ export default function unburyNoteProps () {
33
const reactKey = Object.keys(noteElement).find(key => key.startsWith('__reactFiber'));
44
let fiber = noteElement[reactKey];
55

6-
const results = {};
6+
const resultsByReplyId = {};
77
while (fiber !== null) {
88
const props = fiber.memoizedProps || {};
99
if (typeof props?.note?.replyId === 'string') {
10-
// returns the last set of props corresponding to each replyId, which contains the most information
11-
results[props.note.replyId] = props;
10+
// multiple sets of props correspond to each replyId;
11+
// prefer the last set, as it contains the most information
12+
resultsByReplyId[props.note.replyId] = props;
1213
}
1314
fiber = fiber.return;
1415
}
15-
return Object.values(results);
16+
return Object.values(resultsByReplyId);
1617
}

0 commit comments

Comments
 (0)