How to watch for the focus on a specific note?

I am writing a plugin that does things to a specific note (daylies.md). I would like to trigger these actions when the note is focused on (i.e. when switching to it from another note, or when Obsidian starts with this note as the default one, …).

I found the hasFocus() method but I guess that this is just a method that returns whether the editor has focus or not.

Is it possible to watch (and run a callback) for when a note gets focused on?

import { App, Workspace } from 'obsidian';

export default class MyPlugin extends Plugin {
  private activeLeaf: any; // Store the current active leaf

  async onload() {
    console.log('loading plugin');

    this.app.workspace.onLayoutReady(() => {

      this.app.workspace.on('active-leaf-change', (leaf) => {
        this.activeLeaf = this.app.workspace.activeLeaf;
        if (leaf && leaf !== this.activeLeaf && leaf instanceof TFile) {
          // Note focus has changed
          this.activeLeaf = leaf;

          if (this.app.workspace.getActiveFile()?.path === "daylies.md") {
            // Trigger your actions here
            console.log("daylies.md is now focused!");
          }
        }
      });
    });
  }

  onunload() {
    console.log('unloading plugin');
  }
}

I guess there is some logic flaw here. But you got the point, I hope, which APIs to use.