diff --git a/src/api/services/ShlinkApiClient.ts b/src/api/services/ShlinkApiClient.ts index 552254e9..54682e06 100644 --- a/src/api/services/ShlinkApiClient.ts +++ b/src/api/services/ShlinkApiClient.ts @@ -80,17 +80,6 @@ export default class ShlinkApiClient { this.performRequest(`/short-urls/${shortCode}`, 'DELETE', { domain }) .then(() => {}); - /** - * @deprecated. If using Shlink 2.6.0 or greater, use updateShortUrl instead - */ - public readonly updateShortUrlTags = async ( - shortCode: string, - domain: OptionalString, - tags: string[], - ): Promise => - this.performRequest<{ tags: string[] }>(`/short-urls/${shortCode}/tags`, 'PUT', { domain }, { tags }) - .then(({ data }) => data.tags); - public readonly updateShortUrl = async ( shortCode: string, domain: OptionalString, diff --git a/src/short-urls/reducers/shortUrlEdition.ts b/src/short-urls/reducers/shortUrlEdition.ts index 2fdb5d92..6c530695 100644 --- a/src/short-urls/reducers/shortUrlEdition.ts +++ b/src/short-urls/reducers/shortUrlEdition.ts @@ -6,7 +6,6 @@ import { EditShortUrlData, ShortUrl } from '../data'; import { ShlinkApiClientBuilder } from '../../api/services/ShlinkApiClientBuilder'; import { ProblemDetailsError } from '../../api/types'; import { parseApiError } from '../../api/utils'; -import { supportsTagsInPatch } from '../../utils/helpers/features'; import { ApiErrorAction } from '../../api/types/actions'; export const EDIT_SHORT_URL_START = 'shlink/shortUrlEdition/EDIT_SHORT_URL_START'; @@ -42,15 +41,10 @@ export const editShortUrl = (buildShlinkApiClient: ShlinkApiClientBuilder) => ( ) => async (dispatch: Dispatch, getState: GetState) => { dispatch({ type: EDIT_SHORT_URL_START }); - const { selectedServer } = getState(); - const sendTagsSeparately = !supportsTagsInPatch(selectedServer); - const { updateShortUrl, updateShortUrlTags } = buildShlinkApiClient(getState); + const { updateShortUrl } = buildShlinkApiClient(getState); try { - const [shortUrl] = await Promise.all([ - updateShortUrl(shortCode, domain, data as any), // FIXME Parse dates - sendTagsSeparately && data.tags ? updateShortUrlTags(shortCode, domain, data.tags) : undefined, - ]); + const shortUrl = await updateShortUrl(shortCode, domain, data as any); // FIXME parse dates; dispatch({ shortUrl, type: SHORT_URL_EDITED }); } catch (e: any) { diff --git a/src/utils/helpers/features.ts b/src/utils/helpers/features.ts index 6f8f7810..54a26c7d 100644 --- a/src/utils/helpers/features.ts +++ b/src/utils/helpers/features.ts @@ -8,7 +8,6 @@ export const supportsQrCodeSizeInQuery = serverMatchesVersions({ minVersion: '2. export const supportsShortUrlTitle = serverMatchesVersions({ minVersion: '2.6.0' }); export const supportsOrphanVisits = supportsShortUrlTitle; export const supportsQrCodeMargin = supportsShortUrlTitle; -export const supportsTagsInPatch = supportsShortUrlTitle; export const supportsBotVisits = serverMatchesVersions({ minVersion: '2.7.0' }); export const supportsCrawlableVisits = supportsBotVisits; export const supportsQrErrorCorrection = serverMatchesVersions({ minVersion: '2.8.0' }); diff --git a/test/api/services/ShlinkApiClient.test.ts b/test/api/services/ShlinkApiClient.test.ts index 88bab25f..91153fb4 100644 --- a/test/api/services/ShlinkApiClient.test.ts +++ b/test/api/services/ShlinkApiClient.test.ts @@ -156,25 +156,6 @@ describe('ShlinkApiClient', () => { }); }); - describe('updateShortUrlTags', () => { - it.each(shortCodesWithDomainCombinations)('properly updates short URL tags', async (shortCode, domain) => { - const expectedTags = ['foo', 'bar']; - const axiosSpy = createAxiosMock({ - data: { tags: expectedTags }, - }); - const { updateShortUrlTags } = new ShlinkApiClient(axiosSpy, '', ''); - - const result = await updateShortUrlTags(shortCode, domain, expectedTags); - - expect(expectedTags).toEqual(result); - expect(axiosSpy).toHaveBeenCalledWith(expect.objectContaining({ - url: `/short-urls/${shortCode}/tags`, - method: 'PUT', - params: domain ? { domain } : {}, - })); - }); - }); - describe('updateShortUrl', () => { it.each(shortCodesWithDomainCombinations)('properly updates short URL meta', async (shortCode, domain) => { const meta = { diff --git a/test/short-urls/reducers/shortUrlEdition.test.ts b/test/short-urls/reducers/shortUrlEdition.test.ts index 364a32e9..313d7556 100644 --- a/test/short-urls/reducers/shortUrlEdition.test.ts +++ b/test/short-urls/reducers/shortUrlEdition.test.ts @@ -8,7 +8,7 @@ import reducer, { } from '../../../src/short-urls/reducers/shortUrlEdition'; import { ShlinkState } from '../../../src/container/types'; import { ShortUrl } from '../../../src/short-urls/data'; -import { ReachableServer, SelectedServer } from '../../../src/servers/data'; +import { SelectedServer } from '../../../src/servers/data'; describe('shortUrlEditionReducer', () => { const longUrl = 'https://shlink.io'; @@ -41,8 +41,7 @@ describe('shortUrlEditionReducer', () => { describe('editShortUrl', () => { const updateShortUrl = jest.fn().mockResolvedValue(shortUrl); - const updateShortUrlTags = jest.fn().mockResolvedValue([]); - const buildShlinkApiClient = jest.fn().mockReturnValue({ updateShortUrl, updateShortUrlTags }); + const buildShlinkApiClient = jest.fn().mockReturnValue({ updateShortUrl }); const dispatch = jest.fn(); const createGetState = (selectedServer: SelectedServer = null) => () => Mock.of({ selectedServer }); @@ -59,25 +58,6 @@ describe('shortUrlEditionReducer', () => { expect(dispatch).toHaveBeenNthCalledWith(2, { type: SHORT_URL_EDITED, shortUrl }); }); - it.each([ - [null, { tags: ['foo', 'bar'] }, 1], - [null, {}, 0], - [Mock.of({ version: '2.6.0' }), {}, 0], - [Mock.of({ version: '2.6.0' }), { tags: ['foo', 'bar'] }, 0], - [Mock.of({ version: '2.5.0' }), {}, 0], - [Mock.of({ version: '2.5.0' }), { tags: ['foo', 'bar'] }, 1], - ])( - 'sends tags separately when appropriate, based on selected server and the payload', - async (server, payload, expectedTagsCalls) => { - const getState = createGetState(server); - - await editShortUrl(buildShlinkApiClient)(shortCode, null, payload)(dispatch, getState); - - expect(updateShortUrl).toHaveBeenCalled(); - expect(updateShortUrlTags).toHaveBeenCalledTimes(expectedTagsCalls); - }, - ); - it('dispatches error on failure', async () => { const error = new Error();