aboutsummaryrefslogtreecommitdiff
path: root/src/services
diff options
context:
space:
mode:
Diffstat (limited to 'src/services')
-rw-r--r--src/services/notifications_fetcher/notifications_fetcher.service.js5
-rw-r--r--src/services/offset_finder/offset_finder.service.js31
2 files changed, 36 insertions, 0 deletions
diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js
index f9ec3f6e..b6c4cf80 100644
--- a/src/services/notifications_fetcher/notifications_fetcher.service.js
+++ b/src/services/notifications_fetcher/notifications_fetcher.service.js
@@ -10,6 +10,11 @@ const fetchAndUpdate = ({ store, credentials, older = false }) => {
const args = { credentials }
const rootState = store.rootState || store.state
const timelineData = rootState.statuses.notifications
+ const hideMutedPosts = typeof rootState.config.hideMutedPosts === 'undefined'
+ ? rootState.instance.hideMutedPosts
+ : rootState.config.hideMutedPosts
+
+ args['withMuted'] = !hideMutedPosts
args['timeline'] = 'notifications'
if (older) {
diff --git a/src/services/offset_finder/offset_finder.service.js b/src/services/offset_finder/offset_finder.service.js
new file mode 100644
index 00000000..9034f8c8
--- /dev/null
+++ b/src/services/offset_finder/offset_finder.service.js
@@ -0,0 +1,31 @@
+export const findOffset = (child, parent, { top = 0, left = 0 } = {}, ignorePadding = true) => {
+ const result = {
+ top: top + child.offsetTop,
+ left: left + child.offsetLeft
+ }
+ if (!ignorePadding && child !== window) {
+ const { topPadding, leftPadding } = findPadding(child)
+ result.top += ignorePadding ? 0 : topPadding
+ result.left += ignorePadding ? 0 : leftPadding
+ }
+
+ if (child.offsetParent && (parent === window || parent.contains(child.offsetParent) || parent === child.offsetParent)) {
+ return findOffset(child.offsetParent, parent, result, false)
+ } else {
+ if (parent !== window) {
+ const { topPadding, leftPadding } = findPadding(parent)
+ result.top += topPadding
+ result.left += leftPadding
+ }
+ return result
+ }
+}
+
+const findPadding = (el) => {
+ const topPaddingStr = window.getComputedStyle(el)['padding-top']
+ const topPadding = Number(topPaddingStr.substring(0, topPaddingStr.length - 2))
+ const leftPaddingStr = window.getComputedStyle(el)['padding-left']
+ const leftPadding = Number(leftPaddingStr.substring(0, leftPaddingStr.length - 2))
+
+ return { topPadding, leftPadding }
+}