@@ -0,0 +1,47 @@
|
||||
module.exports = class {
|
||||
onCreate(input) {
|
||||
this.state = {
|
||||
publics: input.publics.sort(byDate),
|
||||
privates: input.privates.sort(byDate),
|
||||
modal: null,
|
||||
}
|
||||
}
|
||||
|
||||
onMount() {
|
||||
}
|
||||
|
||||
open(modal) {
|
||||
this.state.modal = modal
|
||||
}
|
||||
|
||||
close() {
|
||||
this.state.modal = null
|
||||
}
|
||||
|
||||
fileRemoved({id}) {
|
||||
this.state.publics = this.state.publics.filter(f => f.id !== id)
|
||||
this.state.privates = this.state.privates.filter(f => f.id !== id)
|
||||
}
|
||||
|
||||
fileEdited(file, patch) {
|
||||
this.fileRemoved({id: file.id})
|
||||
this.fileAdded(Object.assign({}, file, patch))
|
||||
|
||||
console.log(Object.assign({}, file, patch))
|
||||
}
|
||||
|
||||
fileAdded(file) {
|
||||
if (file.public) {
|
||||
this.state.publics = [].concat(...this.state.publics).concat(file).sort(byDate)
|
||||
} else {
|
||||
this.state.privates = [].concat(...this.state.privates).concat(file).sort(byDate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function byDate(a, b) {
|
||||
const ad = new Date(a.time)
|
||||
const bd = new Date(b.time)
|
||||
|
||||
return ad.getTime() - bd.getTime()
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<data-menu categories=input.categories selected=(input.selected || {}) user=input.user on-open("open") />
|
||||
<main class="data-file-page">
|
||||
<h1 class="file-list-headers color-primary">Your Private Files</h1>
|
||||
<file-list user=input.user files=state.privates on-removed("fileRemoved") on-edited("fileEdited") on-nicks("fileNicksChanged") />
|
||||
|
||||
<h1 class="file-list-headers color-primary">Public Files</h1>
|
||||
<file-list user=input.user files=state.publics on-removed("fileRemoved") on-edited("fileEdited") on-nicks("fileNicksChanged") />
|
||||
</main>
|
||||
<add-channel-modal enabled=(state.modal === "channel.add") user=input.user on-close("close") />
|
||||
<add-character-modal enabled=(state.modal === "character.add") user=input.user on-close("close") />
|
||||
<add-file-modal enabled=(state.modal === "file.add") user=input.user on-added("fileAdded") on-close("close") />
|
||||
@@ -0,0 +1,10 @@
|
||||
h1.file-list-headers {
|
||||
margin: 0;
|
||||
font-size: 1.5em;
|
||||
margin-top: 0.5em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
main.data-file-page {
|
||||
margin-bottom: 4em;
|
||||
}
|
||||
Reference in New Issue
Block a user