UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) • 1.19 kB
import b from"../../data";import d from"../../tools/logger";import{generateUniqueSlug as k}from"../../tools/slug";import{getStorage as n,saveStorage as a}from"../../utils/entity-storage";import{planAutorun as m}from"../../utils/plan-reactions.js";import c from"../../utils/preview-exhibitor.js";import{Exhibitor as h,RebookingState as p}from"../ExhibitorStore";export default function u(r){const{exhibitorStore:t}=r,o=[...b.exhibitors||[]],i=c();if(i){const s=o.findIndex(e=>e.id===i.id);s!==-1?o.splice(s,1,i):o.push(i)}o.sort((s,e)=>Number(e.featured)-Number(s.featured));for(const s of o){const e=new h;Object.assign(e,s),e.slug=k(e.name),e.rebookingState=e.rebookingState||p.Unasked,e.categories=[],e.booths=[],e.store=t,t.exhibitors.push(e),e.schedule=null}d.log("initExhibitors",t.exhibitors.length),f(t),g(t)}function f(r){const t=n("bookmarked");r.replaceBookmarked(t.exhibitors),m(()=>{const o=n("bookmarked");a("bookmarked",{exhibitors:r.bookmarked?.map(i=>i.id),events:o.events,speakers:o.speakers,booths:o.booths})})}function g(r){const t=n("visited");r.replaceVisited(t.exhibitors),m(()=>{const o=n("visited");a("visited",{exhibitors:r.visited.map(i=>i.id),events:o.events})})}