Browse Source

make sure to remove RiotControl events when tags are unmounted

pull/1/head
wes 7 years ago
parent
commit
a8362359ff
  1. 4
      src/scripts/app.tag
  2. 51
      src/scripts/browse.tag
  3. 9
      src/scripts/post.tag

4
src/scripts/app.tag

@ -130,14 +130,14 @@ document.addEventListener("click", function(event) {
}
});
RiotControl.on("postswitch",
window.RiotControl.on("postswitch",
(ev) => {
self.update(
{
"currentPage" : ev.title
})
}
);
);
self.state = {
"page" : self.opts.page,

51
src/scripts/browse.tag

@ -1,19 +1,19 @@
<browse>
<div>
<div
class="card"
each={result in opts.state.results}
>
<div class="card-header">
<a href={"/blog/posts/"+result[1].id}>
<h3 class="card-title">
{ result[1].title } by { result[1].author }
</h3>
</a>
</div>
<div class="card-body">
<raw content="{ result[1].content }"></raw>
</div>
<div
style={cardStyle}
class="card content"
each={result in opts.state.results}
>
<div class="card-header">
<a
onclick={openPost(result[1].id)}
>
<h3 class="card-title">
{ result[1].title } by { result[1].author }
</h3>
</a>
</div>
<div class="card-body">
</div>
</div>
@ -22,5 +22,26 @@ import './raw.tag';
import route from 'riot-route';
var self = this;
self.route = route;
self.openPost = (id) => {
return ((ev) => {
console.log(id);
console.log(window.RiotControl.trigger);
});
};
window.RiotControl.on("openpost",
(ev) => {
console.log("caught the event");
}
);
self.cardStyle = {
"margin" : "auto"
};
</script>
</browse>

9
src/scripts/post.tag

@ -68,11 +68,16 @@ self.swipe = false;
self.start = false;
self.end = false;
RiotControl.on("filtercategory",
window.RiotControl.on("filtercategory",
(ev) => {
let category = ev.category.toLowerCase();
});
self.on("unmount", () => {
window.RiotControl.off("filtercategory");
window.RiotControl.off("postswitch");
});
prev(ev) {
ev.preventDefault();
self.end = false;
@ -133,7 +138,7 @@ updatePost(postcontent) {
self.nextloading = "";
self.route("/posts/"+self._id);
RiotControl.trigger("postswitch", {"title" : self.title});
window.RiotControl.trigger("postswitch", {"title" : self.title});
self.parent.update();

Loading…
Cancel
Save