Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunkLightTuna committed Dec 15, 2023
1 parent 435bd92 commit ab5b7ae
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"oronder.Auth-Token": "Auth Token",
"oronder.Discord-Server-Id": "Discord Server Id",
"oronder.Fetch-Discord-User-Ids": "Fetch Discord User Ids",
"oronder.Full-Sync": "Full Sync",
"oronder.Full-Sync": "Manually Sync All Actors",
"oronder.Fetching-Discord-Ids": "Fetching Discord Ids",
"oronder.Oronder-Configuration": "Oronder Configuration",
"oronder.Configure-Oronder": "Configure Oronder",
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
},
"scripts": {
"build": "esbuild src/module.mjs --bundle --minify --format=esm --outdir=dist",
"build-dev": "esbuild src/module.mjs --bundle --sourcemap=inline --format=esm --outdir=dist && mkdir -p ../foundry_data/Data/modules/oronder/ && cp -r ./* ../foundry_data/Data/modules/oronder/",
"build-dev-win": "esbuild src/module.mjs --bundle --sourcemap=inline --format=esm --outdir=dist && mkdir ..\\foundry_data\\Data\\modules\\oronder\\ && xcopy /E /Y .\\* ..\\foundry_data\\Data\\modules\\oronder\\"
"build-dev": "esbuild src/module.mjs --bundle --sourcemap=inline --format=esm --outdir=dist"
}
}
2 changes: 1 addition & 1 deletion src/module.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Hooks.on("createActor", async (actor, data, options, userId) => {
await sync_actor(actor)
})
Hooks.on("updateActor", async (actor, data, options, userId) => {
if ('currency' in data?.system) {
if ((data?.system || []).includes('currency')) {
//todo handle currency
}
await sync_actor(actor)
Expand Down
22 changes: 10 additions & 12 deletions src/settings-form-application.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export class OronderSettingsFormApplication extends FormApplication {
const requestOptions = this._requestOptions(this.object.guild_id, this.object.auth)
let valid_config = false
await fetch(`${ORONDER_BASE_URL}/validate_discord_ids?${queryParams}`, requestOptions)
.then(self._handle_json_response)
.then(result => {
const invalid_player_names = result.map(invalid_discord_id => {
.then(this._handle_json_response)
.then(invalid_discord_ids => {
const invalid_player_names = invalid_discord_ids.map(invalid_discord_id => {
return this.object.players.find(p => p.discord_id === invalid_discord_id).foundry_name
})
if (invalid_player_names.length) {
Expand Down Expand Up @@ -168,16 +168,14 @@ export class OronderSettingsFormApplication extends FormApplication {
const requestOptions = this._requestOptions(this.object.guild_id, this.object.auth)

await fetch(`${ORONDER_BASE_URL}/discord_id?${queryParams}`, requestOptions)
.then(self._handle_json_response)
.then(async result => {
.then(this._handle_json_response)
.then(result => {
for (const [foundry_name, discord_user_id] of Object.entries(result)) {
this.object.players.find(p => p.foundry_name === foundry_name).discord_id = discord_user_id
}

await full_sync()
})
.catch(error => {
Logger.logError(error)
.catch(e => {
Logger.logError(e)
})

this.object.fetch_button_icon = "fa-solid fa-rotate"
Expand All @@ -188,11 +186,11 @@ export class OronderSettingsFormApplication extends FormApplication {
_handle_json_response(response) {
if (!response.ok) {
if (response.status === 401) {
Logger.logError(game.i18n.localize("oronder.Invalid-Auth"));
throw new Error(game.i18n.localize("oronder.Invalid-Auth"))
} else if (response.status === 400) {
Logger.logError(game.i18n.localize("oronder.Server-Id-NaN"));
throw new Error(game.i18n.localize("oronder.Server-Id-NaN"))
} else {
Logger.logError(game.i18n.localize("oronder.Unexpected-Error"));
throw new Error(game.i18n.localize("oronder.Unexpected-Error"))
}
}
return response.json()
Expand Down

0 comments on commit ab5b7ae

Please sign in to comment.