/*
 * Copyright (C) 2015 Actor LLC. <https://actor.im>
 */

import { dispatch } from '../dispatcher/ActorAppDispatcher';
import { ActionTypes } from '../constants/ActorAppConstants';
import ConnectionStateActionCreators from '../actions/ConnectionStateActionCreators';
import ActorClient from '../utils/ActorClient';

export default {
  createAppVisible() {
    ActorClient.onAppVisible();
    ActorClient.bindConnectState(ConnectionStateActionCreators.setState);
    dispatch(ActionTypes.APP_VISIBLE);
  },

  createAppHidden() {
    ActorClient.onAppHidden();
    ActorClient.unbindConnectState(ConnectionStateActionCreators.setState);
    dispatch(ActionTypes.APP_HIDDEN);
  }
};

@@ -273,46 +273,161 @@
 ort 
-ActorClient from '../utils/ActorClient
+DraftActionCreators from '../actions/DraftActionCreators';%0Aimport ActorClient from '../utils/ActorClient';%0Aimport DialogStore from '../stores/DialogStore
 ';%0A%0A
@@ -462,24 +462,63 @@
 Visible() %7B%0A
+    dispatch(ActionTypes.APP_VISIBLE);%0A
     ActorCli
@@ -617,72 +617,125 @@
 ;%0A  
-  dispatch(ActionTypes.APP_VISIBLE);%0A  %7D,%0A%0A  createAppHidden() %7B
+%7D,%0A%0A  createAppHidden() %7B%0A    dispatch(ActionTypes.APP_HIDDEN);%0A    const currentPeer = DialogStore.getCurrentPeer();
 %0A   
@@ -846,39 +846,49 @@
     
-dispatch(ActionTypes.APP_HIDDEN
+DraftActionCreators.saveDraft(currentPeer
 );%0A 

save draft on app hidden