diff options
| author | HJ <spam@hjkos.com> | 2019-01-22 17:46:08 +0000 |
|---|---|---|
| committer | HJ <spam@hjkos.com> | 2019-01-22 17:46:08 +0000 |
| commit | 3a3cf1d48a67c82bb2c94cafb0150b1fa8e4de1a (patch) | |
| tree | 5e39bb41c1e73191b2ff6222eee8720420f13dfd /src/modules/users.js | |
| parent | 7651290e2be72ed35d7582757251eb151fdce953 (diff) | |
| parent | 92dedcd53e56562205e704eea2754f159eb9707d (diff) | |
Merge branch 'favorites' into 'develop'
Add Favorites TL to user profile, add some initial support for MastoAPI
Closes #265 and #262
See merge request pleroma/pleroma-fe!462
Diffstat (limited to 'src/modules/users.js')
| -rw-r--r-- | src/modules/users.js | 66 |
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') + }) }) } } |
