-
-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathAppFilesTab.vue
More file actions
119 lines (100 loc) · 2.79 KB
/
AppFilesTab.vue
File metadata and controls
119 lines (100 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!--
- SPDX-FileCopyrightText: 2024 LibreCode coop and LibreCode contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<div>
<h3 v-if="filesStore.getSubtitle()">
{{ filesStore.getSubtitle() }}
</h3>
<RequestSignatureTab :use-modal="true" />
</div>
</template>
<script>
import { getCurrentUser } from '@nextcloud/auth'
import { generateRemoteUrl } from '@nextcloud/router'
import RequestSignatureTab from '../RightSidebar/RequestSignatureTab.vue'
import { useFilesStore } from '../../store/files.js'
export default {
name: 'AppFilesTab',
components: {
RequestSignatureTab,
},
setup() {
const filesStore = useFilesStore()
return { filesStore }
},
data() {
return {
sidebarTitleObserver: null,
}
},
methods: {
checkAndLoadPendingEnvelope() {
const pendingEnvelope = window.OCA?.Libresign?.pendingEnvelope
if (pendingEnvelope?.id) {
this.filesStore.addFile(pendingEnvelope)
this.filesStore.selectFile(pendingEnvelope.id)
delete window.OCA.Libresign.pendingEnvelope
this.$nextTick(() => {
this.updateSidebarTitle(pendingEnvelope.name)
})
return true
}
return false
},
updateSidebarTitle(envelopeName) {
if (!envelopeName) return
this.disconnectTitleObserver()
const titleElement = document.querySelector('.app-sidebar-header__mainname')
if (titleElement) {
titleElement.textContent = envelopeName
titleElement.setAttribute('title', envelopeName)
this.sidebarTitleObserver = new MutationObserver(() => {
if (titleElement.textContent !== envelopeName) {
titleElement.textContent = envelopeName
titleElement.setAttribute('title', envelopeName)
}
})
this.sidebarTitleObserver.observe(titleElement, {
childList: true,
characterData: true,
subtree: true
})
setTimeout(() => this.disconnectTitleObserver(), 5000)
}
},
disconnectTitleObserver() {
if (this.sidebarTitleObserver) {
console.log('Disconnecting sidebar title observer')
this.sidebarTitleObserver.disconnect()
this.sidebarTitleObserver = null
}
},
async update(fileInfo) {
if (this.checkAndLoadPendingEnvelope()) {
return
}
this.disconnectTitleObserver()
if (this.filesStore.selectedId === fileInfo.id) {
return
}
this.filesStore.addFile({
nodeId: fileInfo.id,
name: fileInfo.name,
file: generateRemoteUrl(`dav/files/${getCurrentUser()?.uid}/${fileInfo.path + '/' + fileInfo.name}`)
.replace(/\/\/$/, '/'),
signers: [],
})
this.filesStore.selectFile(fileInfo.id)
this.$nextTick(() => {
const titleElement = document.querySelector('.app-sidebar-header__mainname')
if (titleElement) {
titleElement.textContent = fileInfo.name
titleElement.setAttribute('title', fileInfo.name)
}
})
},
},
}
</script>