import BackgroundApplication from "../application/BackgroundApplication";
//import commentHandler from "./commentHandleMessage";
//import explorationHandler from "./explorationHandleMessage";

export default class ChromeMessageHandler {
	private application: BackgroundApplication;

	constructor(application: BackgroundApplication) {
		this.application = application;
	}

	attach(): void {
		chrome.runtime.onMessage.addListener(this.handleMessage.bind(this));
		//chrome.runtime.onMessage.addListener(commentHandler.bind(this));
		//chrome.runtime.onMessage.addListener(connectionHandler.bind(this));
		//chrome.runtime.onMessage.addListener(explorationHandler.bind(this));
	}

	handleMessage(msg, sender, sendResponse): boolean {
		return true;
		switch (msg.kind) {


			/*case "updateState": {
				const patch = msg.patch;
				this.application
					.updateState(patch)
					.then(() => {
						sendResponse(this.state);
					})
					.catch((error) => {
						console.log(error);
					});
				return true;
			}

			case "openWindow": {
				this.application
					.drawAttention()
					.catch((error) => {
						sendResponse({ error });
						console.error(error);
					});
				sendResponse(this.state);
				return true;
			}*/
			
		}
	}
}
