This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/models/draft.js
2020-03-12 13:29:55 -04:00

36 lines
736 B
JavaScript

import { ajax } from "discourse/lib/ajax";
import EmberObject from "@ember/object";
const Draft = EmberObject.extend();
Draft.reopenClass({
clear(key, sequence) {
return ajax("/draft.json", {
type: "DELETE",
data: { draft_key: key, sequence }
});
},
get(key) {
return ajax("/draft.json", {
data: { draft_key: key },
dataType: "json"
});
},
getLocal(key, current) {
// TODO: implement this
return current;
},
save(key, sequence, data, clientId) {
data = typeof data === "string" ? data : JSON.stringify(data);
return ajax("/draft.json", {
type: "POST",
data: { draft_key: key, sequence, data, owner: clientId }
});
}
});
export default Draft;