Fix highlights not showing in mentions (#3801)

This commit is contained in:
pajlada 2022-06-06 15:36:53 +02:00 committed by GitHub
parent d29243a2a5
commit 9219647b6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 116 additions and 8 deletions

View file

@ -32,7 +32,7 @@
- Bugfix: Fixed automod queue pubsub topic persisting after user change. (#3718)
- Bugfix: Fixed viewer list not closing after pressing escape key. (#3734)
- Bugfix: Fixed links with no thumbnail having previous link's thumbnail. (#3720)
- Dev: Overhaul highlight system by moving all checks into a Controller allowing for easier tests. (#3399)
- Dev: Overhaul highlight system by moving all checks into a Controller allowing for easier tests. (#3399, #3801)
- Dev: Use Game Name returned by Get Streams instead of querying it from the Get Games API. (#3662)
- Dev: Batch checking live status for all channels after startup. (#3757, #3762, #3767)

View file

@ -44,12 +44,57 @@ public:
}
};
class MockApplication : BaseApplication
class MockApplication : IApplication
{
AccountController *const getAccounts() override
public:
Theme *getThemes() override
{
return nullptr;
}
Fonts *getFonts() override
{
return nullptr;
}
Emotes *getEmotes() override
{
return nullptr;
}
AccountController *getAccounts() override
{
return &this->accounts;
}
HotkeyController *getHotkeys() override
{
return nullptr;
}
WindowManager *getWindows() override
{
return nullptr;
}
Toasts *getToasts() override
{
return nullptr;
}
CommandController *getCommands() override
{
return nullptr;
}
NotificationController *getNotifications() override
{
return nullptr;
}
TwitchIrcServer *getTwitch() override
{
return nullptr;
}
ChatterinoBadges *getChatterinoBadges() override
{
return nullptr;
}
FfzBadges *getFfzBadges() override
{
return nullptr;
}
AccountController accounts;
// TODO: Figure this out

View file

@ -170,11 +170,9 @@ void rebuildUserHighlights(Settings &settings,
}
return HighlightResult{
highlight.hasAlert(),
highlight.hasSound(),
highlightSoundUrl,
highlight.getColor(),
false, // showInMentions
highlight.hasAlert(), highlight.hasSound(),
highlightSoundUrl, highlight.getColor(),
highlight.showInMentions(),
};
}});
}
@ -344,6 +342,14 @@ std::pair<bool, HighlightResult> HighlightController::check(
}
}
if (checkResult->showInMentions)
{
if (!result.showInMentions)
{
result.showInMentions = checkResult->showInMentions;
}
}
if (result.full())
{
// The final highlight result does not have room to add any more parameters, early out

View file

@ -121,6 +121,22 @@ struct HighlightResult {
this->customSoundUrl.has_value() && this->color &&
this->showInMentions;
}
friend std::ostream &operator<<(std::ostream &os,
const HighlightResult &result)
{
os << "Alert: " << (result.alert ? "Yes" : "No") << ", "
<< "Play sound: " << (result.playSound ? "Yes" : "No") << " ("
<< (result.customSoundUrl
? result.customSoundUrl.get().toString().toStdString()
: "")
<< ")"
<< ", "
<< "Color: "
<< (result.color ? result.color->name().toStdString() : "") << ", "
<< "Show in mentions: " << (result.showInMentions ? "Yes" : "No");
return os;
}
};
struct HighlightCheck {

View file

@ -451,6 +451,47 @@ TEST_F(HighlightControllerTest, A)
},
},
},
{
// User mention with showInMentions
{
// input
MessageParseArgs{}, // no special args
{}, // no badges
"gempir", // sender name
"a", // original message
},
{
// expected
true, // state
{
true, // alert
false, // playsound
boost::none, // custom sound url
std::make_shared<QColor>("#7ff19900"), // color
true, // showInMentions
},
},
},
{
{
// input
MessageParseArgs{}, // no special args
{}, // no badges
"a", // sender name
"!testmanxd", // original message
},
{
// expected
true, // state
{
true, // alert
true, // playsound
boost::none, // custom sound url
std::make_shared<QColor>("#7f7f3f49"), // color
true, // showInMentions
},
},
},
};
for (const auto &[input, expected] : tests)