<commit_before>const createVideoPlayer = require("./renderer-process/createVideoPlayer");
const ipc = require("electron").ipcRenderer;
const registerFileSelectionButtons = require("./renderer-process/registerFileSelectionEvent");
const { listenForInsertCurrentTimestampEvents } = require("./renderer-process/insertCurrentTime");
const { registerClickHandlerForTimestampButton } = require("./renderer-process/insertCurrentTime");
const { handlePlayPauseToggle } = require("./main-process/controlPlayback");
const { handleJumpingBackNSeconds } = require("./main-process/controlPlayback");

const {
  autosave,
  registerSaveHandlers,
  handleASaveClick,
  handleASaveAsClick,
  isEditorDirty,
  setIsEditorDirty,
} = require("./saveTranscript");
let editorContainer = document.querySelector(".editor-container");
const lastSavedPath = "data-last-saved-path";
const { handleAnyUnsavedChanges } = require("../common/closeTheApp");
let transcriptEditor = require("./renderer-process/transcriptEditor");
let videoPlayer = createVideoPlayer();

registerFileSelectionButtons(transcriptEditor);
registerSaveHandlers(transcriptEditor, handleASaveClick, handleASaveAsClick);
autosave(transcriptEditor);
listenForInsertCurrentTimestampEvents();
registerClickHandlerForTimestampButton();
handlePlayPauseToggle(videoPlayer);
handleJumpingBackNSeconds(videoPlayer);

ipc.on("a-file-was-selected", (event, filepath, roleOfFile) => {
  if (roleOfFile === "transcript") {
    ipc.send("read-transcript-from-filepath", filepath);
  } else if (roleOfFile === "video") {
    videoPlayer.src(filepath);
  }
});

ipc.on("transcript-was-read-from-file", (event, fileContents, filePath) => {
  transcriptEditor.setText(fileContents, "user");
  editorContainer.setAttribute(lastSavedPath, filePath);
  setIsEditorDirty(false);
});

ipc.on("user-wants-to-close-the-app", (event) => {
  handleAnyUnsavedChanges(
    isEditorDirty(),
    transcriptEditor,
    editorContainer,
    editorContainer.getAttribute(lastSavedPath),
  );
});

ipc.on("saved-file", (event, savePath) => {
  editorContainer.setAttribute(lastSavedPath, savePath);
  setIsEditorDirty(false);
});

setInterval(
  3 * 1000,
);
<commit_msg>assert editorContainer won't be null<commit_after>const createVideoPlayer = require("./renderer-process/createVideoPlayer");
const ipc = require("electron").ipcRenderer;
const registerFileSelectionButtons = require("./renderer-process/registerFileSelectionEvent");
const { listenForInsertCurrentTimestampEvents } = require("./renderer-process/insertCurrentTime");
const { registerClickHandlerForTimestampButton } = require("./renderer-process/insertCurrentTime");
const { handlePlayPauseToggle } = require("./main-process/controlPlayback");
const { handleJumpingBackNSeconds } = require("./main-process/controlPlayback");

const {
  autosave,
  registerSaveHandlers,
  handleASaveClick,
  handleASaveAsClick,
  isEditorDirty,
  setIsEditorDirty,
} = require("./saveTranscript");
let editorContainer = document.querySelector(".editor-container");
const lastSavedPath = "data-last-saved-path";
const { handleAnyUnsavedChanges } = require("../common/closeTheApp");
let transcriptEditor = require("./renderer-process/transcriptEditor");
let videoPlayer = createVideoPlayer();

registerFileSelectionButtons(transcriptEditor);
registerSaveHandlers(transcriptEditor, handleASaveClick, handleASaveAsClick);
autosave(transcriptEditor);
listenForInsertCurrentTimestampEvents();
registerClickHandlerForTimestampButton();
handlePlayPauseToggle(videoPlayer);
handleJumpingBackNSeconds(videoPlayer);

ipc.on("a-file-was-selected", (event, filepath, roleOfFile) => {
  if (roleOfFile === "transcript") {
    ipc.send("read-transcript-from-filepath", filepath);
  } else if (roleOfFile === "video") {
    videoPlayer.src(filepath);
  }
});

ipc.on("transcript-was-read-from-file", (event, fileContents, filePath) => {
  transcriptEditor.setText(fileContents, "user");
  editorContainer!.setAttribute(lastSavedPath, filePath);
  setIsEditorDirty(false);
});

ipc.on("user-wants-to-close-the-app", (event) => {
  handleAnyUnsavedChanges(
    isEditorDirty(),
    transcriptEditor,
    editorContainer,
    editorContainer!.getAttribute(lastSavedPath),
  );
});

ipc.on("saved-file", (event, savePath) => {
  editorContainer!.setAttribute(lastSavedPath, savePath);
  setIsEditorDirty(false);
});

setInterval(
  3 * 1000,
);

{'fraction_non_alphanumeric': 0.1381668946648427, 'fraction_numerical': 0.002279981760145919, 'mean_word_length': 7.04954128440367, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1511417', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1286, 'n_words': 188}