diff options
author | Azul <azul@riseup.net> | 2020-07-09 14:01:01 +0300 |
---|---|---|
committer | Azul <azul@riseup.net> | 2020-08-11 17:09:44 +0300 |
commit | e955b5af377dcb7b3092ba867d11da2253a482dd (patch) | |
tree | 99428323a464625a966f963ff160a4267e5d3d46 /src | |
parent | 7d5f0db033fb7b4becf495e01e3d4760694cf688 (diff) |
fix: use Viewer state to determine current dir
This is more relyable then parsing the window location query for dir:
* ?dir does not change when navigating between files right now
* ?dir is not present when the viewer is used from within other apps.
We used to fallback to the viewer state which solved the latter.
However it is easier and less error prone
to just rely on viewer state in the first place.
Signed-off-by: Azul <azul@riseup.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/helpers/links.js | 3 | ||||
-rw-r--r-- | src/tests/helpers/links.spec.js | 13 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/helpers/links.js b/src/helpers/links.js index 3a2918863..5d7ecbf7e 100644 --- a/src/helpers/links.js +++ b/src/helpers/links.js @@ -58,8 +58,7 @@ const domHref = function(node) { const match = ref.match(/^([^?]*)\?fileId=(\d+)/) if (match) { const [, relPath, id] = match - const currentDir = OC.Util.History.parseUrlQuery().dir - || basedir(OCA.Viewer.state.file) + const currentDir = basedir(OCA.Viewer.state.file) const dir = absolutePath(currentDir, basedir(relPath)) return generateUrl(`/apps/files/?dir=${dir}&openfile=${id}#relPath=${relPath}`) } diff --git a/src/tests/helpers/links.spec.js b/src/tests/helpers/links.spec.js index a72072fd9..426d80f6a 100644 --- a/src/tests/helpers/links.spec.js +++ b/src/tests/helpers/links.spec.js @@ -1,13 +1,14 @@ import { domHref, parseHref } from '../../helpers/links' -global.OC = { - Util: { - History: { - parseUrlQuery: () => ({ - dir: '/Wiki', - }), +global.OCA = { + Viewer: { + state: { + file: '/Wiki/file.md', }, }, +} + +global.OC = { config: {modRewriteWorking: true}, webroot: '' } |