Skip to content

Commit 25243ee

Browse files
committed
Config setting to use boolean instead of string
Signed-off-by: Azri Adam <[email protected]>
1 parent da5f0c5 commit 25243ee

File tree

5 files changed

+12
-16
lines changed

5 files changed

+12
-16
lines changed

lib/Controller/SettingsController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class SettingsController extends Controller
1818
{
1919
public const ACCEPTED_KEYS = [
2020
'workspace_enabled',
21-
'user_text_editor_max_width'
21+
'is_full_width_editor'
2222
];
2323

2424
public function __construct(
@@ -34,7 +34,7 @@ public function __construct(
3434
/**
3535
* @throws \OCP\PreConditionNotMetException
3636
*
37-
* @psalm-return DataResponse<200|400, array{workspace_enabled?: mixed, user_text_editor_max_width?: mixed, message?: 'Invalid config key'}, array<never, never>>
37+
* @psalm-return DataResponse<200|400, array{workspace_enabled?: mixed, is_full_width_editor?: mixed, message?: 'Invalid config key'}, array<never, never>>
3838
*/
3939
#[NoAdminRequired]
4040
public function updateConfig(string $key, int|string $value): DataResponse

lib/Service/ConfigService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public function isNotifyPushSyncEnabled(): bool
5252

5353
}
5454

55-
public function getUserPreferencesTextEditorMaxWidth(?string $userId): string
55+
public function isFullWidthEditor(?string $userId): bool
5656
{
57-
return $this->config->getUserValue($userId, Application::APP_NAME, 'user_text_editor_max_width', '80ch');
57+
return $this->config->getUserValue($userId, Application::APP_NAME, 'is_full_width_editor', '0') === '1';
5858
}
5959
}

lib/Service/InitialStateProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ public function provideState(): void
8282
);
8383

8484
$this->initialState->provideInitialState(
85-
'user_text_editor_max_width',
86-
$this->configService->getUserPreferencesTextEditorMaxWidth($this->userId),
85+
'is_full_width_editor',
86+
$this->configService->isFullWidthEditor($this->userId),
8787
);
8888
}
8989

src/components/Editor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ export default {
321321
}
322322
},
323323
editorMaxWidth() {
324-
return loadState('text', 'user_text_editor_max_width', '80ch')
324+
return loadState('text', 'is_full_width_editor', false) ? '100%' : '80ch'
325325
},
326326
},
327327
watch: {

src/components/Editor/SessionList.vue

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,10 @@ export default {
7070
},
7171
},
7272
data() {
73-
const savedWidth = loadState('text', 'user_text_editor_max_width', '80ch')
73+
const isFullWidth = loadState('text', 'is_full_width_editor', false)
7474
return {
7575
myName: '',
76-
user_text_editor_max_width: savedWidth,
77-
isFullWidth: savedWidth === '100%',
76+
isFullWidth,
7877
}
7978
},
8079
computed: {
@@ -112,15 +111,12 @@ export default {
112111
},
113112
methods: {
114113
onWidthToggle(checked) {
115-
const newWidth = checked ? '100%' : '80ch'
116-
this.user_text_editor_max_width = newWidth
117114
this.isFullWidth = checked
118-
119-
this.$emit('editor-width-change', newWidth)
115+
this.$emit('editor-width-change', checked ? '100%' : '80ch')
120116
121117
axios.post(generateUrl('/apps/text/settings'), {
122-
key: 'user_text_editor_max_width',
123-
value: newWidth,
118+
key: 'is_full_width_editor',
119+
value: checked ? '1' : '0',
124120
})
125121
},
126122
},

0 commit comments

Comments
 (0)