aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/config.js2
-rw-r--r--src/modules/instance.js1
-rw-r--r--src/modules/statuses.js2
-rw-r--r--src/modules/users.js28
4 files changed, 30 insertions, 3 deletions
diff --git a/src/modules/config.js b/src/modules/config.js
index ccfd0190..c9528f6f 100644
--- a/src/modules/config.js
+++ b/src/modules/config.js
@@ -24,7 +24,7 @@ const defaultState = {
likes: true,
repeats: true
},
- webPushNotifications: true,
+ webPushNotifications: false,
muteWords: [],
highlight: {},
interfaceLanguage: browserLocale,
diff --git a/src/modules/instance.js b/src/modules/instance.js
index 342bc9ac..546d2cc4 100644
--- a/src/modules/instance.js
+++ b/src/modules/instance.js
@@ -27,6 +27,7 @@ const defaultState = {
loginMethod: 'password',
nsfwCensorImage: undefined,
vapidPublicKey: undefined,
+ noAttachmentLinks: false,
// Nasty stuff
pleromaBackend: true,
diff --git a/src/modules/statuses.js b/src/modules/statuses.js
index 8c2d36bc..dccccf72 100644
--- a/src/modules/statuses.js
+++ b/src/modules/statuses.js
@@ -27,6 +27,7 @@ export const defaultState = {
maxId: 0,
minId: Number.POSITIVE_INFINITY,
data: [],
+ idStore: {},
error: false
},
favorites: new Set(),
@@ -307,6 +308,7 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot
}
state.notifications.data.push(result)
+ state.notifications.idStore[notification.id] = result
if ('Notification' in window && window.Notification.permission === 'granted') {
const title = action.user.name
diff --git a/src/modules/users.js b/src/modules/users.js
index 13d3f26e..2f05ed3f 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -1,7 +1,7 @@
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
import { compact, map, each, merge } from 'lodash'
import { set } from 'vue'
-import registerPushNotifications from '../services/push/push.js'
+import { registerPushNotifications, unregisterPushNotifications } from '../services/push/push.js'
import oauthApi from '../services/new_api/oauth'
import { humanizeErrors } from './errors'
@@ -66,6 +66,9 @@ export const mutations = {
setUserForStatus (state, status) {
status.user = state.usersObject[status.user.id]
},
+ setUserForNotification (state, notification) {
+ notification.action.user = state.usersObject[notification.action.user.id]
+ },
setColor (state, { user: { id }, highlighted }) {
const user = state.usersObject[id]
set(user, 'highlight', highlighted)
@@ -113,8 +116,14 @@ const users = {
const token = store.state.currentUser.credentials
const vapidPublicKey = store.rootState.instance.vapidPublicKey
const isEnabled = store.rootState.config.webPushNotifications
+ const notificationVisibility = store.rootState.config.notificationVisibility
- registerPushNotifications(isEnabled, vapidPublicKey, token)
+ registerPushNotifications(isEnabled, vapidPublicKey, token, notificationVisibility)
+ },
+ unregisterPushNotifications (store) {
+ const token = store.state.currentUser.credentials
+
+ unregisterPushNotifications(token)
},
addNewStatuses (store, { statuses }) {
const users = map(statuses, 'user')
@@ -131,6 +140,21 @@ const users = {
store.commit('setUserForStatus', status)
})
},
+ addNewNotifications (store, { notifications }) {
+ const users = compact(map(notifications, 'from_profile'))
+ const notificationIds = compact(notifications.map(_ => String(_.id)))
+ store.commit('addNewUsers', users)
+
+ const notificationsObject = store.rootState.statuses.notifications.idStore
+ const relevantNotifications = Object.entries(notificationsObject)
+ .filter(([k, val]) => notificationIds.includes(k))
+ .map(([k, val]) => val)
+
+ // Reconnect users to notifications
+ each(relevantNotifications, (notification) => {
+ store.commit('setUserForNotification', notification)
+ })
+ },
async signUp (store, userInfo) {
store.commit('signUpPending')