️ (#2323): inject SyncService instance

Vinicius Reis <vinicius.reis@nextcloud.com>
This commit is contained in:
Vinicius Reis 2022-04-26 11:21:39 -03:00
Родитель 217a7f13c7
Коммит 5d69744cf6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 33D19916F9FF2308
4 изменённых файлов: 20 добавлений и 19 удалений

Просмотреть файл

@ -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 },
},
}

Просмотреть файл

@ -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: [],

Просмотреть файл

@ -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) => {

Просмотреть файл

@ -149,11 +149,6 @@ export default {
useEditorMixin,
],
props: {
syncService: {
type: Object,
required: false,
default: null,
},
isRichEditor: {
type: Boolean,
default: true,