Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add experimental option to allow typing during connectivity issues or being offline #6933

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ public function isRichWorkspaceEnabledForUser(?string $userId): bool {

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

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

public function isFullWidthEditor(?string $userId): bool {
Expand Down
5 changes: 5 additions & 0 deletions lib/Service/InitialStateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public function provideState(): void {
$this->configService->isNotifyPushSyncEnabled(),
);

$this->initialState->provideInitialState(
'experimental_offline_typing',
$this->configService->isExperimentalOffilineTypingEnabled(),
);

$this->initialState->provideInitialState(
'is_full_width_editor',
$this->configService->isFullWidthEditor($this->userId),
Expand Down
16 changes: 12 additions & 4 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@
import { generateRemoteUrl } from '@nextcloud/router'
import { fetchNode } from '../services/WebdavClient.ts'

const experimentalOfflineTyping = loadState('text', 'experimental_offline_typing', false)

Check warning on line 130 in src/components/Editor.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor.vue#L130

Added line #L130 was not covered by tests

export default {
name: 'Editor',
components: {
Expand Down Expand Up @@ -592,7 +594,7 @@
this.document = document

this.syncError = null
const editable = this.editMode && !this.hasConnectionIssue
const editable = this.editMode && (experimentalOfflineTyping || !this.hasConnectionIssue)

Check warning on line 597 in src/components/Editor.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor.vue#L597

Added line #L597 was not covered by tests
if (this.$editor.isEditable !== editable) {
this.$editor.setEditable(editable)
}
Expand Down Expand Up @@ -626,7 +628,9 @@

onError({ type, data }) {
this.$nextTick(() => {
this.$editor?.setEditable(false)
if (!experimentalOfflineTyping) {
this.$editor?.setEditable(false)
}

Check warning on line 633 in src/components/Editor.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor.vue#L631-L633

Added lines #L631 - L633 were not covered by tests
this.emit('sync-service:error')
})

Expand Down Expand Up @@ -687,7 +691,9 @@
onIdle() {
this.$syncService.close()
this.idle = true
this.readOnly = true
if (!experimentalOfflineTyping) {
this.readOnly = true
}

Check warning on line 696 in src/components/Editor.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor.vue#L694-L696

Added lines #L694 - L696 were not covered by tests
this.editMode = false
this.$editor.setEditable(this.editMode)

Expand Down Expand Up @@ -733,7 +739,9 @@
this.$providers = []
this.$syncService = null
// disallow editing while still showing the content
this.readOnly = true
if (!experimentalOfflineTyping) {
this.readOnly = true
}

Check warning on line 744 in src/components/Editor.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor.vue#L742-L744

Added lines #L742 - L744 were not covered by tests
},

async close() {
Expand Down
Loading