Skip to content

Commit

Permalink
Merge pull request #149 from duncte123/oengus-update
Browse files Browse the repository at this point in the history
Use new oengus display names and support the youtube connection
  • Loading branch information
zoton2 authored May 11, 2024
2 parents 4a0f615 + 1c4877d commit 233fd76
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
project: 'tsconfig.browser.json',
project: path.join(__dirname, 'tsconfig.browser.json'),
extraFileExtensions: ['.vue'],
ecmaVersion: 2020,
},
Expand All @@ -31,7 +31,7 @@ module.exports = {
'import/resolver': {
typescript: {
// This is needed to properly resolve paths.
project: 'tsconfig.browser.json',
project: path.join(__dirname, 'tsconfig.browser.json'),
},
webpack: {
config: path.join(__dirname, 'webpack.config.mjs'),
Expand Down
6 changes: 4 additions & 2 deletions .eslintrc.extension.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const path = require('path');

module.exports = {
root: true,
env: {
node: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.extension.json',
project: path.join(__dirname, 'tsconfig.extension.json'),
},
plugins: [
'@typescript-eslint',
Expand All @@ -21,7 +23,7 @@ module.exports = {
'import/resolver': {
typescript: {
// This is needed to properly resolve paths.
project: 'tsconfig.extension.json',
project: path.join(__dirname, 'tsconfig.extension.json'),
},
},
'import/extensions': ['.js', '.jsx', '.ts', '.tsx'],
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,4 @@ dist
/dashboard/
/extension/
/graphics/
.idea/
4 changes: 3 additions & 1 deletion configschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@
"default": "SHORTNAME"
},
"useJapanese": {
"$comment": "DEPRECATED; should be removed in next major version (2.x > 3.x).",
"description": "DEPRECATED; left for compatibility reasons.",
"type": "boolean",
"default": false
},
Expand Down Expand Up @@ -271,4 +273,4 @@
"horaro",
"oengus"
]
}
}
5 changes: 4 additions & 1 deletion schemas/reused/RunData.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
"properties": {
"twitch": {
"type": "string"
},
"youtube": {
"type": "string"
}
}
},
Expand Down Expand Up @@ -136,4 +139,4 @@
"customData",
"id"
]
}
}
11 changes: 0 additions & 11 deletions src/dashboard/oengus-schedule-import/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"shortname": "Oengus Marathon Shortname",
"helpText": "Insert the Oengus marathon shortname (not including \"/schedule\") above and press the \"Import Schedule Data\" button.",
"importInProgressHelpText": "Import currently in progress...",
"useJapaneseNames": "Use Japanese names?",
"import": "Import Schedule Data",
"importProgress": "Importing {item}/{total}"
},
Expand All @@ -14,7 +13,6 @@
"shortname": "Oengusマラソンの略称",
"helpText": "上記にインポートしたいOengusのイベントの略称を入力し(\"/schedule\"を含めないでください)、「スケジュール情報のインポート」ボタンを押してください。",
"importInProgressHelpText": "インポート処理の実行中...",
"useJapaneseNames": "日本語ユーザーネームを使用しますか?",
"import": "スケジュール情報のインポート",
"importProgress": "{item}/{total}件をインポート"
}
Expand All @@ -38,13 +36,6 @@
<div>
{{ $t('helpText') }}
</div>
<!-- Switch use Japanese or not for importing data -->
<v-switch
v-model="useJapanese"
class="ma-1"
hide-details
:label="$t('useJapaneseNames')"
/>
</template>
<template v-else>
{{ $t('importInProgressHelpText') }}
Expand Down Expand Up @@ -82,7 +73,6 @@ import { replicantNS } from '../_misc/replicant_store';
export default class extends Vue {
@replicantNS.State((s) => s.reps.oengusImportStatus) readonly importStatus!: OengusImportStatus;
marathonShort = nodecg.bundleConfig.oengus.defaultMarathon || '';
useJapanese = nodecg.bundleConfig.oengus.useJapanese;
importConfirm(): void {
const dialog = getDialog('alert-dialog') as Alert.Dialog;
Expand All @@ -99,7 +89,6 @@ export default class extends Vue {
try {
await nodecg.sendMessage('importOengusSchedule', {
marathonShort: this.marathonShort,
useJapanese: this.useJapanese,
});
} catch (err) {
// catch
Expand Down
8 changes: 8 additions & 0 deletions src/dashboard/run-modification-dialog/components/Player.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
"en": {
"name": "Name",
"twitch": "Twitch",
"youtube": "YouTube",
"countryCode": "Country Code",
"removePlayer": "Remove Player",
"pronouns": "Pronouns"
},
"ja": {
"name": "プレイヤー名",
"twitch": "Twitch ID",
"youtube": "YouTube",
"countryCode": "国名コード",
"removePlayer": "プレイヤーの削除",
"pronouns": "Pronouns"
Expand All @@ -33,6 +35,12 @@
:label="$t('twitch')"
left-border
/>
<text-input
:value="playerData.social.youtube"
@input="updatePlayerDataProp('social.youtube', $event)"
:label="$t('youtube')"
left-border
/>
<text-input
:value="playerData.country"
@input="updatePlayerDataProp('country', $event)"
Expand Down
11 changes: 6 additions & 5 deletions src/extension/oengus-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ function resetImportStatus(): void {
/**
* Import schedule data in from Oengus.
* @param marathonShort Oengus' marathon shortname you want to import.
* @param useJapanese If you want to use usernameJapanese from the user data.
*/
async function importSchedule(marathonShort: string, useJapanese: boolean): Promise<void> {
async function importSchedule(marathonShort: string): Promise<void> {
try {
oengusImportStatus.value.importing = true;
const marathonResp = await get(`/marathons/${marathonShort}`);
Expand Down Expand Up @@ -182,16 +181,18 @@ async function importSchedule(marathonShort: string, useJapanese: boolean): Prom
};
const playerTwitch = runner.connections
?.find((c) => c.platform === 'TWITCH')?.username || runner.twitchName;
const playerYoutube = runner.connections
?.find((c) => c.platform === 'YOUTUBE')?.username;
const playerPronouns = typeof runner.pronouns === 'string'
? runner.pronouns.split(',')
: runner.pronouns;
const player: RunDataPlayer = {
name: (useJapanese && runner.usernameJapanese)
? runner.usernameJapanese : runner.username,
name: runner.displayName || runner.username,
id: uuid(),
teamID: team.id,
social: {
twitch: playerTwitch || undefined,
youtube: playerYoutube || undefined,
},
country: runner.country?.toLowerCase() || undefined,
pronouns: playerPronouns?.join(', ') || undefined,
Expand Down Expand Up @@ -240,7 +241,7 @@ nodecg.listenFor('importOengusSchedule', async (data, ack) => {
throw new Error('Already importing schedule');
}
nodecg.log.info('[Oengus Import] Started importing schedule');
await importSchedule(data.marathonShort, data.useJapanese);
await importSchedule(data.marathonShort);
nodecg.log.info('[Oengus Import] Successfully imported schedule from Oengus');
processAck(ack, null);
} catch (err) {
Expand Down
5 changes: 3 additions & 2 deletions src/types/Oengus.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export enum OengusRunType {
export interface OengusUser {
id: number;
username: string;
usernameJapanese: string | null;
displayName: string;
usernameJapanese: string | null; // deprecated
enabled: boolean;
twitterName?: string | null; // deprecated
twitchName?: string | null; // deprecated
Expand All @@ -49,7 +50,7 @@ export interface OengusUser {

export interface OengusUserConnections {
id: number;
platform: 'DISCORD' | 'SPEEDRUNCOM' | 'TWITCH' | 'TWITTER';
platform: 'DISCORD' | 'SPEEDRUNCOM' | 'TWITCH' | 'TWITTER' | 'YOUTUBE';
username: string;
usernameValidForPlatform: boolean;
}
Expand Down
1 change: 1 addition & 0 deletions src/types/RunData.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface RunDataPlayer {
pronouns?: string;
social: {
twitch?: string;
youtube?: string;
};
customData: {
[key: string]: string;
Expand Down
3 changes: 3 additions & 0 deletions src/types/schemas/configschema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export interface Configschema {
horaro: Horaro;
oengus: {
defaultMarathon: string;
/**
* DEPRECATED; left for compatibility reasons.
*/
useJapanese: boolean;
ignoreGamesWhileImporting?: IgnoreGamesWhileImporting;
disableSpeedrunComLookup: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/types/schemas/runDataActiveRun.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface RunData {
pronouns?: string;
social: {
twitch?: string;
youtube?: string;
};
customData: {
[k: string]: string;
Expand Down
1 change: 1 addition & 0 deletions src/types/schemas/runDataArray.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface RunData {
pronouns?: string;
social: {
twitch?: string;
youtube?: string;
};
customData: {
[k: string]: string;
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const config = (name) => {
},
plugins: [
new TsConfigPathsPlugin({
configFile: 'tsconfig.browser.json',
configFile: path.resolve(__dirname, 'tsconfig.browser.json'),
}),
],
},
Expand Down

0 comments on commit 233fd76

Please sign in to comment.