diff options
author | Maksim Sukharev <antreesy.web@gmail.com> | 2024-03-14 19:30:21 +0100 |
---|---|---|
committer | Maksim Sukharev <antreesy.web@gmail.com> | 2024-03-15 10:23:17 +0100 |
commit | dda2d2b8e5d5601b7a50a6ab04da79a41a420692 (patch) | |
tree | 662d4a890fdc97b895b212ccaeeab88ee6d5344c | |
parent | 74ad6721bcda36f5c317fe98ef1fb96e14bed657 (diff) |
fix(typescript): migrate reactionsService to ts
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
-rw-r--r-- | src/components/MessagesList/MessagesGroup/Message/MessagePart/Reactions.spec.js | 2 | ||||
-rw-r--r-- | src/services/__tests__/messagesService.spec.js | 2 | ||||
-rw-r--r-- | src/services/reactionsService.ts (renamed from src/services/reactionsService.js) | 18 | ||||
-rw-r--r-- | src/stores/__tests__/reactions.spec.js | 2 | ||||
-rw-r--r-- | src/stores/reactions.js | 2 | ||||
-rw-r--r-- | src/types/index.ts | 8 |
6 files changed, 25 insertions, 9 deletions
diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/Reactions.spec.js b/src/components/MessagesList/MessagesGroup/Message/MessagePart/Reactions.spec.js index 4bccb521b..ef4617c22 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/Reactions.spec.js +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/Reactions.spec.js @@ -16,7 +16,7 @@ import { addReactionToMessage, removeReactionFromMessage, getReactionsDetails, -} from '../../../../../services/reactionsService.js' +} from '../../../../../services/reactionsService.ts' import vuexStore from '../../../../../store/index.js' import storeConfig from '../../../../../store/storeConfig.js' import { useReactionsStore } from '../../../../../stores/reactions.js' diff --git a/src/services/__tests__/messagesService.spec.js b/src/services/__tests__/messagesService.spec.js index dc918a1f2..25f2eb4e0 100644 --- a/src/services/__tests__/messagesService.spec.js +++ b/src/services/__tests__/messagesService.spec.js @@ -16,7 +16,7 @@ import { addReactionToMessage, removeReactionFromMessage, getReactionsDetails, -} from '../reactionsService.js' +} from '../reactionsService.ts' import { getTranslationLanguages, translateText, diff --git a/src/services/reactionsService.js b/src/services/reactionsService.ts index 7714efd7e..19cd2f7f0 100644 --- a/src/services/reactionsService.js +++ b/src/services/reactionsService.ts @@ -24,16 +24,24 @@ import axios from '@nextcloud/axios' import { generateOcsUrl } from '@nextcloud/router' -const addReactionToMessage = async function(token, messageId, selectedEmoji, options) { +import type { + addReactionParams, + addReactionResponse, + deleteReactionParams, + deleteReactionResponse, + getReactionsResponse +} from '../types' + +const addReactionToMessage = async function(token: string, messageId: number, selectedEmoji: addReactionParams['reaction'], options: object): addReactionResponse { return axios.post(generateOcsUrl('apps/spreed/api/v1/reaction/{token}/{messageId}', { token, messageId }, options), { reaction: selectedEmoji, - }, options) + } as addReactionParams, options) } -const removeReactionFromMessage = async function(token, messageId, selectedEmoji, options) { +const removeReactionFromMessage = async function(token: string, messageId: number, selectedEmoji: deleteReactionParams['reaction'], options: object): deleteReactionResponse { return axios.delete(generateOcsUrl('apps/spreed/api/v1/reaction/{token}/{messageId}', { token, messageId @@ -41,11 +49,11 @@ const removeReactionFromMessage = async function(token, messageId, selectedEmoji ...options, params: { reaction: selectedEmoji, - }, + } as deleteReactionParams, }) } -const getReactionsDetails = async function(token, messageId, options) { +const getReactionsDetails = async function(token: string, messageId: number, options: object): getReactionsResponse { return axios.get(generateOcsUrl('apps/spreed/api/v1/reaction/{token}/{messageId}', { token, messageId diff --git a/src/stores/__tests__/reactions.spec.js b/src/stores/__tests__/reactions.spec.js index d971add0a..faf917318 100644 --- a/src/stores/__tests__/reactions.spec.js +++ b/src/stores/__tests__/reactions.spec.js @@ -4,7 +4,7 @@ import Vuex from 'vuex' import { showError } from '@nextcloud/dialogs' -import { getReactionsDetails, addReactionToMessage, removeReactionFromMessage } from '../../services/reactionsService.js' +import { getReactionsDetails, addReactionToMessage, removeReactionFromMessage } from '../../services/reactionsService.ts' import vuexStore from '../../store/index.js' import { generateOCSErrorResponse, generateOCSResponse } from '../../test-helpers.js' import { useReactionsStore } from '../reactions.js' diff --git a/src/stores/reactions.js b/src/stores/reactions.js index 8d0c8f582..7fcbb53e1 100644 --- a/src/stores/reactions.js +++ b/src/stores/reactions.js @@ -30,7 +30,7 @@ import { getReactionsDetails, addReactionToMessage, removeReactionFromMessage, -} from '../services/reactionsService.js' +} from '../services/reactionsService.ts' import store from '../store/index.js' /** diff --git a/src/types/index.ts b/src/types/index.ts index 6c57e5f8f..ad005697a 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -88,3 +88,11 @@ export type NotificationInvite = Notification<FederationInviteRichParameters> export type getSharesResponse = ApiResponse<operations['federation-get-shares']['responses'][200]['content']['application/json']> export type acceptShareResponse = ApiResponse<operations['federation-accept-share']['responses'][200]['content']['application/json']> export type rejectShareResponse = ApiResponse<operations['federation-reject-share']['responses'][200]['content']['application/json']> + +// Reactions +export type getReactionsParams = ApiOptions<operations['reaction-get-reactions']['parameters']['query']>['params'] +export type getReactionsResponse = ApiResponse<operations['reaction-get-reactions']['responses'][200]['content']['application/json']> +export type addReactionParams = ApiOptions<operations['reaction-react']['parameters']['query']>['params'] +export type addReactionResponse = ApiResponse<operations['reaction-react']['responses'][200]['content']['application/json']> +export type deleteReactionParams = ApiOptions<operations['reaction-delete']['parameters']['query']>['params'] +export type deleteReactionResponse = ApiResponse<operations['reaction-delete']['responses'][200]['content']['application/json']> |