IDesktopRecentDocuments interface

Namespace Runic.Platform in Runic.Platform 0.23.0

public interface IDesktopRecentDocuments

The application's recent documents, which the desktop lists for reopening: Open Recent and the Dock menu on macOS, the Jump List and Recent items on Windows, and the recent files of file choosers and file managers on Linux.

Remarks

An application-scoped service that needs no window; a ViewModel takes it in its constructor. Note a document after the user opened it and after Save As. A path is a fully qualified local path, supplied by trusted application code.

macOS: NSDocumentController on the main thread, which Runic Desktop's event loop serves; in the App Sandbox, note the path while the document's lease is open. Windows: SHAddToRecentDocs, which also fills the Recent category of the application's Jump List where the application is registered for the file type, and IDesktopRecentDocuments.ClearAsync removes the application's Jump List destinations without touching other applications'. Linux: the freedesktop.org recently-used.xbel file that GTK and KDE read, written on the thread pool, with this application, named by its application ID or else its entry assembly, as the document's application; IDesktopRecentDocuments.ClearAsync removes this application from every entry and the entries only it had. A write keeps the newest 500 entries, and a file that is not a bookmark file is left as it is and reported as PlatformFailureCode.IOError. Inside Flatpak that file is the application's own. A path is made absolute before it is noted. Hosts without a desktop, such as CS-WebUI and serve-only Runic Desktop, report Unavailable.

Methods

AddAsync

ValueTask<PlatformResult<PlatformUnit>> AddAsync(string path, CancellationToken cancellationToken = default)

Adds the document at path to the recent documents, or moves it to the top.

Parameters

path

A fully qualified local path to the document.

cancellationToken

Cancels the request before it is made.

Returns

Success, or the platform's failure, such as PlatformFailureCode.IOError when the list cannot be written.

Exceptions

ArgumentException

path is empty, not fully qualified, or contains a NUL character.

ArgumentNullException

path is null.

ClearAsync

ValueTask<PlatformResult<PlatformUnit>> ClearAsync(CancellationToken cancellationToken = default)

Empties the application's recent documents, as Clear Menu in Open Recent does.

Parameters

cancellationToken

Cancels the request before it is made.