-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f888783
commit 6c8168f
Showing
8 changed files
with
779 additions
and
95 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ | |
.message { | ||
padding: 2px 0; | ||
display: flex; | ||
align-items: baseline; | ||
align-items: center; | ||
} | ||
|
||
.username { | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useState, useEffect, useCallback } from "react"; | ||
import { EmoteFetcher, EmoteParser } from "@mkody/twitch-emoticons"; | ||
|
||
const fetcher = new EmoteFetcher(); | ||
const parser = new EmoteParser(fetcher, { | ||
template: '<img class="emote" alt="{name}" src="{link}">', | ||
match: /(\w+)+?/g, | ||
}); | ||
|
||
export function useParseEmotes({ channelId }) { | ||
const [loading, setLoading] = useState(true); | ||
const [loadEmotes, setLoadEmotes] = useState(1); | ||
|
||
useEffect(() => { | ||
Promise.all([ | ||
fetcher.fetchBTTVEmotes(), | ||
fetcher.fetchBTTVEmotes(channelId), | ||
fetcher.fetchSevenTVEmotes(), | ||
fetcher.fetchSevenTVEmotes(channelId), | ||
fetcher.fetchFFZEmotes(), | ||
fetcher.fetchFFZEmotes(channelId), | ||
]) | ||
.then(() => { | ||
setLoading(false); | ||
}) | ||
.catch((err) => { | ||
console.error("Error loading emotes..."); | ||
console.error(err); | ||
setLoadEmotes((prev) => prev + 1); | ||
}); | ||
}, [loadEmotes]); | ||
|
||
const parseEmoteMessage = useCallback((message) => { | ||
if (!loading) { | ||
return message; | ||
} | ||
return parser.parse(message); | ||
}, []); | ||
|
||
return { parseEmoteMessage, loading }; | ||
} |