规避因错误导致的大量重复消息#575
Merged
2-2-3-trimethylpentane merged 1 commit intoJul 4, 2026
Merged
Conversation
0f0cc91
into
InkCanvasForClass:net6
3 checks passed
Collaborator
|
感谢 PR! 注:以下内容由AI生成 命名
魔数 TotalSeconds <= 2 里的 2 建议提常量,比如 DeduplicationWindowSeconds = 2,方便后续调参。 可变结构体 JudgeRepeatMessageStruct 用了 { get; set; } 可变属性,属于 mutable struct,在 C# 里容易因值拷贝踩坑。这里因为只有一个实例、都在 lock 内访问,问题不大,但规范起见建议改成 class,或改成只读 struct + 构造函数。 逻辑可抽方法 去重判断那段建议抽成一个 IsDuplicate(NotificationMessage),可读性更好,也方便补单测。 空标题 当前 message.Title 为空时既不去重也不更新 LastMessage,看起来是合理的(空标题消息原样入队),但建议补一行注释说明这是有意为之,免得后人疑惑。 再次感谢贡献,课堂场景下这个修复很必要 👍 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
场景:教学课堂环境,插件可能因异常(如死循环、网络重连)高频推送相同通知。
策略:采用滑动窗口去重(2秒内)。若同一来源的相同标题持续出现,每次出现都刷新窗口起点,使通知彻底沉默,直到插件停止刷屏 2 秒以上。
效果:杜绝课堂被反复弹窗干扰,同时不影响正常间隔(> 2秒)的有效通知。