Router WIP
This commit is contained in:
@@ -59,6 +59,8 @@ const viewListingDetails = ({ type, action }, component) => {
|
||||
imageIndex: 0,
|
||||
listing: action.listing
|
||||
}, () => {
|
||||
//window.history.pushState({}, '', `/listing/${action.id}`);
|
||||
component.router.update();
|
||||
markSeen(action.id);
|
||||
const m = component.findMarker(action.id);
|
||||
if (m) {
|
||||
|
||||
18
web/lib/router.js
Normal file
18
web/lib/router.js
Normal file
@@ -0,0 +1,18 @@
|
||||
export default class Router {
|
||||
constructor(comp) {
|
||||
this.component = comp;
|
||||
}
|
||||
|
||||
update () {
|
||||
// Take the state from the component and update the URL
|
||||
const {listingId, sort, minPrice, maxPrice, minSize, maxSize, filters: {rooms, category}} = this.component.state;
|
||||
const bounds = this.component.map.getBounds().toUrlValue();
|
||||
const params = [];
|
||||
params.push(`listingId=${listingId}`);
|
||||
params.push(`sort=${sort}`);
|
||||
params.push(`bounds=${bounds}`);
|
||||
params.push(`rooms=${Object.keys(rooms).filter(v => rooms[v]).join(",")}`);
|
||||
params.push(`category=${Object.keys(category).filter(v => category[v]).join(",")}`);
|
||||
window.history.pushState({}, '', `/?${params.join("&")}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user