Skip to content

Commit 153770e

Browse files
committed
refactor: inline single use constants
The variable name does not provide any benefit
1 parent 2cdbf1f commit 153770e

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

source/lib/all-events.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import {EVENT_FILES_DIR, pullEventFiles} from './git.ts';
33
import {typedEntries} from './javascript-helper.ts';
44
import type {EventDirectory, EventId} from './types.ts';
55

6-
const DIRECTORY_FILE = `${EVENT_FILES_DIR}/directory.json`;
7-
86
let directory: EventDirectory = {};
97
let namesOfEvents: Readonly<Record<EventId, string>> = {};
108

@@ -14,7 +12,10 @@ console.log(new Date(), 'eventfiles loaded');
1412

1513
async function update() {
1614
await pullEventFiles();
17-
const directoryString = await readFile(DIRECTORY_FILE, 'utf8');
15+
const directoryString = await readFile(
16+
`${EVENT_FILES_DIR}/directory.json`,
17+
'utf8',
18+
);
1819
directory = JSON.parse(directoryString) as EventDirectory;
1920
namesOfEvents = await generateMapping();
2021
}

source/lib/change-helper.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ export function generateShortChangeText(
7171

7272
export async function loadEvents(eventId: EventId): Promise<EventEntry[]> {
7373
try {
74-
const content = await readFile(`${EVENT_FILES_DIR}/events/${eventId}.json`, 'utf8');
74+
const content = await readFile(
75+
`${EVENT_FILES_DIR}/events/${eventId}.json`,
76+
'utf8',
77+
);
7578
return JSON.parse(content) as EventEntry[];
7679
} catch (error) {
7780
console.error('ERROR while loading events for change date picker', error);

source/menu/events/add.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ import {BACK_BUTTON_TEXT} from '../../lib/inline-menu.ts';
1919
import {typedEntries} from '../../lib/javascript-helper.ts';
2020
import type {EventId, MyContext} from '../../lib/types.ts';
2121

22-
const MAX_RESULT_ROWS = 10;
23-
const RESULT_COLUMNS = 1;
24-
2522
export const bot = new Composer<MyContext>();
2623
export const menu = new MenuTemplate<MyContext>(ctx => {
2724
ctx.session.eventAdd ??= {path: []};
@@ -102,8 +99,8 @@ menu.interact('filter-clear', {
10299
});
103100

104101
menu.choose('list', {
105-
maxRows: MAX_RESULT_ROWS,
106-
columns: RESULT_COLUMNS,
102+
maxRows: 10,
103+
columns: 1,
107104
choices(ctx) {
108105
try {
109106
ctx.session.eventAdd ??= {path: []};

0 commit comments

Comments
 (0)