Skip to content

Commit 0022e49

Browse files
committed
feat: Add experimental option to allow typing during connectivity issues or being offline
Signed-off-by: Julius Knorr <jus@bitgrid.net>
1 parent 0309dce commit 0022e49

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

lib/Service/ConfigService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ public function isRichWorkspaceEnabledForUser(?string $userId): bool {
4646

4747
public function isNotifyPushSyncEnabled(): bool {
4848
return $this->appConfig->getValueBool(Application::APP_NAME, 'notify_push');
49+
}
4950

51+
public function isExperimentalOffilineTypingEnabled(): bool {
52+
return $this->appConfig->getValueBool(Application::APP_NAME, 'experimental_offline_typing');
5053
}
5154

5255
public function isFullWidthEditor(?string $userId): bool {

lib/Service/InitialStateProvider.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ public function provideState(): void {
8383
$this->configService->isNotifyPushSyncEnabled(),
8484
);
8585

86+
$this->initialState->provideInitialState(
87+
'experimental_offline_typing',
88+
$this->configService->isExperimentalOffilineTypingEnabled(),
89+
);
90+
8691
$this->initialState->provideInitialState(
8792
'is_full_width_editor',
8893
$this->configService->isFullWidthEditor($this->userId),

src/components/Editor.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ import { generateRemoteUrl } from '@nextcloud/router'
128128
import { fetchNode } from '../services/WebdavClient.ts'
129129
import SuggestionsBar from './SuggestionsBar.vue'
130130
131+
const experimentalOfflineTyping = loadState('text', 'experimental_offline_typing', false)
132+
131133
export default {
132134
name: 'Editor',
133135
components: {
@@ -592,7 +594,7 @@ export default {
592594
this.document = document
593595
594596
this.syncError = null
595-
const editable = this.editMode && !this.hasConnectionIssue
597+
const editable = this.editMode && (experimentalOfflineTyping || !this.hasConnectionIssue)
596598
if (this.$editor.isEditable !== editable) {
597599
this.$editor.setEditable(editable)
598600
}
@@ -626,7 +628,9 @@ export default {
626628
627629
onError({ type, data }) {
628630
this.$nextTick(() => {
629-
this.$editor?.setEditable(false)
631+
if (!experimentalOfflineTyping) {
632+
this.$editor?.setEditable(false)
633+
}
630634
this.emit('sync-service:error')
631635
})
632636
@@ -687,7 +691,9 @@ export default {
687691
onIdle() {
688692
this.$syncService.close()
689693
this.idle = true
690-
this.readOnly = true
694+
if (!experimentalOfflineTyping) {
695+
this.readOnly = true
696+
}
691697
this.editMode = false
692698
this.$editor.setEditable(this.editMode)
693699
@@ -733,7 +739,9 @@ export default {
733739
this.$providers = []
734740
this.$syncService = null
735741
// disallow editing while still showing the content
736-
this.readOnly = true
742+
if (!experimentalOfflineTyping) {
743+
this.readOnly = true
744+
}
737745
},
738746
739747
async close() {

0 commit comments

Comments
 (0)