Avoid changing intro dictionary in HTTP controller
This commit is contained in:
parent
85f21ae51c
commit
b1cf0aa2fc
@ -54,7 +54,8 @@ public class SkipIntroController : ControllerBase
|
|||||||
/// <returns>Intro object if the provided item has an intro, null otherwise.</returns>
|
/// <returns>Intro object if the provided item has an intro, null otherwise.</returns>
|
||||||
private Intro? GetIntro(Guid id)
|
private Intro? GetIntro(Guid id)
|
||||||
{
|
{
|
||||||
return Plugin.Instance!.Intros.TryGetValue(id, out var intro) ? intro : null;
|
// Returns a copy to avoid mutating the original Intro object stored in the dictionary.
|
||||||
|
return Plugin.Instance!.Intros.TryGetValue(id, out var intro) ? new Intro(intro) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -32,6 +32,17 @@ public class Intro
|
|||||||
IntroEnd = 0;
|
IntroEnd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Intro"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="intro">intro.</param>
|
||||||
|
public Intro(Intro intro)
|
||||||
|
{
|
||||||
|
EpisodeId = intro.EpisodeId;
|
||||||
|
IntroStart = intro.IntroStart;
|
||||||
|
IntroEnd = intro.IntroEnd;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Intro"/> class.
|
/// Initializes a new instance of the <see cref="Intro"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user