Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
95764c6
chore(split): SaveService from SyncService
max-nextcloud Jul 1, 2025
2405e75
chore(type): sync service with typescript
max-nextcloud Jul 2, 2025
8525912
chore(migrate): sync service mixin to composable
max-nextcloud Jul 2, 2025
507a7a5
chore(refactor): watch sync service to create save service
max-nextcloud Jul 3, 2025
594fb1a
chore(refactor): move connectSyncService into useSyncService composable
max-nextcloud Jul 3, 2025
725872c
refactor(compose): migrate save service to composable
max-nextcloud Jul 3, 2025
9fdf878
refactor(editor): detect rich editor based on markdown extension
max-nextcloud Jul 3, 2025
94f7619
refactor(editor): always provide an editor
max-nextcloud Jul 3, 2025
e8d184a
refactor(cleanup): unwrap connection
max-nextcloud Jul 3, 2025
c856f2f
chore(minor): clean up redundant injects
max-nextcloud Jul 3, 2025
00c18c4
chore(refactor): simplify types for props
max-nextcloud Jul 3, 2025
c71503e
chore(refactor): watch sync service in useConnection
max-nextcloud Jul 5, 2025
7265f02
chore(extract): Mentions api from extension
max-nextcloud Jul 5, 2025
f6b76f3
chore(simplify): SyncService.open returns void
max-nextcloud Jul 5, 2025
90ae016
chore(simplify): combine loaded and opened event
max-nextcloud Jul 5, 2025
8a46d28
chore(cleanup): unused getter
max-nextcloud Jul 5, 2025
798c4b8
fix(menu): call base components setup function
max-nextcloud Jul 5, 2025
8b45a52
chore(refactor): connect from useConnection composable
max-nextcloud Jul 5, 2025
7bc34c9
chore(cleanup): sync and save service are always defined now
max-nextcloud Jul 6, 2025
d4a09c4
test(cy): properly close connections
max-nextcloud Jul 6, 2025
e6fc63b
chore(refactor): sync service with new connection
max-nextcloud Jul 7, 2025
c3230d3
chore(refactor): instantiate SessionConnection with plain data
max-nextcloud Jul 7, 2025
7dc8e25
fix(sync): stop autosave when closing connection
max-nextcloud Jul 8, 2025
7c52d1c
chore(cleanup): ? on attributes that are always truthy
max-nextcloud Jul 8, 2025
f370913
chore(cleanup): avoid reuse of isRichEditor name
max-nextcloud Jul 8, 2025
6c76f27
chore(cleanup): remove outdated comment
max-nextcloud Jul 8, 2025
9ea9857
chore(copyright): fix year to 2025
max-nextcloud Jul 8, 2025
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
Prev Previous commit
chore(copyright): fix year to 2025
Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Jul 8, 2025
commit 9ea98570f776e9ab45db6c5c91f912221d53bb90
2 changes: 1 addition & 1 deletion src/apis/Connect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import axios from '@nextcloud/axios'
Expand All @@ -22,37 +22,37 @@
* Open editing connection to the document
* @param params Parameters identifying the document
*/
export async function open(
params: OpenParams,
): Promise<{ connection: Connection; data: OpenData }> {
const _baseUrl = params.token
? generateUrl('/apps/text/public')
: generateUrl('/apps/text')
const url = `${_baseUrl}/session/${params.fileId}/create`
const response = await axios.put(url, params)
const { document, session } = response.data
const connection = {
documentId: document.id,
sessionId: session.id,
sessionToken: session.token,
baseVersionEtag: document.baseVersionEtag,
filePath: params.filePath,
shareToken: params.token,
}
return { connection, data: response.data }
}

Check warning on line 43 in src/apis/Connect.ts

View check run for this annotation

Codecov / codecov/patch

src/apis/Connect.ts#L25-L43

Added lines #L25 - L43 were not covered by tests

/**
* Close the connection
* @param connection connection to close
*/
export async function close(connection: Connection) {
const id = connection.documentId
const url = generateUrl(`/apps/text/session/${id}/close`)
const response = await axios.post(url, {
documentId: connection.documentId,
sessionId: connection.sessionId,
sessionToken: connection.sessionToken,
})
return response.data
}

Check warning on line 58 in src/apis/Connect.ts

View check run for this annotation

Codecov / codecov/patch

src/apis/Connect.ts#L49-L58

Added lines #L49 - L58 were not covered by tests
2 changes: 1 addition & 1 deletion src/apis/Mention.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

Expand All @@ -16,29 +16,29 @@
* @param options.connection connection to the text editing session
*/
export function emitMention(
mention: string,
scope: object,
{ connection }: { connection: ShallowRef<Connection> | Connection },
): Promise<void> {

Check warning on line 22 in src/apis/Mention.ts

View check run for this annotation

Codecov / codecov/patch

src/apis/Mention.ts#L19-L22

Added lines #L19 - L22 were not covered by tests
// TODO: Require actual connection - handle disconnected state early on
const con = unref(connection)
if (!con) {
const err = new Error('Disconnected. Could not notify user about mention.')
console.warn(err.message, { err, mention })
return Promise.resolve()
}
const url = generateUrl(`apps/text/session/${con.documentId}/mention`)
return axios.put(url, {
documentId: con.documentId,
sessionId: con.sessionId,
sessionToken: con.sessionToken,
mention,
scope,
})

Check warning on line 37 in src/apis/Mention.ts

View check run for this annotation

Codecov / codecov/patch

src/apis/Mention.ts#L24-L37

Added lines #L24 - L37 were not covered by tests
// TODO: handle errors:
// * signal something is wrong with the connection
// * wait for reconnect and fetch again
}

Check warning on line 41 in src/apis/Mention.ts

View check run for this annotation

Codecov / codecov/patch

src/apis/Mention.ts#L41

Added line #L41 was not covered by tests

const USERS_LIST_ENDPOINT_URL = generateUrl('apps/text/api/v1/users')

Expand All @@ -48,20 +48,20 @@
* @param options options
* @param options.connection connection to the text editing session
*/
export async function getUsers(
filter: string,
{ connection }: { connection: ShallowRef<Connection> },
): Promise<Record<string, string>> {

Check warning on line 54 in src/apis/Mention.ts

View check run for this annotation

Codecov / codecov/patch

src/apis/Mention.ts#L51-L54

Added lines #L51 - L54 were not covered by tests
// TODO: Require actual connection - handle disconnected state early on
const con = unref(connection)
if (!con) {
const err = new Error('Disconnected. Could not lookup users to mention.')
console.warn(err.message, { err })
return Promise.resolve({})
}
const response = await axios.post(USERS_LIST_ENDPOINT_URL, { ...con, filter })

Check warning on line 62 in src/apis/Mention.ts

View check run for this annotation

Codecov / codecov/patch

src/apis/Mention.ts#L56-L62

Added lines #L56 - L62 were not covered by tests
// TODO: handle errors:
// * signal something is wrong with the connection
// * wait for reconnect and fetch again
return JSON.parse(JSON.stringify(response.data))
}

Check warning on line 67 in src/apis/Mention.ts

View check run for this annotation

Codecov / codecov/patch

src/apis/Mention.ts#L66-L67

Added lines #L66 - L67 were not covered by tests
2 changes: 1 addition & 1 deletion src/apis/Sync.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import axios from '@nextcloud/axios'
Expand Down Expand Up @@ -28,20 +28,20 @@
* @param data data to push to the server
*/
export function push(
connection: ShallowRef<Connection> | Connection,
data: SyncData,
): Promise<SyncResponse> {
const con = unref(connection)
const pub = con.shareToken ? '/public' : ''
const url = generateUrl(`apps/text${pub}/session/${con.documentId}/push`)
return axios.post(url, {
documentId: con.documentId,
sessionId: con.sessionId,
sessionToken: con.sessionToken,
token: con.shareToken,
baseVersionEtag: con.baseVersionEtag,
version: data.version,
steps: data.steps.filter((s) => s),
awareness: data.awareness,
})
}

Check warning on line 47 in src/apis/Sync.ts

View check run for this annotation

Codecov / codecov/patch

src/apis/Sync.ts#L31-L47

Added lines #L31 - L47 were not covered by tests
Loading