kernl API
    Preparing search index...

    Function createMessagingRegistry

    • Create the shell's provider registry.

      The registry owns one backend per enabled provider and hands out a single composite backend for the NAP dm service. Preferences restored at construction are applied lazily: a provider that appears in the saved enabled list is started the moment it is registered, if it is available. One that cannot run yet (nobody is signed in, say) reports why through list(), stays in the saved enabled list, and is started the next time the registry is read after it became available. Switching it off forgets it.

      Providers are kept in the user's order. A provider joins the end of it when it is registered, unless the saved order already places it. The first enabled provider in the order is the default: a message to someone new leaves through it, and when it cannot reach them the next one is tried.

      When a one-to-one message would leave through a provider other than the one its recipient last wrote through, the reply rule decides: theirs follows the correspondent, mine keeps the order's pick, and ask (the default) puts the question to askReply, whose answer can settle it for that person or for everyone.

      close() closes every backend without touching the preferences, so a shutdown never erases what the user chose. A closed registry is not reused.

      Parameters

      Returns MessagingRegistry

      A MessagingRegistry.

      const registry = createMessagingRegistry({
      preferences: load(),
      onChange: (prefs) => save(prefs),
      });
      registry.register(createPrivateMessagesProvider(deps));
      registry.register(createLegacyMessagesProvider(deps));
      registry.enable('private');
      registry.setOrder(['legacy', 'private']);
      registry.preferences().defaultProvider; // 'private': the first one that is enabled