Browse Source

drafts draft

master
Igor Zhukov 9 years ago
parent
commit
cb9aed03f7
  1. 51
      app/js/services.js

51
app/js/services.js

@ -4454,3 +4454,54 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
shareUrl: shareUrl shareUrl: shareUrl
}; };
}) })
.service('DraftsManager', function (qSync, Storage) {
var localDrafts = {};
return {
getDraft: getDraft,
saveDraft: saveDraft,
changeDraft: changeDraft,
syncDraft: syncDraft
};
function getDraft (peerID, options) {
return Storage.get('draft' + peerID).then(function (draft) {
if (typeof draft === 'string' && draft.length > 0) {
draft = {
text: draft
};
}
if (draft === false || draft == null) {
draft = '';
}
});
}
function saveDraft(peerID, draftData) {
localDrafts[peerID] = draftData;
}
function changeDraft(peerID, message, options) {
options = options || {};
if (typeof message === 'string' || options.replyToMsgID) {
var localDraft = {
text: message,
replyToMsgID: replyToMsgID
};
var backupDraftObj = {};
backupDraftObj['draft' + peerID] = localDraft;
Storage.set(backupDraftObj);
} else {
Storage.remove('draft' + peerID);
}
}
function syncDraft(peerID) {
}
})
Loading…
Cancel
Save