Skip to content

Commit

Permalink
Merge pull request #193 from Cycling74/fde/instance_ids
Browse files Browse the repository at this point in the history
Dropped instance.index usage in favour of referring to it simply as id
  • Loading branch information
fde31 authored Jan 8, 2025
2 parents 8c1d934 + fd1d64d commit b584ff7
Show file tree
Hide file tree
Showing 26 changed files with 257 additions and 286 deletions.
4 changes: 2 additions & 2 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def do_GET(self):
normPath.remove('')

fpath = path.join(args.directory, '{os.sep}'.join(normPath))
# handle /instances/12 -> /instances/[index].html mapping
ipath = path.join(normPath[0], "[index].html")
# handle /instances/12 -> /instances/[id].html mapping
ipath = path.join(normPath[0], "[id].html")

if not path.isfile(fpath) and not fext and path.isfile(fpath + '.html'):
self.path = self.path + '.html'
Expand Down
4 changes: 2 additions & 2 deletions src/actions/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { oscQueryBridge } from "../controller/oscqueryBridgeController";
import { isValidConnection } from "../lib/editorUtils";
import throttle from "lodash.throttle";
import { OSCQuerySetMeta } from "../lib/types";
import { setConnection, setNode, setNodes, unloadPatcherNodeByIndexOnRemote } from "./graph";
import { setConnection, setNode, setNodes, unloadPatcherNodeOnRemote } from "./graph";
import { getGraphEditorInstance, getGraphEditorLockedState } from "../selectors/editor";
import { defaultNodeGap } from "../lib/constants";

Expand Down Expand Up @@ -191,7 +191,7 @@ export const removeEditorNodeById = (id: GraphNode["id"], updateSetMeta = true):
throw new Error(`System nodes cannot be removed (id: ${id}).`);
}

dispatch(unloadPatcherNodeByIndexOnRemote(node.index));
dispatch(unloadPatcherNodeOnRemote(node.instanceId));
if (updateSetMeta) doUpdateNodesMeta(getNodes(state).delete(node.id));

} catch (err) {
Expand Down
24 changes: 12 additions & 12 deletions src/actions/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { oscQueryBridge } from "../controller/oscqueryBridgeController";
import { ActionBase, AppThunk, RootStateType } from "../lib/store";
import { OSCQueryRNBOInstance, OSCQueryRNBOInstancesState, OSCQueryRNBOJackConnections, OSCQueryRNBOJackPortInfo, OSCQuerySetMeta, OSCQuerySetNodeMeta } from "../lib/types";
import { ConnectionType, GraphConnectionRecord, GraphControlNodeRecord, GraphNodeRecord, GraphPatcherNodeRecord, GraphPortRecord, GraphSystemNodeRecord, NodeType, PortDirection, calculateNodeContentHeight, createNodePorts } from "../models/graph";
import { getConnectionsForSourceNodeAndPort, getNode, getPatcherNodeByIndex, getNodes, getSystemNodeByJackNameAndDirection, getConnections, getPatcherNodes, getSystemNodes, getControlNodes } from "../selectors/graph";
import { getConnectionsForSourceNodeAndPort, getNode, getPatcherNodeByInstanceId, getNodes, getSystemNodeByJackNameAndDirection, getConnections, getPatcherNodes, getSystemNodes, getControlNodes } from "../selectors/graph";
import { showNotification } from "./notifications";
import { NotificationLevel } from "../models/notification";
import { PatcherInstanceRecord } from "../models/instance";
Expand Down Expand Up @@ -362,9 +362,9 @@ export const initNodes = (jackPortsInfo: OSCQueryRNBOJackPortInfo, instanceInfo:
patcherAndControlNodes.push(node);
const instance = PatcherInstanceRecord.fromDescription(info);
instances.push(instance);
instanceParameters.push(...ParameterRecord.fromDescription(instance.index, info.CONTENTS.params));
instanceMessageInports.push(...MessagePortRecord.fromDescription(instance.index, info.CONTENTS.messages?.CONTENTS?.in));
instanceMessageOutports.push(...MessagePortRecord.fromDescription(instance.index, info.CONTENTS.messages?.CONTENTS?.out));
instanceParameters.push(...ParameterRecord.fromDescription(instance.id, info.CONTENTS.params));
instanceMessageInports.push(...MessagePortRecord.fromDescription(instance.id, info.CONTENTS.messages?.CONTENTS?.in));
instanceMessageOutports.push(...MessagePortRecord.fromDescription(instance.id, info.CONTENTS.messages?.CONTENTS?.out));
}

// Build a list of all Jack generated names that have not been used for PatcherNodes above
Expand Down Expand Up @@ -607,14 +607,14 @@ export const updateSystemOrControlPortInfo = (type: ConnectionType, direction: P
};

// Trigger Updates on remote OSCQuery Runner
export const unloadPatcherNodeByIndexOnRemote = (instanceIndex: number): AppThunk =>
export const unloadPatcherNodeOnRemote = (instanceId: string): AppThunk =>
(dispatch) => {
try {

const message = {
address: "/rnbo/inst/control/unload",
args: [
{ type: "i", value: instanceIndex }
{ type: "i", value: parseInt(instanceId, 10) }
]
};
oscQueryBridge.sendPacket(writePacket(message));
Expand Down Expand Up @@ -695,26 +695,26 @@ export const addPatcherNode = (desc: OSCQueryRNBOInstance, metaString: string):

// Create Instance State
const instance = PatcherInstanceRecord.fromDescription(desc);
const parameters = ParameterRecord.fromDescription(instance.index, desc.CONTENTS.params);
const messageInports = MessagePortRecord.fromDescription(instance.index, desc.CONTENTS.messages?.CONTENTS?.in);
const messageOutports = MessagePortRecord.fromDescription(instance.index, desc.CONTENTS.messages?.CONTENTS?.out);
const parameters = ParameterRecord.fromDescription(instance.id, desc.CONTENTS.params);
const messageInports = MessagePortRecord.fromDescription(instance.id, desc.CONTENTS.messages?.CONTENTS?.in);
const messageOutports = MessagePortRecord.fromDescription(instance.id, desc.CONTENTS.messages?.CONTENTS?.out);

dispatch(setInstance(instance));
dispatch(setInstanceParameters(parameters));
dispatch(setInstanceMessageInports(messageInports));
dispatch(setInstanceMessageOutports(messageOutports));
};

export const removePatcherNode = (index: number): AppThunk =>
export const removePatcherNode = (instanceId: string): AppThunk =>
(dispatch, getState) => {
try {
const state = getState();

const node = getPatcherNodeByIndex(state, index);
const node = getPatcherNodeByInstanceId(state, instanceId);
if (node?.type !== NodeType.Patcher) return;
dispatch(deleteNode(node));

const instance = getPatcherInstance(state, node.id);
const instance = getPatcherInstance(state, instanceId);
if (!instance) return;

dispatch(deleteInstance(instance));
Expand Down
Loading

0 comments on commit b584ff7

Please sign in to comment.