mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-28 05:15:54 +00:00
Apparently, there can be ID mismatches with chat and users. It's crazy stuff. Just log a warning when it happens and try to correct. Also, change tokenizer priority for mentions vs emotes.
This commit is contained in:
parent
df874da420
commit
2eb92a7075
2 changed files with 24 additions and 8 deletions
|
@ -282,7 +282,7 @@ export default class Chat extends Module {
|
|||
}
|
||||
|
||||
|
||||
getUser(id, login, no_create, no_login) {
|
||||
getUser(id, login, no_create, no_login, error = false) {
|
||||
let user;
|
||||
if ( id && typeof id === 'number' )
|
||||
id = `${id}`;
|
||||
|
@ -302,8 +302,15 @@ export default class Chat extends Module {
|
|||
if ( id && id !== user.id ) {
|
||||
// If the ID isn't what we expected, something is very wrong here.
|
||||
// Blame name changes.
|
||||
if ( user.id )
|
||||
throw new Error('id mismatch');
|
||||
if ( user.id ) {
|
||||
this.log.warn(`Data mismatch for user #${id} -- Stored ID: ${user.id} -- Login: ${login} -- Stored Login: ${user.login}`);
|
||||
if ( error )
|
||||
throw new Error('id mismatch');
|
||||
|
||||
// Remove the old reference if we're going with this.
|
||||
if ( this.user_ids[user.id] === user )
|
||||
this.user_ids[user.id] = null;
|
||||
}
|
||||
|
||||
// Otherwise, we're just here to set the ID.
|
||||
user._id = id;
|
||||
|
@ -330,7 +337,7 @@ export default class Chat extends Module {
|
|||
}
|
||||
|
||||
|
||||
getRoom(id, login, no_create, no_login) {
|
||||
getRoom(id, login, no_create, no_login, error = false) {
|
||||
let room;
|
||||
if ( id && typeof id === 'number' )
|
||||
id = `${id}`;
|
||||
|
@ -350,8 +357,15 @@ export default class Chat extends Module {
|
|||
if ( id && id !== room.id ) {
|
||||
// If the ID isn't what we expected, something is very wrong here.
|
||||
// Blame name changes. Or React not being atomic.
|
||||
if ( room.id )
|
||||
throw new Error('id mismatch');
|
||||
if ( room.id ) {
|
||||
this.log.warn(`Data mismatch for room #${id} -- Stored ID: ${room.id} -- Login: ${login} -- Stored Login: ${room.login}`);
|
||||
if ( error )
|
||||
throw new Error('id mismatch');
|
||||
|
||||
// Remove the old reference if we're going with this.
|
||||
if ( this.room_ids[room.id] === room )
|
||||
this.room_ids[room.id] = null;
|
||||
}
|
||||
|
||||
// Otherwise, we're just here to set the ID.
|
||||
room._id = id;
|
||||
|
|
|
@ -206,7 +206,7 @@ Links.tooltip.delayHide = function(target) {
|
|||
|
||||
export const Mentions = {
|
||||
type: 'mention',
|
||||
priority: 40,
|
||||
priority: 0,
|
||||
|
||||
render(token, createElement) {
|
||||
return (<strong class={`chat-line__message-mention${token.me ? ' ffz--mention-me' : ''}`}>
|
||||
|
@ -277,6 +277,7 @@ export const Mentions = {
|
|||
|
||||
export const CheerEmotes = {
|
||||
type: 'cheer',
|
||||
priority: 40,
|
||||
|
||||
render(token, createElement) {
|
||||
return (<span
|
||||
|
@ -446,6 +447,7 @@ export const CheerEmotes = {
|
|||
|
||||
export const AddonEmotes = {
|
||||
type: 'emote',
|
||||
priority: 10,
|
||||
|
||||
render(token, createElement) {
|
||||
const mods = token.modifiers || [], ml = mods.length,
|
||||
|
@ -643,7 +645,7 @@ export const AddonEmotes = {
|
|||
|
||||
export const TwitchEmotes = {
|
||||
type: 'twitch-emote',
|
||||
priority: 10,
|
||||
priority: 20,
|
||||
|
||||
process(tokens, msg) {
|
||||
if ( ! msg.emotes )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue