Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Trustroots/nostr-map
Browse files Browse the repository at this point in the history
  • Loading branch information
K committed Aug 11, 2024
2 parents 510c4a1 + 8c8890e commit 8f45f72
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 21 deletions.
14 changes: 0 additions & 14 deletions src/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,6 @@ function generateDatetimeFromNote(note: Note): string {
const date = new Date(createdAt * 1000);

return date.toLocaleString();

const month = ("0" + (date.getMonth() + 1)).slice(-2); // Months are zero-based, so add 1
const day = ("0" + date.getDate()).slice(-2);

// Extract the time components
const hours = ("0" + date.getHours()).slice(-2);
const minutes = ("0" + date.getMinutes()).slice(-2);

// Format the date and time strings
const datetime = `${hours}:${minutes} ${day}-${month}`;

return datetime;
}

function generateLinkFromNote(note: Note): string {
Expand Down Expand Up @@ -320,11 +308,9 @@ function createPopupHtml(createNoteCallback) {
submitButton.onclick = () => {
const content = contentTextArea.value;
const expirationTime = parseInt(expirationSelect.value) || null;
console.log("time", expirationTime);
const expirationDate = expirationTime
? Math.floor(Date.now() / 1000 + expirationTime)
: null;
console.log("expiration date", expirationDate), expirationTime;
createNoteCallback(content, expirationDate);
map.closePopup();
};
Expand Down
2 changes: 1 addition & 1 deletion src/nostr/relays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const _publish = async (event: NostrEvent): Promise<void> => {

type SubscribeParams = {
filters: Filter[];
onEvent: (event: nostrify.NostrEvent) => void;
onEvent: (event: NostrEvent) => void;
};
export const _query = async ({
filters,
Expand Down
4 changes: 2 additions & 2 deletions src/nostr/subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ export const subscribe = async ({
: eventsBaseFilter;
const eventsFilterWithLimit = { ...eventsFilter, limit };

const noteEventsQueue: nostrify.NostrEvent[] = [];
const noteEventsQueue: NostrEvent[] = [];

const onNoteEvent = (event: nostrify.NostrEvent) => {
const onNoteEvent = (event: NostrEvent) => {
// if (isDev()) console.log("#gITVd2 gotNoteEvent", event);

if (
Expand Down
2 changes: 1 addition & 1 deletion src/nostr/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const filterForTag = (key: string) => (tags: string[]) =>

type GetTagFirstValueFromEventParams = {
/** The event to extract the tag value from */
event: nostrify.NostrEvent;
event: NostrEvent;
/** The name (key) of the tag to get the value of */
tag: string;
};
Expand Down
9 changes: 6 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Event } from "nostr-tools";
import * as nostrify from "@nostrify/nostrify";

export type MaybeLocalStorage = Partial<WindowLocalStorage>;

export type NostrEvent = Required<Event>;
export type NostrEvent = nostrify.NostrEvent;

export type UnsignedEvent = Omit<Event, "created_at" | "pubkey">;
export type UnsignedEvent = Omit<
NostrEvent,
"created_at" | "pubkey" | "id" | "sig"
>;

export type Note = {
id: string;
Expand Down

0 comments on commit 8f45f72

Please sign in to comment.