mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-09 07:40:53 +00:00
Fix potential issues trying to operate on destroyed users / rooms.
This commit is contained in:
parent
411b2d6390
commit
802d19bc00
2 changed files with 22 additions and 0 deletions
|
@ -60,6 +60,8 @@ export default class Room {
|
||||||
|
|
||||||
this.emote_sets = null;
|
this.emote_sets = null;
|
||||||
this.style = null;
|
this.style = null;
|
||||||
|
this.users = null;
|
||||||
|
this.user_ids = null;
|
||||||
|
|
||||||
if ( this._login ) {
|
if ( this._login ) {
|
||||||
if ( this.manager.rooms[this._login] === this )
|
if ( this.manager.rooms[this._login] === this )
|
||||||
|
@ -108,6 +110,9 @@ export default class Room {
|
||||||
|
|
||||||
|
|
||||||
getUser(id, login, no_create, no_login) {
|
getUser(id, login, no_create, no_login) {
|
||||||
|
if ( this.destroyed )
|
||||||
|
return null;
|
||||||
|
|
||||||
let user;
|
let user;
|
||||||
if ( id && typeof id === 'number' )
|
if ( id && typeof id === 'number' )
|
||||||
id = `${id}`;
|
id = `${id}`;
|
||||||
|
@ -240,6 +245,9 @@ export default class Room {
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
|
|
||||||
addSet(provider, set_id, data) {
|
addSet(provider, set_id, data) {
|
||||||
|
if ( this.destroyed )
|
||||||
|
return;
|
||||||
|
|
||||||
let changed = false;
|
let changed = false;
|
||||||
if ( ! this.emote_sets.sourceIncludes(provider, set_id) ) {
|
if ( ! this.emote_sets.sourceIncludes(provider, set_id) ) {
|
||||||
this.emote_sets.push(provider, set_id);
|
this.emote_sets.push(provider, set_id);
|
||||||
|
@ -255,6 +263,9 @@ export default class Room {
|
||||||
}
|
}
|
||||||
|
|
||||||
removeSet(provider, set_id) {
|
removeSet(provider, set_id) {
|
||||||
|
if ( this.destroyed )
|
||||||
|
return;
|
||||||
|
|
||||||
if ( this.emote_sets.sourceIncludes(provider, set_id) ) {
|
if ( this.emote_sets.sourceIncludes(provider, set_id) ) {
|
||||||
this.emote_sets.remove(provider, set_id);
|
this.emote_sets.remove(provider, set_id);
|
||||||
this.manager.emotes.unrefSet(set_id);
|
this.manager.emotes.unrefSet(set_id);
|
||||||
|
@ -305,6 +316,7 @@ export default class Room {
|
||||||
buildModBadgeCSS() {
|
buildModBadgeCSS() {
|
||||||
if ( this.destroyed )
|
if ( this.destroyed )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( ! this.data || ! this.data.mod_urls || ! this.manager.context.get('chat.badges.custom-mod') )
|
if ( ! this.data || ! this.data.mod_urls || ! this.manager.context.get('chat.badges.custom-mod') )
|
||||||
return this.style.delete('mod-badge');
|
return this.style.delete('mod-badge');
|
||||||
|
|
||||||
|
@ -331,6 +343,7 @@ export default class Room {
|
||||||
buildBadgeCSS() {
|
buildBadgeCSS() {
|
||||||
if ( this.destroyed )
|
if ( this.destroyed )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( ! this.badges )
|
if ( ! this.badges )
|
||||||
return this.style.delete('badges');
|
return this.style.delete('badges');
|
||||||
|
|
||||||
|
@ -379,6 +392,7 @@ export default class Room {
|
||||||
buildBitsCSS() {
|
buildBitsCSS() {
|
||||||
if ( this.destroyed )
|
if ( this.destroyed )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( ! this.bitsConfig )
|
if ( ! this.bitsConfig )
|
||||||
return this.style.delete('bits');
|
return this.style.delete('bits');
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ export default class User {
|
||||||
|
|
||||||
for(const set_id of this.emote_sets._cache)
|
for(const set_id of this.emote_sets._cache)
|
||||||
this.manager.emotes.unrefSet(set_id);
|
this.manager.emotes.unrefSet(set_id);
|
||||||
|
|
||||||
|
this.emote_sets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get id() {
|
get id() {
|
||||||
|
@ -109,6 +111,9 @@ export default class User {
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
|
|
||||||
addSet(provider, set_id) {
|
addSet(provider, set_id) {
|
||||||
|
if ( this.destroyed )
|
||||||
|
return;
|
||||||
|
|
||||||
if ( ! this.emote_sets.sourceIncludes(provider, set_id) ) {
|
if ( ! this.emote_sets.sourceIncludes(provider, set_id) ) {
|
||||||
this.emote_sets.push(provider, set_id);
|
this.emote_sets.push(provider, set_id);
|
||||||
this.manager.emotes.refSet(set_id);
|
this.manager.emotes.refSet(set_id);
|
||||||
|
@ -118,6 +123,9 @@ export default class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
removeSet(provider, set_id) {
|
removeSet(provider, set_id) {
|
||||||
|
if ( this.destroyed )
|
||||||
|
return;
|
||||||
|
|
||||||
if ( this.emote_sets.sourceIncludes(provider, set_id) ) {
|
if ( this.emote_sets.sourceIncludes(provider, set_id) ) {
|
||||||
this.emote_sets.remove(provider, set_id);
|
this.emote_sets.remove(provider, set_id);
|
||||||
this.manager.emotes.unrefSet(set_id);
|
this.manager.emotes.unrefSet(set_id);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue