Skip to content

Commit 0290afc

Browse files
committed
Resolve PR comments
1 parent ce6821c commit 0290afc

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

src/Nomad/ModifiableAccentColor.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public override async Task ApplyEntryUpdateAsync(ValueUpdateEvent updateEvent, C
3636

3737
if (updateEvent is { Unset: false, Value: not null })
3838
{
39-
(accentColor, _) = await Client.ResolveDagCidAsync<string>(updateEvent.Value!, nocache: !KuboOptions.UseCache, cancellationToken);
39+
(accentColor, _) = await Client.ResolveDagCidAsync<string>(updateEvent.Value, nocache: !KuboOptions.UseCache, cancellationToken);
4040
}
4141

4242
await ApplyEntryUpdateAsync(updateEvent, accentColor, cancellationToken);
@@ -64,7 +64,6 @@ public Task ApplyEntryUpdateAsync(ValueUpdateEvent updateEvent, string? accentCo
6464
/// <inheritdoc cref="INomadKuboEventStreamHandler{TEventEntryContent}.AppendNewEntryAsync" />
6565
public override async Task<EventStreamEntry<Cid>> AppendNewEntryAsync(ValueUpdateEvent updateEvent, CancellationToken cancellationToken = default)
6666
{
67-
// Use extension method for code deduplication (can't use inheritance).
6867
var localUpdateEventCid = await Client.Dag.PutAsync(updateEvent, pin: KuboOptions.ShouldPin, cancel: cancellationToken);
6968
var newEntry = await this.AppendEventStreamEntryAsync(localUpdateEventCid, updateEvent.EventId, updateEvent.TargetId, cancellationToken);
7069
return newEntry;
@@ -82,16 +81,14 @@ public override Task ResetEventStreamPositionAsync(CancellationToken cancellatio
8281
/// <inheritdoc />
8382
public async Task UpdateAccentColorAsync(string? accentColor, CancellationToken cancellationToken)
8483
{
85-
bool unset = accentColor is null;
86-
8784
DagCid? valueCid = null;
88-
if (!unset)
85+
if (accentColor is not null)
8986
{
90-
Cid cid = await Client.Dag.PutAsync(accentColor!, pin: KuboOptions.ShouldPin, cancel: cancellationToken);
87+
Cid cid = await Client.Dag.PutAsync(accentColor, pin: KuboOptions.ShouldPin, cancel: cancellationToken);
9188
valueCid = (DagCid)cid;
9289
}
9390

94-
var updateEvent = new ValueUpdateEvent(Id, nameof(UpdateAccentColorAsync), null, valueCid, unset);
91+
var updateEvent = new ValueUpdateEvent(Id, nameof(UpdateAccentColorAsync), null, valueCid, accentColor is null);
9592

9693
await ApplyEntryUpdateAsync(updateEvent, accentColor, cancellationToken);
9794
var appendedEntry = await AppendNewEntryAsync(updateEvent, cancellationToken);

0 commit comments

Comments
 (0)