mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 01:29:22 +00:00
Clean up System a tiny bit
This commit is contained in:
parent
9fd7f050b4
commit
e2240a67cd
2 changed files with 25 additions and 13 deletions
|
|
@ -15,13 +15,24 @@ class MakiObject {
|
|||
children: MakiObject[];
|
||||
js_annotations: Object;
|
||||
|
||||
constructor(node: XmlNode, parent: MakiObject, annotations: Object = {}) {
|
||||
this._node = node;
|
||||
constructor(
|
||||
node: XmlNode | null,
|
||||
parent: MakiObject,
|
||||
annotations: Object = {}
|
||||
) {
|
||||
if (node) {
|
||||
this._node = node;
|
||||
this._uid = node.uid;
|
||||
this.attributes = node.attributes || {};
|
||||
this.name = node.name;
|
||||
} else {
|
||||
// This feels like a hack.
|
||||
this._node = {
|
||||
children: [],
|
||||
attributes: {},
|
||||
uid: Utils.getId(),
|
||||
name: this.getclassname().toLowerCase(),
|
||||
};
|
||||
this._uid = Utils.getId();
|
||||
// When dynamically creating an object with `new` we have no underlying node
|
||||
this.attributes = {};
|
||||
|
|
|
|||
|
|
@ -13,19 +13,19 @@ import { Context } from "react";
|
|||
import GuiObject from "./GuiObject";
|
||||
|
||||
class System extends MakiObject {
|
||||
scriptGroup: Group;
|
||||
root: MakiObject;
|
||||
_scriptGroup: Group;
|
||||
_root: MakiObject;
|
||||
_store: ModernStore;
|
||||
_privateInt: Map<string, Map<string, number>>;
|
||||
_privateString: Map<string, Map<string, string>>;
|
||||
constructor(scriptGroup, store: ModernStore) {
|
||||
super(null, null, {});
|
||||
constructor(scriptGroup: Group | null, store: ModernStore) {
|
||||
super(null, null);
|
||||
this._store = store;
|
||||
|
||||
this.scriptGroup = scriptGroup == null ? new Group() : scriptGroup;
|
||||
this.root = scriptGroup;
|
||||
while (this.root.parent) {
|
||||
this.root = this.root.parent;
|
||||
this._scriptGroup = scriptGroup == null ? new Group() : scriptGroup;
|
||||
this._root = this._scriptGroup;
|
||||
while (this._root.parent) {
|
||||
this._root = this._root.parent;
|
||||
}
|
||||
// TODO: Replace these with a DefaultMap once we have one.
|
||||
this._privateInt = new Map();
|
||||
|
|
@ -47,11 +47,11 @@ class System extends MakiObject {
|
|||
}
|
||||
|
||||
getscriptgroup() {
|
||||
return this.scriptGroup;
|
||||
return this._scriptGroup;
|
||||
}
|
||||
|
||||
getcontainer(id: string) {
|
||||
return findDescendantByTypeAndId(this.root, "container", id);
|
||||
return findDescendantByTypeAndId(this._root, "container", id);
|
||||
}
|
||||
|
||||
getruntimeversion() {
|
||||
|
|
@ -127,6 +127,7 @@ class System extends MakiObject {
|
|||
if (!this._privateInt.has(section)) {
|
||||
return defvalue;
|
||||
}
|
||||
// @ts-ignore We know this section exists
|
||||
return this._privateInt.get(section).get(item);
|
||||
}
|
||||
|
||||
|
|
@ -508,7 +509,7 @@ class System extends MakiObject {
|
|||
}
|
||||
|
||||
// Based on https://stackoverflow.com/questions/11887934/how-to-check-if-the-dst-daylight-saving-time-is-in-effect-and-if-it-is-whats
|
||||
_stdTimezoneOffset(date) {
|
||||
_stdTimezoneOffset(date: Date): number {
|
||||
const jan = new Date(date.getFullYear(), 0, 1);
|
||||
const jul = new Date(date.getFullYear(), 6, 1);
|
||||
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue