Skip to content

Commit

Permalink
Follow-up for emoji reactions feature
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRegado committed Apr 15, 2023
1 parent 8f7fd48 commit e194627
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ class EmojiReactEventHandler extends SDEventHandler {
if (attempts <= 0) {
throw new ControlsNotFoundError(`Could not find button for emoji reaction ${emojiChar}!`);
}
let button = document.querySelector(`img[data-emoji="${emojiChar}"]`);
let button = document.querySelector(`button[jsname="vnVdbf"][data-emoji^="${emojiChar}"]`);
if (button) {
button.click();
resolve(true);

} else {
resolve(new Promise((resolve) => setTimeout(() => {
resolve(this._tryClickEmojiReactButton(emojiChar, attempts - 1));
Expand Down
2 changes: 1 addition & 1 deletion browser-extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Stream Deck Google Meet Actions",
"version": "1.3.0",
"version": "1.4.0",
"description": "Connects to our accompanying Elgato Stream Deck plugin to create physical controls for your Google Meet calls.",
"author": "Chris Regado",
"homepage_url": "https://github.com/ChrisRegado/streamdeck-googlemeet",
Expand Down
58 changes: 29 additions & 29 deletions com.chrisregado.googlemeet.sdPlugin/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,137 +271,137 @@
},
{
"Icon": "images/actions/emoji_react_sparkling_heart",
"Name": "Emoji react - Sparkling heart",
"Name": "Emoji React - Sparkling Heart",
"States": [
{
"Image": "images/keys/emoji_react_sparkling_heart",
"Title": "Emoji react - Sparkling heart",
"Title": "Emoji React",
"TitleAlignment": "top",
"FontSize": "10",
"ShowTitle": false
}
],
"Tooltip": "Emoji react - Sparkling heart",
"Tooltip": "Emoji React - Sparkling Heart",
"UUID": "com.chrisregado.googlemeet.emojireact.sparklingheart"
},
{
"Icon": "images/actions/emoji_react_thumbs_up",
"Name": "Emoji react - Thumbs up",
"Name": "Emoji React - Thumbs Up",
"States": [
{
"Image": "images/keys/emoji_react_thumbs_up",
"Title": "Emoji react - Thumbs up",
"Title": "Emoji React",
"TitleAlignment": "top",
"FontSize": "10",
"ShowTitle": false
}
],
"Tooltip": "Emoji react - Thumbs up",
"Tooltip": "Emoji React - Thumbs Up",
"UUID": "com.chrisregado.googlemeet.emojireact.thumbsup"
},
{
"Icon": "images/actions/emoji_react_thumbs_up",
"Name": "Emoji react - Party popper",
"Icon": "images/actions/emoji_react_party_popper",
"Name": "Emoji React - Party Popper",
"States": [
{
"Image": "images/keys/emoji_react_party_popper",
"Title": "Emoji react - Party popper",
"Title": "Emoji React",
"TitleAlignment": "top",
"FontSize": "10",
"ShowTitle": false
}
],
"Tooltip": "Emoji react - Party popper",
"Tooltip": "Emoji React - Party Popper",
"UUID": "com.chrisregado.googlemeet.emojireact.partypopper"
},
{
"Icon": "images/actions/emoji_react_clapping_hands",
"Name": "Emoji react - Clapping hands",
"Name": "Emoji React - Clapping Hands",
"States": [
{
"Image": "images/keys/emoji_react_clapping_hands",
"Title": "Emoji react - Clapping hands",
"Title": "Emoji React",
"TitleAlignment": "top",
"FontSize": "10",
"ShowTitle": false
}
],
"Tooltip": "Emoji react - Clapping hands",
"Tooltip": "Emoji React - Clapping Hands",
"UUID": "com.chrisregado.googlemeet.emojireact.clappinghands"
},
{
"Icon": "images/actions/emoji_react_face_with_tears_of_joy",
"Name": "Emoji react - Face with tears of joy",
"Name": "Emoji React - Face with Tears of Joy",
"States": [
{
"Image": "images/keys/emoji_react_face_with_tears_of_joy",
"Title": "Emoji react - Face with tears of joy",
"Title": "Emoji React",
"TitleAlignment": "top",
"FontSize": "10",
"ShowTitle": false
}
],
"Tooltip": "Emoji react - Face with tears of joy",
"Tooltip": "Emoji React - Face with Tears of Joy",
"UUID": "com.chrisregado.googlemeet.emojireact.facewithtearsofjoy"
},
{
"Icon": "images/actions/emoji_react_face_with_open_mouth",
"Name": "Emoji react - Face with open mouth",
"Name": "Emoji React - Face with Open Mouth",
"States": [
{
"Image": "images/keys/emoji_react_face_with_open_mouth",
"Title": "Emoji react - Face with open mouth",
"Title": "Emoji React",
"TitleAlignment": "top",
"FontSize": "10",
"ShowTitle": false
}
],
"Tooltip": "Emoji react - Face with open mouth",
"Tooltip": "Emoji React - Face with Open Mouth",
"UUID": "com.chrisregado.googlemeet.emojireact.facewithopenmouth"
},
{
"Icon": "images/actions/emoji_react_crying_face",
"Name": "Emoji react - Crying face",
"Name": "Emoji React - Crying Face",
"States": [
{
"Image": "images/keys/emoji_react_crying_face",
"Title": "Emoji react - Crying face",
"Title": "Emoji React",
"TitleAlignment": "top",
"FontSize": "10",
"ShowTitle": false
}
],
"Tooltip": "Emoji react - Crying face",
"Tooltip": "Emoji React - Crying Face",
"UUID": "com.chrisregado.googlemeet.emojireact.cryingface"
},
{
"Icon": "images/actions/emoji_react_thinking_face",
"Name": "Emoji react - Thinking face",
"Name": "Emoji React - Thinking Face",
"States": [
{
"Image": "images/keys/emoji_react_thinking_face",
"Title": "Emoji react - Thinking face",
"Title": "Emoji React",
"TitleAlignment": "top",
"FontSize": "10",
"ShowTitle": false
}
],
"Tooltip": "Emoji react - Thinking face",
"Tooltip": "Emoji React - Thinking Face",
"UUID": "com.chrisregado.googlemeet.emojireact.thinkingface"
},
{
"Icon": "images/actions/emoji_react_thumbs_down",
"Name": "Emoji react - Thumbs down",
"Name": "Emoji React - Thumbs Down",
"States": [
{
"Image": "images/keys/emoji_react_thumbs_down",
"Title": "Emoji react - Thumbs down",
"Title": "Emoji React",
"TitleAlignment": "top",
"FontSize": "10",
"ShowTitle": false
}
],
"Tooltip": "Emoji react - Thumbs down",
"Tooltip": "Emoji React - Thumbs Down",
"UUID": "com.chrisregado.googlemeet.emojireact.thumbsdown"
}
],
Expand All @@ -413,7 +413,7 @@
"Name": "Google Meet",
"Icon": "images/plugin_icon",
"URL": "https://github.com/ChrisRegado/streamdeck-googlemeet",
"Version": "1.3.0",
"Version": "1.4.0",
"Category": "Google Meet",
"CategoryIcon": "images/category_icon",
"OS": [
Expand Down
4 changes: 2 additions & 2 deletions streamdeck-plugin/src/event_handlers/base_event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ async def on_stream_deck_event(self, event: dict) -> None:
target_action = event.get("action")

action_matches_on_prefix = self.STREAM_DECK_ACTION_PREFIX is not None \
and target_action is not None \
and target_action.startswith(self.STREAM_DECK_ACTION_PREFIX)
and target_action is not None \
and target_action.startswith(self.STREAM_DECK_ACTION_PREFIX)

if target_action != self.STREAM_DECK_ACTION and not action_matches_on_prefix:
# This message is probably intended for some other event handler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@ class TestEventHandler(EventHandler):
STREAM_DECK_ACTION = "com.test.action"


class TestPrefixedEventHandler(EventHandler):
STREAM_DECK_ACTION_PREFIX = "com.test.prefixedaction"


def make_mocked_event_handler():
return TestEventHandler(MagicMock(), MagicMock())


def make_mocked_prefixed_event_handler():
return TestPrefixedEventHandler(MagicMock(), MagicMock())


class BaseEventHandlerTests(IsolatedAsyncioTestCase):

async def test_key_up_called(self):
Expand All @@ -26,9 +34,42 @@ async def test_key_up_called(self):

handler._key_up_handler.assert_called_once_with(test_event)

async def test_action_prefix_match(self):
"""
Tests that handlers match inbound events based on action prefixes.
"""
handler = make_mocked_prefixed_event_handler()
test_event = {"event": "keyUp",
"action": f"{handler.STREAM_DECK_ACTION_PREFIX}.testaction"}
handler._key_up_handler = AsyncMock()

await handler.on_stream_deck_event(test_event)

handler._key_up_handler.assert_called_once_with(test_event)

async def test_double_action_match(self):
"""
Tests that handlers match inbound events when both the exact and prefix
comparisons pass, and that only one trigger happens.
"""

class DoubleMatchEventHandler(EventHandler):
STREAM_DECK_ACTION = "com.test.action"
STREAM_DECK_ACTION_PREFIX = STREAM_DECK_ACTION

handler = DoubleMatchEventHandler(MagicMock(), MagicMock())
test_event = {"event": "keyUp",
"action": handler.STREAM_DECK_ACTION}
handler._key_up_handler = AsyncMock()

await handler.on_stream_deck_event(test_event)

handler._key_up_handler.assert_called_once_with(test_event)

async def test_only_called_for_specified_action(self):
"""
Tests that handler methods are NOT called for other actions.
Tests that handler methods are NOT called for actions that don't match
this handler's action filter.
"""
handler = make_mocked_event_handler()
test_event = {"event": "keyUp", "action": "notmyaction"}
Expand All @@ -38,6 +79,19 @@ async def test_only_called_for_specified_action(self):

handler._key_up_handler.assert_not_called()

async def test_only_called_for_specified_prefixed_action(self):
"""
Tests that handler methods are NOT called for other actions that don't
match our desired action prefix.
"""
handler = make_mocked_prefixed_event_handler()
test_event = {"event": "keyUp", "action": "notmyaction"}
handler._key_up_handler = AsyncMock()

await handler.on_stream_deck_event(test_event)

handler._key_up_handler.assert_not_called()

async def test_will_appear_called(self):
"""
Tests that the willAppear handler is called for desired Stream Deck events.
Expand Down

0 comments on commit e194627

Please sign in to comment.