Fix code style errors

Remove extra whitespace, use more consistent spacing, add missing
semicolons, using dangling commas, break up long lines, consistent
multiline operator placement, add missing JSDoc strings and so on.
This commit is contained in:
Hornwitser committed 2023-11-19 04:48:38 +01:00
1 parent 97e05c0610
commit 7314dc99c8
71 files changed
+403 -290

No files matched your search

+7 -5
View File
@@ -16,8 +16,9 @@ export function useHost(id: number): [ HostState, () => void ] {
function updateHost() {
// XXX optimize by requesting only the host in question
control.send(new lib.HostListRequest())
.then((hosts: lib.HostDetails[]) => {
control.send(
new lib.HostListRequest()
).then((hosts: lib.HostDetails[]) => {
let match = hosts.find(i => i.id === id);
if (!match) {
setHost({ missing: true });
@@ -35,7 +36,7 @@ export function useHost(id: number): [ HostState, () => void ] {
updateHost();
function updateHandler(newHost: lib.HostDetails) {
setHost({ ...newHost, loading:false, missing:false, present:true });
setHost({ ...newHost, loading: false, missing: false, present: true });
}
control.hostUpdate.subscribeToChannel(id, updateHandler);
@@ -52,8 +53,9 @@ export function useHostList() {
let [hostList, setHostList] = useState<lib.HostDetails[]>([]);
function updateHostList() {
control.send(new lib.HostListRequest())
.then((hosts: lib.HostDetails[]) => {
control.send(
new lib.HostListRequest()
).then((hosts: lib.HostDetails[]) => {
setHostList(hosts);
});
}
+8 -8
View File
@@ -29,14 +29,14 @@ export function useItemMetadata() {
let style = document.createElement("style");
document.head.appendChild(style);
for (let [name, meta] of itemMetadataCache) {
style.sheet!.insertRule(
`.item-${CSS.escape(name)} {
background-image: url("${window.staticRoot}static/${exportManifest.assets["item-spritesheet"]}");
background-repeat: no-repeat;
background-position: -${meta.x}px -${meta.y}px;
height: ${meta.size}px;
width: ${meta.size}px;
}`
style.sheet!.insertRule(`\
.item-${CSS.escape(name)} {
background-image: url("${window.staticRoot}static/${exportManifest.assets["item-spritesheet"]}");
background-repeat: no-repeat;
background-position: -${meta.x}px -${meta.y}px;
height: ${meta.size}px;
width: ${meta.size}px;
}`
);
}
setItemMetadata(itemMetadataCache);
+1 -1
View File
@@ -10,7 +10,7 @@ export function useSaves(instanceId?: number): lib.SaveDetails[] {
let [saves, setSaves] = useState<lib.SaveDetails[]>([]);
function updateSaves() {
control.sendTo({ instanceId:instanceId! }, new lib.InstanceListSavesRequest()).then(updatedSaves => {
control.sendTo({ instanceId: instanceId! }, new lib.InstanceListSavesRequest()).then(updatedSaves => {
setSaves(updatedSaves);
}).catch(err => {
logger.error(`Failed to list instance saves: ${err}`);
+3 -3
View File
@@ -53,9 +53,9 @@ export function sortLastSeen(userA:RawUserState, userB:RawUserState, instanceIdA
}
export type RawUserState = Partial<lib.RawUser> & {
loading?: Boolean;
present?: Boolean;
missing?: Boolean;
loading?: boolean;
present?: boolean;
missing?: boolean;
};
export function useUser(name: string): [RawUserState, () => void] {