mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-13 17:40:53 +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;
|
let user;
|
||||||
if ( id && typeof id === 'number' )
|
if ( id && typeof id === 'number' )
|
||||||
id = `${id}`;
|
id = `${id}`;
|
||||||
|
@ -302,8 +302,15 @@ export default class Chat extends Module {
|
||||||
if ( id && id !== user.id ) {
|
if ( id && id !== user.id ) {
|
||||||
// If the ID isn't what we expected, something is very wrong here.
|
// If the ID isn't what we expected, something is very wrong here.
|
||||||
// Blame name changes.
|
// Blame name changes.
|
||||||
if ( user.id )
|
if ( user.id ) {
|
||||||
throw new Error('id mismatch');
|
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.
|
// Otherwise, we're just here to set the ID.
|
||||||
user._id = 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;
|
let room;
|
||||||
if ( id && typeof id === 'number' )
|
if ( id && typeof id === 'number' )
|
||||||
id = `${id}`;
|
id = `${id}`;
|
||||||
|
@ -350,8 +357,15 @@ export default class Chat extends Module {
|
||||||
if ( id && id !== room.id ) {
|
if ( id && id !== room.id ) {
|
||||||
// If the ID isn't what we expected, something is very wrong here.
|
// If the ID isn't what we expected, something is very wrong here.
|
||||||
// Blame name changes. Or React not being atomic.
|
// Blame name changes. Or React not being atomic.
|
||||||
if ( room.id )
|
if ( room.id ) {
|
||||||
throw new Error('id mismatch');
|
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.
|
// Otherwise, we're just here to set the ID.
|
||||||
room._id = id;
|
room._id = id;
|
||||||
|
|
|
@ -206,7 +206,7 @@ Links.tooltip.delayHide = function(target) {
|
||||||
|
|
||||||
export const Mentions = {
|
export const Mentions = {
|
||||||
type: 'mention',
|
type: 'mention',
|
||||||
priority: 40,
|
priority: 0,
|
||||||
|
|
||||||
render(token, createElement) {
|
render(token, createElement) {
|
||||||
return (<strong class={`chat-line__message-mention${token.me ? ' ffz--mention-me' : ''}`}>
|
return (<strong class={`chat-line__message-mention${token.me ? ' ffz--mention-me' : ''}`}>
|
||||||
|
@ -277,6 +277,7 @@ export const Mentions = {
|
||||||
|
|
||||||
export const CheerEmotes = {
|
export const CheerEmotes = {
|
||||||
type: 'cheer',
|
type: 'cheer',
|
||||||
|
priority: 40,
|
||||||
|
|
||||||
render(token, createElement) {
|
render(token, createElement) {
|
||||||
return (<span
|
return (<span
|
||||||
|
@ -446,6 +447,7 @@ export const CheerEmotes = {
|
||||||
|
|
||||||
export const AddonEmotes = {
|
export const AddonEmotes = {
|
||||||
type: 'emote',
|
type: 'emote',
|
||||||
|
priority: 10,
|
||||||
|
|
||||||
render(token, createElement) {
|
render(token, createElement) {
|
||||||
const mods = token.modifiers || [], ml = mods.length,
|
const mods = token.modifiers || [], ml = mods.length,
|
||||||
|
@ -643,7 +645,7 @@ export const AddonEmotes = {
|
||||||
|
|
||||||
export const TwitchEmotes = {
|
export const TwitchEmotes = {
|
||||||
type: 'twitch-emote',
|
type: 'twitch-emote',
|
||||||
priority: 10,
|
priority: 20,
|
||||||
|
|
||||||
process(tokens, msg) {
|
process(tokens, msg) {
|
||||||
if ( ! msg.emotes )
|
if ( ! msg.emotes )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue