Skip to content

Commit 029620d

Browse files
committed
chore: fixed selected option gridview
Signed-off-by: Crisciany Souza <criscianysilva1997@gmail.com>
1 parent 8770d14 commit 029620d

3 files changed

Lines changed: 7 additions & 28 deletions

File tree

lib/Service/AccountService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ public function getConfig(?IUser $user = null): array {
233233
$info['hasSignatureFile'] = $this->hasSignatureFile($user);
234234
$info['phoneNumber'] = $this->getPhoneNumber($user);
235235
$info['isApprover'] = $this->validateHelper->userCanApproveValidationDocuments($user, false);
236+
$info['grid_view'] = $this->appConfig->getValueBool(Application::APP_ID, 'grid_view', false);
236237
return $info;
237238
}
238239

src/store/modules/settings.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export default {
1616
identificationDocumentsFlow: false,
1717
isApprover: false,
1818
phoneNumber: '',
19+
grid_view: false,
20+
1921
},
2022
...(libresignState?.settings || {}),
2123
},

src/store/userconfig.js

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,22 @@
44
*/
55

66
import { defineStore } from 'pinia'
7-
import { set } from 'vue'
8-
import { generateUrl } from '@nextcloud/router'
9-
import axios from '@nextcloud/axios'
10-
import { emit, subscribe } from '@nextcloud/event-bus'
7+
import { loadState } from '@nextcloud/initial-state'
118

129
export const useUserConfigStore = defineStore('userconfig', {
1310
state: () => ({
14-
grid_view: true, // valor inicial, mas será sobrescrito pelo servidor
11+
grid_view: loadState('libresign', 'config', { grid_view: false }).grid_view,
1512
}),
1613
actions: {
1714
onUpdate(key, value) {
18-
set(this, key, value)
15+
this[key] = value
1916
},
2017

2118
async update(key, value) {
22-
const oldValue = this[key]
2319
this.onUpdate(key, value)
2420

25-
try {
26-
const response = await axios.put(
27-
generateUrl('/apps/files/api/v1/config/{key}', { key }),
28-
{ value },
29-
)
30-
31-
if (response?.data?.value !== undefined) {
32-
this.onUpdate(key, response.data.value)
33-
}
34-
35-
emit('files:config:updated', { key, value })
36-
} catch (error) {
37-
console.error('Erro ao salvar configuração:', error)
38-
this.onUpdate(key, oldValue)
39-
}
21+
OCP.AppConfig.setValue('libresign', 'grid_view', value)
4022
},
4123

42-
initListeners() {
43-
console.log('Initializing user config listeners...')
44-
subscribe('files:config:updated', ({ key, value }) => {
45-
this.onUpdate(key, value)
46-
})
47-
},
4824
},
4925
})

0 commit comments

Comments
 (0)