summaryrefslogtreecommitdiffstats
path: root/src/store
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2020-10-09 18:16:40 +0200
committerRobin Appelman <robin@icewind.nl>2020-10-12 17:03:49 +0200
commit2ef6613857e3f11c017a516aa06871665b203ddb (patch)
tree1366735c8b499ef98a8fec72232d1caebfd04c24 /src/store
parent6ec6fc50f1e798b2243bf38fce0345572c1140d2 (diff)
migrate away from depricated OC.generateUrl
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'src/store')
-rw-r--r--src/store/account.js13
-rw-r--r--src/store/timeline.js23
2 files changed, 19 insertions, 17 deletions
diff --git a/src/store/account.js b/src/store/account.js
index 2ece11e0..91d7b272 100644
--- a/src/store/account.js
+++ b/src/store/account.js
@@ -22,6 +22,7 @@
import axios from '@nextcloud/axios'
import Vue from 'vue'
+import { generateUrl } from '@nextcloud/router'
const state = {
currentAccount: {},
@@ -108,7 +109,7 @@ const getters = {
const actions = {
fetchAccountInfo(context, account) {
- return axios.get(OC.generateUrl(`apps/social/api/v1/global/account/info?account=${account}`)).then((response) => {
+ return axios.get(generateUrl(`apps/social/api/v1/global/account/info?account=${account}`)).then((response) => {
context.commit('addAccount', { actorId: response.data.result.account.id, data: response.data.result.account })
return response.data.result.account
}).catch(() => {
@@ -116,7 +117,7 @@ const actions = {
})
},
fetchPublicAccountInfo(context, uid) {
- return axios.get(OC.generateUrl(`apps/social/api/v1/account/${uid}/info`)).then((response) => {
+ return axios.get(generateUrl(`apps/social/api/v1/account/${uid}/info`)).then((response) => {
context.commit('addAccount', { actorId: response.data.result.account.id, data: response.data.result.account })
return response.data.result.account
}).catch(() => {
@@ -128,7 +129,7 @@ const actions = {
dispatch('fetchAccountInfo', account)
},
followAccount(context, { currentAccount, accountToFollow }) {
- return axios.put(OC.generateUrl('/apps/social/api/v1/current/follow?account=' + accountToFollow)).then((response) => {
+ return axios.put(generateUrl('/apps/social/api/v1/current/follow?account=' + accountToFollow)).then((response) => {
if (response.data.status === -1) {
return Promise.reject(response)
}
@@ -141,7 +142,7 @@ const actions = {
},
unfollowAccount(context, { currentAccount, accountToUnfollow }) {
- return axios.delete(OC.generateUrl('/apps/social/api/v1/current/follow?account=' + accountToUnfollow)).then((response) => {
+ return axios.delete(generateUrl('/apps/social/api/v1/current/follow?account=' + accountToUnfollow)).then((response) => {
if (response.data.status === -1) {
return Promise.reject(response)
}
@@ -157,7 +158,7 @@ const actions = {
// TODO: fetching followers/following information of remotes is currently not supported
const parts = account.split('@')
const uid = (parts.length === 2 ? parts[0] : account)
- axios.get(OC.generateUrl(`apps/social/api/v1/account/${uid}/followers`)).then((response) => {
+ axios.get(generateUrl(`apps/social/api/v1/account/${uid}/followers`)).then((response) => {
context.commit('addFollowers', { account, data: response.data.result })
})
},
@@ -165,7 +166,7 @@ const actions = {
// TODO: fetching followers/following information of remotes is currently not supported
const parts = account.split('@')
const uid = (parts.length === 2 ? parts[0] : account)
- axios.get(OC.generateUrl(`apps/social/api/v1/account/${uid}/following`)).then((response) => {
+ axios.get(generateUrl(`apps/social/api/v1/account/${uid}/following`)).then((response) => {
context.commit('addFollowing', { account, data: response.data.result })
})
}
diff --git a/src/store/timeline.js b/src/store/timeline.js
index 5275ea55..e61a1219 100644
--- a/src/store/timeline.js
+++ b/src/store/timeline.js
@@ -24,6 +24,7 @@
import Logger from '../logger'
import axios from '@nextcloud/axios'
import Vue from 'vue'
+import { generateUrl } from '@nextcloud/router'
const state = {
timeline: {},
@@ -118,7 +119,7 @@ const actions = {
},
post(context, post) {
return new Promise((resolve, reject) => {
- axios.post(OC.generateUrl('apps/social/api/v1/post'), { data: post }).then((response) => {
+ axios.post(generateUrl('apps/social/api/v1/post'), { data: post }).then((response) => {
// eslint-disable-next-line no-console
console.log('Post created with token ' + response.data.result.token)
resolve(response)
@@ -130,7 +131,7 @@ const actions = {
})
},
postDelete(context, post) {
- return axios.delete(OC.generateUrl(`apps/social/api/v1/post?id=${post.id}`)).then((response) => {
+ return axios.delete(generateUrl(`apps/social/api/v1/post?id=${post.id}`)).then((response) => {
context.commit('removePost', post)
// eslint-disable-next-line no-console
console.log('Post deleted with token ' + response.data.result.token)
@@ -141,7 +142,7 @@ const actions = {
},
postLike(context, { post, parentAnnounce }) {
return new Promise((resolve, reject) => {
- axios.post(OC.generateUrl(`apps/social/api/v1/post/like?postId=${post.id}`)).then((response) => {
+ axios.post(generateUrl(`apps/social/api/v1/post/like?postId=${post.id}`)).then((response) => {
context.commit('likePost', { post, parentAnnounce })
resolve(response)
}).catch((error) => {
@@ -152,7 +153,7 @@ const actions = {
})
},
postUnlike(context, { post, parentAnnounce }) {
- return axios.delete(OC.generateUrl(`apps/social/api/v1/post/like?postId=${post.id}`)).then((response) => {
+ return axios.delete(generateUrl(`apps/social/api/v1/post/like?postId=${post.id}`)).then((response) => {
context.commit('unlikePost', { post, parentAnnounce })
// Remove post from list if we are in the 'liked' timeline
if (state.type === 'liked') {
@@ -165,7 +166,7 @@ const actions = {
},
postBoost(context, { post, parentAnnounce }) {
return new Promise((resolve, reject) => {
- axios.post(OC.generateUrl(`apps/social/api/v1/post/boost?postId=${post.id}`)).then((response) => {
+ axios.post(generateUrl(`apps/social/api/v1/post/boost?postId=${post.id}`)).then((response) => {
context.commit('boostPost', { post, parentAnnounce })
// eslint-disable-next-line no-console
console.log('Post boosted with token ' + response.data.result.token)
@@ -178,7 +179,7 @@ const actions = {
})
},
postUnBoost(context, { post, parentAnnounce }) {
- return axios.delete(OC.generateUrl(`apps/social/api/v1/post/boost?postId=${post.id}`)).then((response) => {
+ return axios.delete(generateUrl(`apps/social/api/v1/post/boost?postId=${post.id}`)).then((response) => {
context.commit('unboostPost', { post, parentAnnounce })
// eslint-disable-next-line no-console
console.log('Boost deleted with token ' + response.data.result.token)
@@ -199,13 +200,13 @@ const actions = {
// Compute URl to get the data
let url = ''
if (state.type === 'account') {
- url = OC.generateUrl(`apps/social/api/v1/account/${state.account}/stream?limit=25&since=` + sinceTimestamp)
+ url = generateUrl(`apps/social/api/v1/account/${state.account}/stream?limit=25&since=` + sinceTimestamp)
} else if (state.type === 'tags') {
- url = OC.generateUrl(`apps/social/api/v1/stream/tag/${state.params.tag}?limit=25&since=` + sinceTimestamp)
+ url = generateUrl(`apps/social/api/v1/stream/tag/${state.params.tag}?limit=25&since=` + sinceTimestamp)
} else if (state.type === 'single-post') {
- url = OC.generateUrl(`apps/social/local/v1/post/replies?id=${state.params.id}&limit=5&since=` + sinceTimestamp)
+ url = generateUrl(`apps/social/local/v1/post/replies?id=${state.params.id}&limit=5&since=` + sinceTimestamp)
} else {
- url = OC.generateUrl(`apps/social/api/v1/stream/${state.type}?limit=25&since=` + sinceTimestamp)
+ url = generateUrl(`apps/social/api/v1/stream/${state.type}?limit=25&since=` + sinceTimestamp)
}
// Get the data and add them to the timeline
@@ -220,7 +221,7 @@ const actions = {
// Also load replies when displaying a single post timeline
if (state.type === 'single-post') {
result.push(response.data)
- // axios.get(OC.generateUrl(``)).then((response) => {
+ // axios.get(generateUrl(``)).then((response) => {
// if (response.status !== -1) {
// result.concat(response.data.result)
// }