Skip to content

Commit 156ddc4

Browse files
committed
Revert out-of-scope controller/frontend API change
1 parent 55b05b9 commit 156ddc4

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

Backend/Controllers/WordController.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,12 @@ public async Task<IActionResult> UpdateWord(
248248
}
249249

250250
/// <summary> Restore a deleted <see cref="Word"/>. </summary>
251+
/// <returns> bool: true if restored; false if already in frontier. </returns>
251252
[HttpGet("restore/{wordId}", Name = "RestoreWord")]
252-
[ProducesResponseType(StatusCodes.Status200OK)]
253-
[ProducesResponseType(StatusCodes.Status400BadRequest)]
253+
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(bool))]
254254
[ProducesResponseType(StatusCodes.Status403Forbidden)]
255+
[ProducesResponseType(StatusCodes.Status404NotFound)]
256+
255257
public async Task<IActionResult> RestoreWord(string projectId, string wordId)
256258
{
257259
using var activity = OtelService.StartActivityWithTag(otelTagName, "restoring a word");
@@ -260,8 +262,12 @@ public async Task<IActionResult> RestoreWord(string projectId, string wordId)
260262
{
261263
return Forbid();
262264
}
265+
if (await _wordRepo.GetWord(projectId, wordId) is null)
266+
{
267+
return NotFound();
268+
}
263269

264-
return await _wordService.RestoreFrontierWords(projectId, [wordId]) ? Ok() : BadRequest();
270+
return Ok(await _wordService.RestoreFrontierWords(projectId, [wordId]));
265271
}
266272

267273
/// <summary> Revert words from a dictionary of word ids (key: to revert to; value: from frontier). </summary>

src/api/api/word-api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ export const WordApiFp = function (configuration?: Configuration) {
10411041
wordId: string,
10421042
options?: any
10431043
): Promise<
1044-
(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>
1044+
(axios?: AxiosInstance, basePath?: string) => AxiosPromise<boolean>
10451045
> {
10461046
const localVarAxiosArgs = await localVarAxiosParamCreator.restoreWord(
10471047
projectId,
@@ -1315,7 +1315,7 @@ export const WordApiFactory = function (
13151315
projectId: string,
13161316
wordId: string,
13171317
options?: any
1318-
): AxiosPromise<void> {
1318+
): AxiosPromise<boolean> {
13191319
return localVarFp
13201320
.restoreWord(projectId, wordId, options)
13211321
.then((request) => request(axios, basePath));

src/backend/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,9 +959,10 @@ export async function isInFrontier(
959959
export async function restoreWord(
960960
wordId: string,
961961
projectId?: string
962-
): Promise<void> {
962+
): Promise<boolean> {
963963
projectId ||= LocalStorage.getProjectId();
964-
await wordApi.restoreWord({ projectId, wordId }, defaultOptions());
964+
const params = { projectId, wordId };
965+
return (await wordApi.restoreWord(params, defaultOptions())).data;
965966
}
966967

967968
/** Revert word updates given in dictionary of word ids:

0 commit comments

Comments
 (0)