Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVinicius Reis <vinicius.reis@nextcloud.com>2022-04-26 17:21:39 +0300
committerVinicius Reis <vinicius.reis@nextcloud.com>2022-04-26 21:21:13 +0300
commita63535a9369a00a6c4907c1a57788997dabafdc3 (patch)
tree5c26bf0fda525ee21b86af00a65c55dd677c7cf5 /src
parent3b1b12299b7863cbac42166213811d7aab07125f (diff)
⚡️ (#2323): inject SyncService instance
Vinicius Reis <vinicius.reis@nextcloud.com>
Diffstat (limited to 'src')
-rw-r--r--src/components/EditorWrapper.provider.js7
-rw-r--r--src/components/EditorWrapper.vue13
-rw-r--r--src/components/GuestNameDialog.vue14
-rw-r--r--src/components/MenuBar.vue5
4 files changed, 20 insertions, 19 deletions
diff --git a/src/components/EditorWrapper.provider.js b/src/components/EditorWrapper.provider.js
index e711b5352..c19ebdc0d 100644
--- a/src/components/EditorWrapper.provider.js
+++ b/src/components/EditorWrapper.provider.js
@@ -1,6 +1,13 @@
export const EDITOR = Symbol('tiptap:editor')
+export const SYNC_SERVICE = Symbol('sync:service')
+
export const useEditorMixin = {
inject: {
$editor: { from: EDITOR, default: null },
},
}
+export const useSyncServiceMixin = {
+ inject: {
+ $syncService: { from: SYNC_SERVICE, default: null },
+ },
+}
diff --git a/src/components/EditorWrapper.vue b/src/components/EditorWrapper.vue
index ca8d086ef..913528229 100644
--- a/src/components/EditorWrapper.vue
+++ b/src/components/EditorWrapper.vue
@@ -46,7 +46,6 @@
@image-drop="onEditorDrop">
<MenuBar v-if="renderMenus"
ref="menubar"
- :sync-service="$syncService"
:file-path="relativePath"
:file-id="fileId"
:is-rich-editor="isRichEditor"
@@ -62,7 +61,7 @@
{{ lastSavedStatus }}
</div>
<SessionList :sessions="filteredSessions">
- <GuestNameDialog v-if="isPublic && currentSession.guestName" :sync-service="$syncService" />
+ <GuestNameDialog v-if="isPublic && currentSession.guestName" />
</SessionList>
</div>
<slot name="header" />
@@ -93,7 +92,7 @@ import escapeHtml from 'escape-html'
import moment from '@nextcloud/moment'
import { showError } from '@nextcloud/dialogs'
-import { EDITOR } from './EditorWrapper.provider'
+import { EDITOR, SYNC_SERVICE } from './EditorWrapper.provider'
import { SyncService, ERROR_TYPE, IDLE_TIMEOUT } from './../services/SyncService'
import { endpointUrl, getRandomGuestName } from './../helpers'
@@ -157,6 +156,12 @@ export default {
},
})
+ Object.defineProperty(val, SYNC_SERVICE, {
+ get: () => {
+ return this.$syncService
+ },
+ })
+
return val
},
props: {
@@ -200,8 +205,6 @@ export default {
data() {
return {
IDLE_TIMEOUT,
- /** @type {SyncService} */
- syncService: null,
document: null,
sessions: [],
diff --git a/src/components/GuestNameDialog.vue b/src/components/GuestNameDialog.vue
index 624c8d069..77b4cc03a 100644
--- a/src/components/GuestNameDialog.vue
+++ b/src/components/GuestNameDialog.vue
@@ -35,6 +35,7 @@
import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip'
import Avatar from '@nextcloud/vue/dist/Components/Avatar'
import { generateUrl } from '@nextcloud/router'
+import { useSyncServiceMixin } from './EditorWrapper.provider'
export default {
name: 'GuestNameDialog',
@@ -44,12 +45,7 @@ export default {
directives: {
tooltip: Tooltip,
},
- props: {
- syncService: {
- type: Object,
- default: null,
- },
- },
+ mixins: [useSyncServiceMixin],
data() {
return {
guestName: '',
@@ -69,13 +65,13 @@ export default {
},
},
beforeMount() {
- this.guestName = this.syncService.session.guestName
+ this.guestName = this.$syncService.session.guestName
this.updateBufferedGuestName()
},
methods: {
setGuestName() {
- const previousGuestName = this.syncService.session.guestName
- this.syncService.updateSession(this.guestName).then(() => {
+ const previousGuestName = this.$syncService.session.guestName
+ this.$syncService.updateSession(this.guestName).then(() => {
localStorage.setItem('nick', this.guestName)
this.updateBufferedGuestName()
}).catch((e) => {
diff --git a/src/components/MenuBar.vue b/src/components/MenuBar.vue
index 368fd3a05..bd7b37132 100644
--- a/src/components/MenuBar.vue
+++ b/src/components/MenuBar.vue
@@ -149,11 +149,6 @@ export default {
useEditorMixin,
],
props: {
- syncService: {
- type: Object,
- required: false,
- default: null,
- },
isRichEditor: {
type: Boolean,
default: true,