unsetActiveInstance method

void unsetActiveInstance({
  1. required String instanceId,
})

Called when the instance given by instanceId is no longer the active instance.

  1. Unsets the globally active instance
  2. If instanceId is the active instance for its pane, it is unset as the active instance for that pane
  3. Notifies listeners

Implementation

void unsetActiveInstance({
  required String instanceId,
}) {
  String? paneId;
  api.workspace.workspaceConfigs.activeInstance = null;
  for (final pane in api.workspace.workspaceConfigs.panesData.entries) {
    if (pane.value.instances.contains(instanceId)) {
      paneId = pane.key;
      if (pane.value.activeInstance == instanceId) {
        api.workspace.workspaceConfigs.panesData[pane.key]!.activeInstance =
            null;
      }

      break;
    }
  }

  AffogatoEvents.windowInstanceDidUnsetActiveEventsController.add(
    WindowInstanceDidUnsetActiveEvent(
      instanceId: instanceId,
    ),
  );
  if (paneId != null) {
    AffogatoEvents.windowPaneRequestReloadEventsController
        .add(WindowPaneRequestReloadEvent(paneId));
  }
}