Skip to content

Commit

Permalink
Finish implementing UpdateWritingSystemProxy
Browse files Browse the repository at this point in the history
  • Loading branch information
rmunn committed Nov 19, 2024
1 parent 12db010 commit e534715
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
6 changes: 5 additions & 1 deletion backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ await Cache.DoUsingNewOrCurrentUOW("Update WritingSystem",
"Revert WritingSystem",
async () =>

Check warning on line 196 in backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs

View workflow job for this annotation

GitHub Actions / Build FwHeadless / publish-fw-headless

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 196 in backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs

View workflow job for this annotation

GitHub Actions / Build FW Lite and run tests

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 196 in backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs

View workflow job for this annotation

GitHub Actions / Publish FW Lite app for Linux

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 196 in backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs

View workflow job for this annotation

GitHub Actions / Publish FW Lite app for Linux

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 196 in backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs

View workflow job for this annotation

GitHub Actions / Publish FW Lite app for Mac

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 196 in backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs

View workflow job for this annotation

GitHub Actions / Publish FW Lite app for Mac

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 196 in backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs

View workflow job for this annotation

GitHub Actions / Publish FW Lite app for Windows

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 196 in backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs

View workflow job for this annotation

GitHub Actions / Publish FW Lite app for Windows

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
var updateProxy = new UpdateWritingSystemProxy(lcmWritingSystem, this) { Type = type }; // TODO: Doesn't compile, wants Font to be set. Also wants a GUID Id which we don't have...
var updateProxy = new UpdateWritingSystemProxy(lcmWritingSystem, this)
{
Id = Guid.Empty,
Type = type,
};
update.Apply(updateProxy);
updateProxy.CommitUpdate(Cache);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Diagnostics.CodeAnalysis;
using MiniLcm.Models;
using SIL.LCModel;
using SIL.LCModel.Core.WritingSystems;
using SIL.LCModel.DomainServices;
using SIL.WritingSystems;

namespace FwDataMiniLcmBridge.Api.UpdateProxy;

Expand All @@ -11,10 +13,14 @@ public record UpdateWritingSystemProxy : WritingSystem
private readonly CoreWritingSystemDefinition _workingLcmWritingSystem;
private readonly FwDataMiniLcmApi _lexboxLcmApi;

[SetsRequiredMembers]
public UpdateWritingSystemProxy(CoreWritingSystemDefinition lcmWritingSystem, FwDataMiniLcmApi lexboxLcmApi)
{
_origLcmWritingSystem = lcmWritingSystem;
_workingLcmWritingSystem = new CoreWritingSystemDefinition(lcmWritingSystem, cloneId: true);
base.Abbreviation = Abbreviation = _origLcmWritingSystem.Abbreviation ?? "";
base.Name = Name = _origLcmWritingSystem.LanguageName ?? "";
base.Font = Font = _origLcmWritingSystem.DefaultFontName ?? "";
_lexboxLcmApi = lexboxLcmApi;
}

Expand Down Expand Up @@ -49,10 +55,15 @@ public override required string Abbreviation
set => _workingLcmWritingSystem.Abbreviation = value;
}

// TODO: Change WritingSystem Font property to be a list of strings instead of a single string, then do something like this
// public override required List<string> Fonts
// {
// get => _workingLcmWritingSystem.Fonts.Select(f => f.Name).ToList();
// set => throw new NotImplementedException();
// }
public override required string Font
{
get => _workingLcmWritingSystem.DefaultFontName;
set
{
if (value != _workingLcmWritingSystem.DefaultFontName)
{
_workingLcmWritingSystem.DefaultFont = new FontDefinition(value);
}
}
}
}
1 change: 0 additions & 1 deletion backend/FwLite/MiniLcm/Models/WritingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public record WritingSystem: IObjectWithId
public virtual required WritingSystemId WsId { get; set; }
public virtual required string Name { get; set; }
public virtual required string Abbreviation { get; set; }
// TODO: Font will need to become Fonts, a list or array of strings, to better match the LCM model
public virtual required string Font { get; set; }

public DateTimeOffset? DeletedAt { get; set; }
Expand Down

0 comments on commit e534715

Please sign in to comment.