import { ipcRenderer } from "electron";

export const IPC_TAGUPDATE = "IPC_TAGUPDATE";
export const IPC_TAGSYNC = "IPC_TAGSYNC";
export const STORE_NEW_TAG = "STORE_NEW_TAG";
export const DELETE_TAG = "DELETE_TAG";
export const WRITE_TAG = "WRITE_TAG";

export function ipcTagUpdate(event, tag){
	return {
		type: IPC_TAGUPDATE,
		payload: tag
	};
}

export function ipcTagSync(ipAddress, tagList){
	ipcRenderer.send("tag:sync", ipAddress, tagList);
	return {
		type: IPC_TAGSYNC,
		payload: true
	};
}

export function storeNewTag(tag){
	ipcRenderer.send("tag:new", tag);
	return {
		type: STORE_NEW_TAG,
		payload: tag
	};
}

export function deleteTag(tagName){
	return {
		type: DELETE_TAG,
		payload: tagName
	};
}


export function writeTag(tagName, value){
	ipcRenderer.send("tag:write", tagName, value);

	return {
		type: WRITE_TAG,
		payload: true
	};
}