Aylur / ags

A customizable and extensible shell
GNU General Public License v3.0
2.11k stars 109 forks source link

added recursive option to monitorFile #345

Closed NicolaiVdS closed 6 months ago

NicolaiVdS commented 6 months ago

added functionality to monitorFile to be recursive

NOTE: Recursive is true by default

Aylur commented 6 months ago

small thing, but maybe we should have this instead

export function monitorFile(
    path: string,
    callback: (file: Gio.File, event: Gio.FileMonitorEvent) => void,
    options?: { flags: Gio.FileMonitorFlags, recursive: boolean },
)
NicolaiVdS commented 6 months ago

small thing, but maybe we should have this instead

export function monitorFile(
    path: string,
    callback: (file: Gio.File, event: Gio.FileMonitorEvent) => void,
    options?: { flags: Gio.FileMonitorFlags, recursive: boolean },
)

Ok i can see the point in using options but should flags still be used since

// FIXME: remove the checking in the next release
  // @ts-expect-error
  if (options?.flags === "file" || options?.flags === "directory") {
    throw Error(
      `${options?.flags}` +
        " passed as a parameter in `monitorFile`. " +
        "Specifying the type is no longer required."
    );
  }
Aylur commented 6 months ago

that check was there because the third parameter used to be "file" | "directory", but it was removed with #302 this time, since it will be another breaking change, we need to update it to check if the third parameter is a number (Gio.FileMonitorFlags) and console.warn about it being changed to an options object

NicolaiVdS commented 6 months ago

that check was there because the third parameter used to be "file" | "directory", but it was removed with #302 this time, since it will be another breaking change, we need to update it to check if the third parameter is a number (Gio.FileMonitorFlags) and console.warn about it being changed to an options object

added the requested changes