Experiment to rebuild Diffuse using web applets.
0

Configure Feed

Select the types of activity you want to include in your feed.

1<script> 2 import { QueueItem, State } from "./types"; 3 import { register } from "@scripts/applets/common"; 4 5 //////////////////////////////////////////// 6 // SETUP 7 //////////////////////////////////////////// 8 const context = register<State>(); 9 10 // Initial state 11 context.data = { 12 past: [], 13 now: null, 14 future: [], 15 }; 16 17 // State helpers 18 function update(partial: Partial<State>): void { 19 context.data = { ...context.data, ...partial }; 20 } 21 22 //////////////////////////////////////////// 23 // ACTIONS 24 //////////////////////////////////////////// 25 context.setActionHandler("add", add); 26 context.setActionHandler("shift", shift); 27 28 function add(items: QueueItem[]) { 29 update({ future: [...context.data.future, ...items] }); 30 } 31 32 function shift() { 33 const now = context.data.future[0] || null; 34 const future = context.data.future.slice(1); 35 const past = context.data.now ? [...context.data.past, context.data.now] : context.data.past; 36 37 update({ past, now, future }); 38 39 return now; 40 } 41</script>