mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-06-27 17:16:28 +00:00
Replace GetAcceptanceHash with AcceptanceHash property
This commit is contained in:
parent
277cc01cbf
commit
b68c62693f
@ -33,7 +33,7 @@ public partial class MandatoryInfoDisplay
|
||||
if (!string.Equals(this.Acceptance.AcceptedVersion, this.Info.VersionText, StringComparison.Ordinal))
|
||||
return MandatoryInfoAcceptanceStatus.VERSION_CHANGED;
|
||||
|
||||
if (!string.Equals(this.Acceptance.AcceptedHash, this.Info.GetAcceptanceHash(), StringComparison.Ordinal))
|
||||
if (!string.Equals(this.Acceptance.AcceptedHash, this.Info.AcceptanceHash, StringComparison.Ordinal))
|
||||
return MandatoryInfoAcceptanceStatus.CONTENT_CHANGED;
|
||||
|
||||
return MandatoryInfoAcceptanceStatus.ACCEPTED;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<div class="pt-6" style="max-height: calc(100vh - 11rem); overflow-y: auto; overflow-x: hidden; padding-right: 0.5rem;">
|
||||
<MandatoryInfoDisplay Info="@this.Info" />
|
||||
<MandatoryInfoDisplay Info="@this.Info" ShowAcceptanceMetadata="@true" />
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
|
||||
@ -418,7 +418,7 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
.Where(info =>
|
||||
{
|
||||
var acceptance = this.SettingsManager.ConfigurationData.MandatoryInformation.FindAcceptance(info.Id);
|
||||
return acceptance is null || !string.Equals(acceptance.AcceptedHash, info.GetAcceptanceHash(), StringComparison.Ordinal);
|
||||
return acceptance is null || !string.Equals(acceptance.AcceptedHash, info.AcceptanceHash, StringComparison.Ordinal);
|
||||
});
|
||||
}
|
||||
|
||||
@ -441,7 +441,7 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
{
|
||||
InfoId = info.Id,
|
||||
AcceptedVersion = info.VersionText,
|
||||
AcceptedHash = info.GetAcceptanceHash(),
|
||||
AcceptedHash = info.AcceptanceHash,
|
||||
AcceptedAtUtc = DateTimeOffset.UtcNow,
|
||||
EnterpriseConfigurationPluginId = info.EnterpriseConfigurationPluginId,
|
||||
};
|
||||
|
||||
@ -45,10 +45,17 @@ public sealed record DataMandatoryInfo
|
||||
/// </summary>
|
||||
public string RejectButtonText { get; private init; } = string.Empty;
|
||||
|
||||
public string GetAcceptanceHash()
|
||||
/// <summary>
|
||||
/// The current hash used to determine whether the user needs to re-accept the info.
|
||||
/// </summary>
|
||||
public string AcceptanceHash { get; private init; } = string.Empty;
|
||||
|
||||
private static string CreateAcceptanceHash(string versionText, string title, string markdown)
|
||||
{
|
||||
var content = $"Version:{this.VersionText}\nTitle:{this.Title}\nMarkdown:{this.Markdown}";
|
||||
var hash = SHA256.HashData(Encoding.UTF8.GetBytes(content));
|
||||
var content = $"Version:{versionText}\nTitle:{title}\nMarkdown:{markdown}";
|
||||
var bytes = Encoding.UTF8.GetBytes(content);
|
||||
var hash = SHA256.HashData(bytes);
|
||||
|
||||
return Convert.ToHexString(hash);
|
||||
}
|
||||
|
||||
@ -92,6 +99,7 @@ public sealed record DataMandatoryInfo
|
||||
}
|
||||
|
||||
var normalizedMarkdown = AIStudio.Tools.Markdown.RemoveSharedIndentation(markdown);
|
||||
var acceptanceHash = CreateAcceptanceHash(versionText, title, normalizedMarkdown);
|
||||
mandatoryInfo = new DataMandatoryInfo
|
||||
{
|
||||
Id = id.ToString(),
|
||||
@ -101,6 +109,7 @@ public sealed record DataMandatoryInfo
|
||||
AcceptButtonText = acceptButtonText,
|
||||
RejectButtonText = rejectButtonText,
|
||||
EnterpriseConfigurationPluginId = configPluginId,
|
||||
AcceptanceHash = acceptanceHash,
|
||||
};
|
||||
|
||||
return true;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user