@ -10,6 +10,8 @@ import { EmojiPicker } from "element/emoji-picker";
|
|||||||
import type { EmojiPack, Emoji } from "types";
|
import type { EmojiPack, Emoji } from "types";
|
||||||
import { LIVE_STREAM_CHAT } from "const";
|
import { LIVE_STREAM_CHAT } from "const";
|
||||||
import { SnortContext } from "@snort/system-react";
|
import { SnortContext } from "@snort/system-react";
|
||||||
|
import { unixNowMs } from "@snort/shared";
|
||||||
|
import { TimeSync } from "index";
|
||||||
|
|
||||||
export function WriteMessage({ link, emojiPacks }: { link: NostrLink; emojiPacks: EmojiPack[] }) {
|
export function WriteMessage({ link, emojiPacks }: { link: NostrLink; emojiPacks: EmojiPack[] }) {
|
||||||
const system = useContext(SnortContext);
|
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));
|
const emoji = [...emojiNames].map(name => emojis.find(e => e.at(1) === name));
|
||||||
eb.kind(LIVE_STREAM_CHAT as EventKind)
|
eb.kind(LIVE_STREAM_CHAT as EventKind)
|
||||||
.content(chat)
|
.content(chat)
|
||||||
|
.createdAt(Math.floor((unixNowMs() - TimeSync) / 1000))
|
||||||
.tag(["a", `${link.kind}:${link.author}:${link.id}`, "", "root"])
|
.tag(["a", `${link.kind}:${link.author}:${link.id}`, "", "root"])
|
||||||
.processContent();
|
.processContent();
|
||||||
for (const e of emoji) {
|
for (const e of emoji) {
|
||||||
|
@ -24,6 +24,7 @@ import { register } from "serviceWorker";
|
|||||||
import { IntlProvider } from "intl";
|
import { IntlProvider } from "intl";
|
||||||
import { WidgetsPage } from "pages/widgets";
|
import { WidgetsPage } from "pages/widgets";
|
||||||
import { AlertsPage } from "pages/alerts";
|
import { AlertsPage } from "pages/alerts";
|
||||||
|
import { unixNowMs } from "@snort/shared";
|
||||||
|
|
||||||
export enum StreamState {
|
export enum StreamState {
|
||||||
Live = "live",
|
Live = "live",
|
||||||
@ -45,12 +46,23 @@ Object.entries(defaultRelays).forEach(params => {
|
|||||||
System.ConnectToRelay(relay, settings);
|
System.ConnectToRelay(relay, settings);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export let TimeSync = 0;
|
||||||
|
|
||||||
const router = createBrowserRouter([
|
const router = createBrowserRouter([
|
||||||
{
|
{
|
||||||
element: <LayoutPage />,
|
element: <LayoutPage />,
|
||||||
loader: async () => {
|
loader: async () => {
|
||||||
db.ready = await db.isAvailable();
|
db.ready = await db.isAvailable();
|
||||||
await System.Init();
|
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;
|
return null;
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
|
Reference in New Issue
Block a user