await set()

in packages/graph-explorer/src/core/StateProvider/userPreferences.ts [182:210]


      await set(userStylingAtom, async prev => {
        let newEdges = Array.from((await prev).edges ?? []);
        const existingIndex = newEdges.findIndex(
          edge => edge.type === edgeType
        );
        const prevValue =
          existingIndex !== -1 ? newEdges[existingIndex] : undefined;
        const newValue =
          typeof update === "function" ? update(prevValue) : update;

        if (newValue === RESET || !newValue) {
          // Remove the entry from user styles
          newEdges = newEdges.filter(edge => edge.type !== edgeType);
        } else if (existingIndex === -1) {
          // Add it because it doesn't exist
          newEdges.push(newValue);
        } else {
          // Replace the existing entry
          newEdges[existingIndex] = {
            ...newEdges[existingIndex],
            ...newValue,
          };
        }

        return {
          ...prev,
          edges: newEdges,
        };
      });