mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-05 13:50:54 +00:00
4.61.0
* Changed: Replace the old Twitter widget on the FFZ Control Center's Home page with a custom Bluesky widget. * Fixed: Settings profile rules for the current channel and current category not functioning correctly. * Developer Changed: We TypeScript (a work-in-progress conversion) * Developer Fixed: The GraphQL inspector not properly displaying data.
This commit is contained in:
parent
31e7ce4ac5
commit
18491b0873
25 changed files with 846 additions and 208 deletions
|
@ -1,238 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
// ============================================================================
|
||||
// User
|
||||
// ============================================================================
|
||||
|
||||
import {SourcedSet} from 'utilities/object';
|
||||
|
||||
export default class User {
|
||||
constructor(manager, room, id, login) {
|
||||
this.manager = manager;
|
||||
this.room = room;
|
||||
|
||||
this.emote_sets = null; //new SourcedSet;
|
||||
this.badges = null; // new SourcedSet;
|
||||
|
||||
this._id = id;
|
||||
this.login = login;
|
||||
|
||||
if ( id )
|
||||
(room || manager).user_ids[id] = this;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.destroyed = true;
|
||||
|
||||
if ( this.emote_sets ) {
|
||||
for(const set_id of this.emote_sets._cache)
|
||||
this.manager.emotes.unrefSet(set_id);
|
||||
|
||||
this.emote_sets = null;
|
||||
}
|
||||
|
||||
if ( this.badges )
|
||||
this.badges = null;
|
||||
|
||||
const parent = this.room || this.manager;
|
||||
|
||||
if ( parent ) {
|
||||
if ( this._login && parent.users && parent.users[this._login] === this )
|
||||
parent.users[this._login] = null;
|
||||
|
||||
if ( parent.user_ids && parent.user_ids[this._id] === this )
|
||||
parent.user_ids[this._id] = null;
|
||||
}
|
||||
}
|
||||
|
||||
merge(other) {
|
||||
if ( ! this.login && other.login )
|
||||
this.login = other.login;
|
||||
|
||||
if ( other.emote_sets && other.emote_sets._sources ) {
|
||||
for(const [provider, sets] of other.emote_sets._sources.entries()) {
|
||||
for(const set_id of sets)
|
||||
this.addSet(provider, set_id);
|
||||
}
|
||||
}
|
||||
|
||||
if ( other.badges && other.badges._sources ) {
|
||||
for(const [provider, badges] of other.badges._sources.entries()) {
|
||||
for(const badge of badges)
|
||||
this.addBadge(provider, badge.id, badge);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_unloadAddon(addon_id) {
|
||||
// TODO: This
|
||||
return 0;
|
||||
}
|
||||
|
||||
get id() {
|
||||
return this._id;
|
||||
}
|
||||
|
||||
get login() {
|
||||
return this._login;
|
||||
}
|
||||
|
||||
set login(val) {
|
||||
if ( this._login === val )
|
||||
return;
|
||||
|
||||
const obj = this.room || this.manager;
|
||||
|
||||
if ( this._login ) {
|
||||
const old_user = obj.users[this._login];
|
||||
if ( old_user === this )
|
||||
obj.users[this._login] = null;
|
||||
}
|
||||
|
||||
this._login = val;
|
||||
if ( ! val )
|
||||
return;
|
||||
|
||||
const old_user = obj.users[val];
|
||||
if ( old_user && old_user !== this )
|
||||
old_user.login = null;
|
||||
|
||||
// Make sure we didn't have a funky loop thing happen.
|
||||
this._login = val;
|
||||
obj.users[val] = this;
|
||||
}
|
||||
|
||||
|
||||
// ========================================================================
|
||||
// Add Badges
|
||||
// ========================================================================
|
||||
|
||||
addBadge(provider, badge_id, data) {
|
||||
if ( this.destroyed )
|
||||
return;
|
||||
|
||||
if ( typeof badge_id === 'number' )
|
||||
badge_id = `${badge_id}`;
|
||||
|
||||
if ( data )
|
||||
data.id = badge_id;
|
||||
else
|
||||
data = {id: badge_id};
|
||||
|
||||
if ( ! this.badges )
|
||||
this.badges = new SourcedSet;
|
||||
|
||||
if ( this.badges.has(provider) )
|
||||
for(const old_b of this.badges.get(provider))
|
||||
if ( old_b.id == badge_id ) {
|
||||
Object.assign(old_b, data);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.badges.push(provider, data);
|
||||
//this.manager.badges.refBadge(badge_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
getBadge(badge_id) {
|
||||
if ( ! this.badges )
|
||||
return null;
|
||||
|
||||
for(const badge of this.badges._cache)
|
||||
if ( badge.id == badge_id )
|
||||
return badge;
|
||||
}
|
||||
|
||||
|
||||
removeBadge(provider, badge_id) {
|
||||
if ( ! this.badges || ! this.badges.has(provider) )
|
||||
return false;
|
||||
|
||||
for(const old_b of this.badges.get(provider))
|
||||
if ( old_b.id == badge_id ) {
|
||||
this.badges.remove(provider, old_b);
|
||||
//this.manager.badges.unrefBadge(badge_id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
removeAllBadges(provider) {
|
||||
if ( this.destroyed || ! this.badges )
|
||||
return false;
|
||||
|
||||
if ( ! this.badges.has(provider) )
|
||||
return false;
|
||||
|
||||
// Just yeet them all since we don't ref badges.
|
||||
this.badges.delete(provider);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ========================================================================
|
||||
// Emote Sets
|
||||
// ========================================================================
|
||||
|
||||
addSet(provider, set_id, data) {
|
||||
if ( this.destroyed )
|
||||
return;
|
||||
|
||||
if ( ! this.emote_sets )
|
||||
this.emote_sets = new SourcedSet;
|
||||
|
||||
if ( typeof set_id === 'number' )
|
||||
set_id = `${set_id}`;
|
||||
|
||||
let changed = false, added = false;
|
||||
if ( ! this.emote_sets.sourceIncludes(provider, set_id) ) {
|
||||
changed = ! this.emote_sets.includes(set_id);
|
||||
this.emote_sets.push(provider, set_id);
|
||||
added = true;
|
||||
}
|
||||
|
||||
if ( data )
|
||||
this.manager.emotes.loadSetData(set_id, data);
|
||||
|
||||
if ( changed ) {
|
||||
this.manager.emotes.refSet(set_id);
|
||||
this.manager.emotes.emit(':update-user-sets', this, provider, set_id, true);
|
||||
}
|
||||
|
||||
return added;
|
||||
}
|
||||
|
||||
removeAllSets(provider) {
|
||||
if ( this.destroyed || ! this.emote_sets )
|
||||
return false;
|
||||
|
||||
const sets = this.emote_sets.get(provider);
|
||||
if ( ! Array.isArray(sets) || ! sets.length )
|
||||
return false;
|
||||
|
||||
for(const set_id of sets)
|
||||
this.removeSet(provider, set_id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
removeSet(provider, set_id) {
|
||||
if ( this.destroyed || ! this.emote_sets )
|
||||
return;
|
||||
|
||||
if ( typeof set_id === 'number' )
|
||||
set_id = `${set_id}`;
|
||||
|
||||
if ( this.emote_sets.sourceIncludes(provider, set_id) ) {
|
||||
this.emote_sets.remove(provider, set_id);
|
||||
if ( ! this.emote_sets.includes(set_id) ) {
|
||||
this.manager.emotes.unrefSet(set_id);
|
||||
this.manager.emotes.emit(':update-user-sets', this, provider, set_id, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue