Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

1.4 KB
Raw Blame
import type { PlanDetailSliceCreator, ThreadFocusSlice } from "./types";

// "View in Statement" hands the target thread to the statement editor through
// the store: the timeline and the editor live in different phase sections and
// the editor may still be mounting when the request is made.
export const createThreadFocusSlice: PlanDetailSliceCreator<
  ThreadFocusSlice
> = (set) => ({
  threadFocus: undefined,
  requestThreadFocus: (request) =>
    set((state) => ({
      threadFocus: {
        ...request,
        nonce: (state.threadFocus?.nonce ?? 0) + 1,
      },
    })),
  clearThreadFocus: (nonce) =>
    set((state) =>
      state.threadFocus && state.threadFocus.nonce === nonce
        ? { threadFocus: undefined }
        : state
    ),
  walkerFilter: undefined,
  setWalkerFilter: (walkerFilter) => set({ walkerFilter }),
  reviewRowRequest: undefined,
  requestReviewRow: (reviewer) =>
    set((state) => ({
      reviewRowRequest: {
        reviewer,
        nonce: (state.reviewRowRequest?.nonce ?? 0) + 1,
      },
    })),
  activityFocus: undefined,
  requestActivityFocus: (commentName) =>
    set((state) => ({
      activityFocus: {
        commentName,
        nonce: (state.activityFocus?.nonce ?? 0) + 1,
      },
    })),
  clearActivityFocus: (nonce) =>
    set((state) =>
      state.activityFocus && state.activityFocus.nonce === nonce
        ? { activityFocus: undefined }
        : state
    ),
});