import Alpine from "alpinejs"; import { goto } from "../utils/tools.ts"; import { Store } from "../utils/store.ts"; import * as api from "../utils/api.ts"; import { openUrl } from "@tauri-apps/plugin-opener"; Alpine.data("homePageState", () => ({ is_admin: false, friends: [] as { name: string; id: string }[], async init() { this.is_admin = await Store.get("is_admin"); this.friends = await Store.get("friends"); }, newSignupKey: "", timeAgo() { return "2m ago"; }, async viewLocation(friend_id: string) { const pings = await api.getPings(friend_id); await openUrl(`geo:0,0?q=${pings[0]}`); }, friendOptions(friend_id: string) { alert(`Options for friend id ${friend_id}`); }, async updateServer() { // temporarly, just use the friend id of the first in the list const friends = await Store.get("friends"); await api.sendPings(friends[0].id, "37.78918,-122.40335"); }, addFriend() { goto("add-friend"); }, openSettings() { goto("settings"); }, async generateSignupKey() { this.newSignupKey = await api.generateSignupKey(); }, })); Alpine.start();