-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fw lite handle errors on frontend (#947)
* dynamically load project when trying to access LcmCache in FwDataMiniLcmApi * notify client when a project is locked, display a message and allow the user to retry on frontend. * setup generic signalr error handling * hide double notifications for locked projects, change the error message to something more helpful * set sense part of speech id to undefined by default * fix bug where a new id would be generated even if it was already set for both the sense and example sentence * fix bug where reloading the page would result in a 404, fixed by setting up a fallback to the index page * add placeholder for index changes
- Loading branch information
Showing
18 changed files
with
261 additions
and
121 deletions.
There are no files selected for viewing
140 changes: 62 additions & 78 deletions
140
backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using MiniLcm; | ||
|
||
namespace LocalWebApp.Hubs; | ||
|
||
public interface ILexboxHubClient | ||
{ | ||
Task OnEntryUpdated(Entry entry); | ||
Task OnProjectClosed(CloseReason reason); | ||
} | ||
|
||
public enum CloseReason | ||
{ | ||
User, | ||
Locked | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Microsoft.AspNetCore.SignalR; | ||
using SIL.LCModel; | ||
|
||
namespace LocalWebApp.Hubs; | ||
|
||
public class LockedProjectFilter: IHubFilter | ||
{ | ||
public async ValueTask<object?> InvokeMethodAsync(HubInvocationContext invocationContext, Func<HubInvocationContext, ValueTask<object?>> next) | ||
{ | ||
try | ||
{ | ||
return await next(invocationContext); | ||
} | ||
catch (LcmFileLockedException) | ||
{ | ||
await TypedHubHelper<ILexboxHubClient>.TypeClients(invocationContext.Hub.Clients) | ||
.Caller.OnProjectClosed(CloseReason.Locked); | ||
throw new HubException("The project is locked."); | ||
} | ||
} | ||
|
||
private class TypedHubHelper<TClient> : Hub<TClient> where TClient : class | ||
{ | ||
public TypedHubHelper(IHubCallerClients clients) : base() | ||
{ | ||
((Hub)this).Clients = clients; | ||
} | ||
|
||
public static IHubCallerClients<TClient> TypeClients(IHubCallerClients clients) | ||
{ | ||
return new TypedHubHelper<TClient>(clients).Clients; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.