Skip to content

Commit

Permalink
🔧 fix(index.ts): remove mode prompt and mode property from generateTr…
Browse files Browse the repository at this point in the history
…aktCredentials function as it is no longer needed
  • Loading branch information
RagnarLothbrok-Odin committed Dec 19, 2023
1 parent 94011ff commit b1aa705
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ interface Configuration {
clientSecret: string;
discordClientId: string;
oAuth?: string;
mode: string;
}

interface TraktContent {
Expand Down Expand Up @@ -246,7 +245,7 @@ class TraktInstance {
const elapsedDuration = DateTime.local().diff(DateTime.fromISO(watching.started_at), 'seconds').seconds;

// Initialize progress bar if it doesn't exist
if (!progressBar && this.credentials?.mode === 'progress_bar') {
if (!progressBar) {
progressBar = await generateProgressBar();
progressBar.start(totalDuration, elapsedDuration, {
content: detail,
Expand All @@ -258,11 +257,6 @@ class TraktInstance {
// If the progressBar instance exists, update its progress with the elapsed duration
if (progressBar) progressBar.update(elapsedDuration);

// If the mode is set to standard cli logging
if (this.credentials?.mode === 'standard_log') {
console.log(`${formatDate()} | ${'Trakt Playing:'.red.bold} ${detail} (${movie.year})`);
}

// Update Trakt content details
return { ...traktContent, details: detail };
}
Expand All @@ -286,7 +280,7 @@ class TraktInstance {
const elapsedDuration = DateTime.local().diff(DateTime.fromISO(watching.started_at), 'seconds').seconds;

// Initialize progress bar if it doesn't exist
if (!progressBar && this.credentials?.mode === 'progress_bar') {
if (!progressBar) {
progressBar = await generateProgressBar();
progressBar.start(totalDuration, elapsedDuration, {
content: `${detail} - ${state}`,
Expand All @@ -298,11 +292,6 @@ class TraktInstance {
// If the progressBar instance exists, update its progress with the elapsed duration
if (progressBar) progressBar.update(elapsedDuration);

// If the mode is set to standard cli logging
if (this.credentials?.mode === 'standard_log') {
console.log(`${formatDate()} | ${'Trakt Playing:'.red.bold} ${detail} - ${state}`);
}

// Update Trakt content details and state
return { ...traktContent, details: detail, state };
}
Expand Down Expand Up @@ -503,22 +492,10 @@ async function generateTraktCredentials(): Promise<Configuration | null> {
}`,
);

const modePrompt = [{
type: 'select',
name: 'mode',
message: 'Please select which UI you would prefer.',
initial: 0,
choices: [
{ name: 'Progress Bar', message: 'Progress Bar', value: '#ff0000' },
{ name: 'Standard Log', message: 'Standard Log', value: '#00ff00' },
],
}];

return prompt([
generatePromptConfig('input', 'clientId', 'Please provide your Trakt Client ID:'),
generatePromptConfig('input', 'clientSecret', 'Please provide your Trakt Client Secret:'),
generatePromptConfig('input', 'discordClientId', 'Please provide your Discord Client ID:'),
...modePrompt,
]);
}

Expand Down Expand Up @@ -563,7 +540,6 @@ async function authoriseTrakt(gen: Configuration) {
clientId: gen.clientId,
clientSecret: gen.clientSecret,
discordClientId: gen.discordClientId,
mode: gen.mode === 'Progress Bar' ? 'progress_bar' : 'standard_log',
};

try {
Expand Down

0 comments on commit b1aa705

Please sign in to comment.