aboutsummaryrefslogtreecommitdiff
path: root/src/modules/users.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/users.js')
-rw-r--r--src/modules/users.js66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/modules/users.js b/src/modules/users.js
index adbd37dd..d83f0dd8 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -68,6 +68,7 @@ export const mutations = {
},
setUserForNotification (state, notification) {
notification.action.user = state.usersObject[notification.action.user.id]
+ notification.from_profile = state.usersObject[notification.action.user.id]
},
setColor (state, { user: { id }, highlighted }) {
const user = state.usersObject[id]
@@ -149,8 +150,8 @@ const users = {
})
},
addNewNotifications (store, { notifications }) {
- const users = compact(map(notifications, 'from_profile'))
- const notificationIds = compact(notifications.map(_ => String(_.id)))
+ const users = map(notifications, 'from_profile')
+ const notificationIds = notifications.map(_ => _.id)
store.commit('addNewUsers', users)
const notificationsObject = store.rootState.statuses.notifications.idStore
@@ -206,39 +207,38 @@ const users = {
const commit = store.commit
commit('beginLogin')
store.rootState.api.backendInteractor.verifyCredentials(accessToken)
- .then((response) => {
- if (response.ok) {
- response.json()
- .then((user) => {
- // user.credentials = userCredentials
- user.credentials = accessToken
- commit('setCurrentUser', user)
- commit('addNewUsers', [user])
+ .then((data) => {
+ if (!data.error) {
+ const user = data
+ // user.credentials = userCredentials
+ user.credentials = accessToken
+ commit('setCurrentUser', user)
+ commit('addNewUsers', [user])
- getNotificationPermission()
- .then(permission => commit('setNotificationPermission', permission))
+ getNotificationPermission()
+ .then(permission => commit('setNotificationPermission', permission))
- // Set our new backend interactor
- commit('setBackendInteractor', backendInteractorService(accessToken))
+ // Set our new backend interactor
+ commit('setBackendInteractor', backendInteractorService(accessToken))
- if (user.token) {
- store.dispatch('initializeSocket', user.token)
- }
+ if (user.token) {
+ store.dispatch('initializeSocket', user.token)
+ }
- // Start getting fresh tweets.
- store.dispatch('startFetching', 'friends')
+ // Start getting fresh tweets.
+ store.dispatch('startFetching', 'friends')
- // Get user mutes and follower info
- store.rootState.api.backendInteractor.fetchMutes().then((mutedUsers) => {
- each(mutedUsers, (user) => { user.muted = true })
- store.commit('addNewUsers', mutedUsers)
- })
+ // Get user mutes and follower info
+ store.rootState.api.backendInteractor.fetchMutes().then((mutedUsers) => {
+ each(mutedUsers, (user) => { user.muted = true })
+ store.commit('addNewUsers', mutedUsers)
+ })
- // Fetch our friends
- store.rootState.api.backendInteractor.fetchFriends({ id: user.id })
- .then((friends) => commit('addNewUsers', friends))
- })
+ // Fetch our friends
+ store.rootState.api.backendInteractor.fetchFriends({ id: user.id })
+ .then((friends) => commit('addNewUsers', friends))
} else {
+ const response = data.error
// Authentication failed
commit('endLogin')
if (response.status === 401) {
@@ -250,11 +250,11 @@ const users = {
commit('endLogin')
resolve()
})
- .catch((error) => {
- console.log(error)
- commit('endLogin')
- reject('Failed to connect to server, try again')
- })
+ .catch((error) => {
+ console.log(error)
+ commit('endLogin')
+ reject('Failed to connect to server, try again')
+ })
})
}
}