closes #75
This commit is contained in:
parent
27cf614048
commit
080955532c
@ -10,6 +10,8 @@ import { EmojiPicker } from "element/emoji-picker";
|
||||
import type { EmojiPack, Emoji } from "types";
|
||||
import { LIVE_STREAM_CHAT } from "const";
|
||||
import { SnortContext } from "@snort/system-react";
|
||||
import { unixNowMs } from "@snort/shared";
|
||||
import { TimeSync } from "index";
|
||||
|
||||
export function WriteMessage({ link, emojiPacks }: { link: NostrLink; emojiPacks: EmojiPack[] }) {
|
||||
const system = useContext(SnortContext);
|
||||
@ -39,6 +41,7 @@ export function WriteMessage({ link, emojiPacks }: { link: NostrLink; emojiPacks
|
||||
const emoji = [...emojiNames].map(name => emojis.find(e => e.at(1) === name));
|
||||
eb.kind(LIVE_STREAM_CHAT as EventKind)
|
||||
.content(chat)
|
||||
.createdAt(Math.floor((unixNowMs() - TimeSync) / 1000))
|
||||
.tag(["a", `${link.kind}:${link.author}:${link.id}`, "", "root"])
|
||||
.processContent();
|
||||
for (const e of emoji) {
|
||||
|
@ -24,6 +24,7 @@ import { register } from "serviceWorker";
|
||||
import { IntlProvider } from "intl";
|
||||
import { WidgetsPage } from "pages/widgets";
|
||||
import { AlertsPage } from "pages/alerts";
|
||||
import { unixNowMs } from "@snort/shared";
|
||||
|
||||
export enum StreamState {
|
||||
Live = "live",
|
||||
@ -45,12 +46,23 @@ Object.entries(defaultRelays).forEach(params => {
|
||||
System.ConnectToRelay(relay, settings);
|
||||
});
|
||||
|
||||
export let TimeSync = 0;
|
||||
|
||||
const router = createBrowserRouter([
|
||||
{
|
||||
element: <LayoutPage />,
|
||||
loader: async () => {
|
||||
db.ready = await db.isAvailable();
|
||||
await System.Init();
|
||||
try {
|
||||
const req = await fetch("https://api.zap.stream/api/time");
|
||||
const nowAtServer = (await req.json()).time as number;
|
||||
const now = unixNowMs();
|
||||
TimeSync = now - nowAtServer;
|
||||
console.debug("Time clock sync", TimeSync);
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
return null;
|
||||
},
|
||||
children: [
|
||||
|
Loading…
Reference in New Issue
Block a user