pinafore/routes/_components/compose/ComposeContentWarning.html
greenkeeper[bot] 8dbc1b0503 Update standard to the latest version 🚀 (#519)
* chore(package): update standard to version 12.0.0

* package lock update

* fix eslint
2018-08-29 21:42:57 -07:00

51 lines
1.3 KiB
HTML

<input class="content-warning-input"
type="text"
placeholder="Content warning"
aria-label="Content warning"
bind:value=rawText
/>
<style>
.content-warning-input {
font-size: 1.2em;
margin: 10px 0 0 5px;
padding: 10px;
border: 1px solid var(--input-border);
width: calc(100% - 5px);
}
</style>
<script>
import { store } from '../../_store/store'
import debounce from 'lodash-es/debounce'
import { scheduleIdleTask } from '../../_utils/scheduleIdleTask'
import { observe } from 'svelte-extras'
export default {
oncreate () {
this.setupSyncFromStore()
this.setupSyncToStore()
},
store: () => store,
data: () => ({
rawText: ''
}),
methods: {
observe,
setupSyncFromStore () {
this.observe('contentWarning', contentWarning => {
this.set({ rawText: contentWarning })
})
},
setupSyncToStore () {
const saveText = debounce(() => scheduleIdleTask(() => this.store.save()), 1000)
this.observe('rawText', rawText => {
let { realm } = this.get()
this.store.setComposeData(realm, {
contentWarning: rawText
})
saveText()
}, { init: false })
}
}
}
</script>