Skip to content

Commit c42de4b

Browse files
committed
partial new notification fix
1 parent 01fe042 commit c42de4b

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

src/features/mutual_checker.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { buildStyle, getTimelineItemWrapper, filterPostElements, getPopoverWrapper } from '../utils/interface.js';
1+
import { buildStyle, getTimelineItemWrapper, filterPostElements, getPopoverWrapper, notificationSelector } from '../utils/interface.js';
22
import { blogData, notificationObject, timelineObject } from '../utils/react_props.js';
33
import { apiFetch } from '../utils/tumblr_helpers.js';
44
import { primaryBlogName } from '../utils/user.js';
@@ -14,7 +14,7 @@ const hiddenAttribute = 'data-mutual-checker-hidden';
1414
const mutualsClass = 'from-mutual';
1515
const postAttributionSelector = `header ${keyToCss('attribution')} a:not(${keyToCss('reblogAttribution', 'rebloggedFromName')} *)`;
1616

17-
const onlyMutualsStyleElement = buildStyle(`${keyToCss('notification')}:not([data-mutuals]) { display: none !important; }`);
17+
const onlyMutualsStyleElement = buildStyle(`${notificationSelector}:not([data-mutuals]) { display: none !important; }`);
1818

1919
const regularPath = 'M593 500q0-45-22.5-64.5T500 416t-66.5 19-18.5 65 18.5 64.5T500 583t70.5-19 22.5-64zm-90 167q-44 0-83.5 18.5t-63 51T333 808v25h334v-25q0-39-22-71.5t-59.5-51T503 667zM166 168l14-90h558l12-78H180q-8 0-51 63l-42 63v209q-19 3-52 3t-33-3q-1 1 0 27 3 53 0 53l32-2q35-1 53 2v258H2l-3 40q-2 41 3 41 42 0 64-1 7-1 21 1v246h756q25 0 42-13 14-10 22-27 5-13 8-28l1-13V275q0-47-3-63-5-24-22.5-34T832 168H166zm667 752H167V754q17 0 38.5-6.5T241 730q16-12 16-26 0-21-33-28-19-4-57-4-3 0-1-51 2-37 1-36V421q88 0 90-48 1-20-33-30-24-6-57-6-4 0-2-44l2-43h635q14 0 22.5 11t8.5 26v543q0 5 4 26 5 30 5 42 1 22-9 22z';
2020
const aprilFoolsPath = 'M858 352q-6-14-8-35-2-12-4-38-3-38-6-54-7-28-22-43t-43-22q-16-3-54-6-26-2-38-4-21-2-34.5-8T619 124q-9-7-28-24-29-25-44-34-24-16-47-16t-47 16q-15 9-44 34-19 17-28 24-16 12-29.5 18t-34.5 8q-12 2-38 4-38 3-54 6-28 7-43 22t-22 43q-3 16-6 54-2 26-4 38-2 21-8 34.5T124 381q-7 9-24 28-25 29-34 44-16 24-16 47t16 47q9 15 34 44 17 19 24 28 12 16 18 29.5t8 34.5q2 12 4 38 3 38 6 54 7 28 22 43t43 22q16 3 54 6 26 2 38 4 21 2 34.5 8t29.5 18q9 7 28 24 29 25 44 34 24 16 47 16t47-16q15-9 44-34 19-17 28-24 16-12 29.5-18t34.5-8q12-2 38-4 38-3 54-6 28-7 43-22t22-43q3-16 6-54 2-26 4-38 2-21 8-34.5t18-29.5q7-9 24-28 25-29 34-44 16-24 16-47t-16-47q-9-15-34-44-17-19-24-28-12-16-18-29zm-119 62L550 706q-10 17-26.5 27T488 745l-11 1q-34 0-59-24L271 584q-26-25-27-60.5t23.5-61.5 60.5-27.5 62 23.5l71 67 132-204q20-30 55-38t65 11.5 37.5 54.5-11.5 65z';
@@ -57,11 +57,9 @@ const styleElement = buildStyle(`
5757
const processNotifications = (notificationElements) => {
5858
notificationElements.forEach(async notificationElement => {
5959
const notification = await notificationObject(notificationElement);
60-
if (notification) {
61-
const { mutuals } = notification;
62-
if (mutuals) {
63-
notificationElement.dataset.mutuals = mutuals;
64-
}
60+
61+
if (notification?.mutuals || notification?.title?.relationshipLabel === 'mutuals') {
62+
notificationElement.setAttribute('data-mutuals', '');
6563
}
6664
});
6765
};

src/features/notificationblock.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@ const buildCss = () => `:is(${blockedPostTargetIDs.map(rootId => `[data-target-r
2323
const processNotifications = (notificationElements) => {
2424
notificationElements.forEach(async notificationElement => {
2525
const notification = await notificationObject(notificationElement);
26-
if (notification !== undefined) {
26+
if (notification?.targetRootPostId || notification?.targetPostId) {
2727
const { targetRootPostId, targetPostId } = notification;
2828
notificationElement.dataset.targetRootPostId = targetRootPostId || targetPostId;
29+
} else if (notification?.actions) {
30+
// const postId = notification.actions.longTap.meta.postId;
31+
const postId = Object.values(notification.actions).map(action => action?.meta?.postId).find(Boolean);
32+
33+
console.log(postId);
34+
// hm. I guess we do an api fetch here now.
2935
}
3036
});
3137
};

src/features/quote_replies.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ button.xkit-quote-replies-dropdown {
3434
transform: scale(0);
3535
}
3636

37-
:is(:hover, :focus-within) > button.xkit-quote-replies svg {
37+
/* temporary. this probably needs keyToCss */
38+
[aria-label="Notification"]:is(:hover, :focus-within) button.xkit-quote-replies svg,
39+
[aria-label="Notification"]:is(:hover, :focus-within) + div button.xkit-quote-replies svg {
3840
opacity: 1;
3941
transform: scale(1);
4042
}

src/features/quote_replies.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const dropdownButtonClass = 'xkit-quote-replies-dropdown';
1616

1717
const originalPostTagStorageKey = 'quick_tags.preferences.originalPostTag';
1818

19-
const activitySelector = `${keyToCss('notification')} > ${keyToCss('activity')}`;
19+
const activitySelector = `:is(${keyToCss('notification')} > ${keyToCss('activity')}, ${keyToCss('activityContent')})`;
2020

2121
const dropdownSelector = '[role="tabpanel"] *';
2222

@@ -31,8 +31,9 @@ const processNotifications = notifications => notifications.forEach(async notifi
3131
notification
3232
);
3333

34-
if (!['reply', 'reply_to_comment', 'note_mention'].includes(notificationProps.type)) return;
35-
if (notificationProps.community) return;
34+
if (!['reply', 'reply_to_comment', 'note_mention'].includes(notificationProps.type === 'generic' ? notificationProps.subtype : notificationProps.type)) return;
35+
36+
if (notificationProps.community) return; // need a new way to determine this!
3637

3738
const activityElement = notification.querySelector(activitySelector);
3839
if (!activityElement) return;
@@ -46,7 +47,7 @@ const processNotifications = notifications => notifications.forEach(async notifi
4647
{
4748
click () {
4849
this.disabled = true;
49-
quoteReply(tumblelogName, notificationProps)
50+
quoteReply(tumblelogName /* how do we get this information now? */)
5051
.catch(showErrorModal)
5152
.finally(() => { this.disabled = false; });
5253
}

src/utils/interface.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { timelineSelector } from './timeline_id.js';
44

55
export const postSelector = '[tabindex="-1"][data-id]';
66
export const blogViewSelector = '[style*="--blog-title-color"] *';
7-
export const notificationSelector = `${keyToCss('notification')}[role="listitem"]`;
7+
export const notificationSelector = `:is(${keyToCss('notification')}[role="listitem"], ${keyToCss('activityItem')})`;
88

99
const listTimelineObjectSelector = keyToCss('listTimelineObject');
1010
const cellSelector = keyToCss('cell');

0 commit comments

Comments
 (0)