The frontend/UI server, written in JS using the MarkoJS library
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
const {query} = require("../client")
class Chapter { /** * @param {string} id * @param {string} title * @param {string} author * @param {string} source * @param {string | Date} createdDate * @param {string | Date} fictionalDate * @param {string | Date} editedDate */ constructor(id, title, author, source, createdDate, fictionalDate, editedDate) { this.id = id this.title = title this.author = author this.source = source this.createdDate = new Date(createdDate) this.fictionalDate = new Date(fictionalDate) this.editedDate = new Date(editedDate) }
/** * Query the chapter's editable fields and update this object. This promise returns a boolean * whether there has been a change. * * @returns {Promise<boolean>} `true` if the story was edited in the meantime */ update() { return query(`
query UpdateChapter($id: String!) { update: chapter(id: $id) { title source fictionalDate editedDate } } `, {id: this.id}).then(({update}) => {
const editedDate = new Date(udpate.editedDate) const wasEdited = editedDate.getTime() != this.editedDate.getTime()
this.title = update.title this.source = update.source this.fictionalDate = new Date(update.fictionalDate) this.editedDate = editedDate
return wasEdited }) } }
module.exports = {Chapter}
|