Self-hosted, federated location sharing app and server that prioritizes user privacy and security
end-to-end-encryption
location-sharing
privacy
self-hosted
federated
1import Alpine from "alpinejs";
2import { goto } from "../utils/tools.ts";
3import { Store } from "../utils/store.ts";
4import * as api from "../utils/api.ts";
5import { openUrl } from "@tauri-apps/plugin-opener";
6
7Alpine.data("homePageState", () => ({
8 is_admin: false,
9 friends: [] as { name: string; id: string }[],
10
11 async init() {
12 this.is_admin = await Store.get("is_admin");
13 this.friends = await Store.get("friends");
14 },
15
16 newSignupKey: "",
17
18 timeAgo() {
19 return "2m ago";
20 },
21
22 async viewLocation(friend_id: string) {
23 const pings = await api.getPings(friend_id);
24 await openUrl(`geo:0,0?q=${pings[0]}`);
25 },
26
27 friendOptions(friend_id: string) {
28 alert(`Options for friend id ${friend_id}`);
29 },
30
31 async updateServer() {
32 // temporarly, just use the friend id of the first in the list
33 const friends = await Store.get("friends");
34
35 await api.sendPings(friends[0].id, "37.78918,-122.40335");
36 },
37
38 addFriend() {
39 goto("add-friend");
40 },
41
42 openSettings() {
43 goto("settings");
44 },
45
46 async generateSignupKey() {
47 this.newSignupKey = await api.generateSignupKey();
48 },
49}));
50
51Alpine.start();