Skip to content

Commit 673f4a3

Browse files
committed
Adjust saving annotations in public pages to changes in Nextcloud 31
In Nextcloud 31 the "sharingToken" element that was used to know the token of the share was removed and replaced with data provided by the initial state API. However, rather than directly getting the value using the initial state API, the token is now got using the @nextcloud/sharing library, which is expected to handle any future change. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
1 parent ae23a76 commit 673f4a3

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

src/services/uploadPdfFile.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import { getRequestToken } from '@nextcloud/auth'
66
import axios from '@nextcloud/axios'
77

8-
import { getRootPath, getToken } from '../utils/davUtils.js'
8+
import { getRootPath } from '../utils/davUtils.js'
9+
import { getSharingToken } from '@nextcloud/sharing/public'
910

1011
/**
1112
* Upload the given contents of a PDF file to the given filename.
@@ -36,11 +37,11 @@ export default async function(filename, data) {
3637
requesttoken: getRequestToken(),
3738
},
3839
}
39-
if (getToken()) {
40+
if (getSharingToken()) {
4041
requestConfig.auth = {
4142
// Password is not needed due to "public_link_authenticated" being
4243
// set in the session when the share was loaded.
43-
username: getToken(),
44+
username: getSharingToken(),
4445
}
4546
}
4647

src/utils/davUtils.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,3 @@ export const getUserRoot = function() {
3636
export const isPublic = function() {
3737
return !getCurrentUser()
3838
}
39-
40-
/**
41-
* Get the current share link token
42-
*/
43-
export const getToken = function() {
44-
const tokenInput = document.getElementById('sharingToken')
45-
return tokenInput && tokenInput.value
46-
}

0 commit comments

Comments
 (0)