Skip to content

Commit

Permalink
bump applesauce version
Browse files Browse the repository at this point in the history
  • Loading branch information
hzrd149 committed Dec 12, 2024
1 parent 3583373 commit c31d16f
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 153 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"rxjs": "^7.8.1",
"three": "^0.170.0",
"three-spritetext": "^1.9.2",
"three-stdlib": "^2.34.1",
"three-stdlib": "^2.35.2",
"tiny-lru": "^11.2.11",
"unified": "^11.0.5",
"vite-plugin-funding": "^0.1.0",
Expand Down
264 changes: 140 additions & 124 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/const.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCoordinateFromAddressPointer, safeRelayUrls } from "applesauce-core/helpers";
import { safeRelayUrls } from "applesauce-core/helpers";
import { EventFactoryClient } from "applesauce-factory";
import { kinds } from "nostr-tools";

Expand Down Expand Up @@ -52,7 +52,6 @@ export const NEVER_ATTACH_CLIENT_TAG = [kinds.EncryptedDirectMessage];
export const NIP_89_CLIENT_APP: EventFactoryClient = {
name: "noStrudel",
address: {
kind: kinds.Handlerinformation,
pubkey: "266815e0c9210dfa324c6cba3573b14bee49da4209a9456f9484e5106cd408a5",
identifier: "1686066542546",
},
Expand Down
5 changes: 4 additions & 1 deletion src/helpers/nostr/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { EventSplit } from "./zaps";
import { unique } from "../array";

import { getEventPointerRelayHint } from "../../services/relay-hints";
import { eventStore } from "../../services/event-store";

/** @deprecated use event factory instead */
function addTag(tags: Tag[], tag: Tag, overwrite = false) {
if (tags.some((t) => t[0] === tag[0] && t[1] === tag[1])) {
if (overwrite) {
Expand All @@ -25,6 +25,8 @@ function addTag(tags: Tag[], tag: Tag, overwrite = false) {
}
return [...tags, tag];
}

/** @deprecated use event factory instead */
function AddEtag(tags: Tag[], eventId: string, relayHint?: string, type?: string, overwrite = false) {
const hint = relayHint || getEventPointerRelayHint(eventId) || "";

Expand All @@ -42,6 +44,7 @@ function AddEtag(tags: Tag[], eventId: string, relayHint?: string, type?: string
return [...tags, tag];
}

/** @deprecated use event factory instead */
function AddQuotePointerTag(tags: Tag[], pointer: EventPointer) {
const hint = pointer.relays?.[0] || getEventPointerRelayHint(pointer.id) || "";

Expand Down
7 changes: 4 additions & 3 deletions src/helpers/nostr/stream.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { kinds } from "nostr-tools";
import { getEventPointerFromETag, getTagValue, safeRelayUrl, unixNow } from "applesauce-core/helpers";

import { DraftNostrEvent, NostrEvent, isPTag } from "../../types/nostr-event";
import { ensureNotifyContentMentions } from "./post";
import { getEventCoordinate } from "./event";
import { kinds } from "nostr-tools";
import { getEventPointerFromTag, getTagValue, safeRelayUrl, unixNow } from "applesauce-core/helpers";

export type StreamStatus = "live" | "ended" | "planned";

Expand All @@ -26,7 +27,7 @@ export function getStreamHost(stream: NostrEvent) {

export function getStreamGoalPointer(stream: NostrEvent) {
const goalTag = stream.tags.find((t) => t[0] === "goal");
return goalTag && getEventPointerFromTag(goalTag);
return goalTag && getEventPointerFromETag(goalTag);
}

/** Gets all the streaming urls for a stream */
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/use-channel-metadata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMemo } from "react";
import { ChannelMetadataQuery } from "applesauce-channel";
import { ChannelMetadataQuery } from "applesauce-channel/queries";
import { useStoreQuery } from "applesauce-react/hooks";

import { RequestOptions } from "../services/replaceable-events";
Expand Down
5 changes: 4 additions & 1 deletion src/providers/global/publish-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ export default function PublishProvider({ children }: PropsWithChildren) {
!draft.tags.some((t) => t[0] === "client")
) {
// TODO: this should be removed when all events are created using the event factory
draft = await includeClientTag(NIP_89_CLIENT_APP.name, NIP_89_CLIENT_APP.address)(draft, {});
draft = await includeClientTag(
NIP_89_CLIENT_APP.name,
NIP_89_CLIENT_APP.address ? { ...NIP_89_CLIENT_APP.address, kind: kinds.Handlerinformation } : undefined,
)(draft, {});
}

// request signature
Expand Down
2 changes: 1 addition & 1 deletion src/services/channel-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import dayjs from "dayjs";
import { Debugger } from "debug";
import _throttle from "lodash.throttle";
import { Filter, kinds } from "nostr-tools";
import { getChannelPointer } from "applesauce-channel";
import { getChannelPointer } from "applesauce-channel/helpers";

import SuperMap from "../classes/super-map";
import { NostrEvent } from "../types/nostr-event";
Expand Down
2 changes: 1 addition & 1 deletion src/views/channels/channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { memo, useCallback, useMemo } from "react";
import { useNavigate } from "react-router-dom";
import { Button, Flex, Heading, Spacer, Spinner, useDisclosure } from "@chakra-ui/react";
import { kinds } from "nostr-tools";
import { ChannelHiddenQuery, ChannelMessagesQuery, ChannelMutedQuery } from "applesauce-channel";
import { ChannelHiddenQuery, ChannelMessagesQuery, ChannelMutedQuery } from "applesauce-channel/queries";
import { useStoreQuery } from "applesauce-react/hooks";

import useSingleEvent from "../../hooks/use-single-event";
Expand Down
35 changes: 17 additions & 18 deletions src/views/channels/components/send-message-form.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import { useCallback, useRef, useState } from "react";
import { useRef, useState } from "react";
import { useForm } from "react-hook-form";
import dayjs from "dayjs";
import { kinds } from "nostr-tools";

import { EventTemplate } from "nostr-tools";
import { Button, ButtonGroup, Flex, FlexProps, Heading } from "@chakra-ui/react";
import { useEventFactory } from "applesauce-react/hooks";
import { ChannelMessageBlueprint, ChannelMessageReplyBlueprint } from "applesauce-channel/blueprints";
import { Emoji } from "applesauce-core/helpers";

import MagicTextArea, { RefType } from "../../../components/magic-textarea";
import useTextAreaUploadFile, { useTextAreaInsertTextWithForm } from "../../../hooks/use-textarea-upload-file";
import { DraftNostrEvent, NostrEvent } from "../../../types/nostr-event";
import { createEmojiTags, ensureNotifyPubkeys, getPubkeysMentionedInContent } from "../../../helpers/nostr/post";
import { NostrEvent } from "../../../types/nostr-event";
import { useContextEmojis } from "../../../providers/global/emoji-provider";
import { usePublishEvent } from "../../../providers/global/publish-provider";
import InsertGifButton from "../../../components/gif/insert-gif-button";
import InsertImageButton from "../../../components/post-modal/insert-image-button";

export default function ChannelMessageForm({
channel,
rootId,
root,
...props
}: { channel: NostrEvent; rootId?: string } & Omit<FlexProps, "children">) {
}: { channel: NostrEvent; root?: NostrEvent } & Omit<FlexProps, "children">) {
const publish = usePublishEvent();
const emojis = useContextEmojis();
const factory = useEventFactory();

const [loadingMessage, setLoadingMessage] = useState("");
const { getValues, setValue, watch, handleSubmit, formState, reset } = useForm({
Expand All @@ -37,18 +38,16 @@ export default function ChannelMessageForm({
const { onPaste } = useTextAreaUploadFile(insertText);

const sendMessage = handleSubmit(async (values) => {
if (!values.content) return;
if (!values.content || !factory) return;

let draft: DraftNostrEvent = {
kind: kinds.ChannelMessage,
content: values.content,
tags: [["e", rootId || channel.id, "", "root"]],
created_at: dayjs().unix(),
};
const customEmojis = emojis.filter((e) => !!e.url) as Emoji[];

const contentMentions = getPubkeysMentionedInContent(draft.content);
draft = createEmojiTags(draft, emojis);
draft = ensureNotifyPubkeys(draft, contentMentions);
let draft: EventTemplate;
if (root) {
draft = await factory.create(ChannelMessageReplyBlueprint, root, values.content, { emojis: customEmojis });
} else {
draft = await factory.create(ChannelMessageBlueprint, channel, values.content, { emojis: customEmojis });
}

setLoadingMessage("Signing...");
await publish("Send DM", draft, undefined, false);
Expand Down

0 comments on commit c31d16f

Please sign in to comment.