Skip to content

Commit

Permalink
Changed permlink to wave-ntz for Waves page
Browse files Browse the repository at this point in the history
  • Loading branch information
dkildar committed Jan 8, 2025
1 parent 887c6d8 commit d3b3bcb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function useWaveCreate() {
const entry = hostEntries[0];
return {
host,
entry: (await generalApiRequest({ entry, raw, editingEntry })) as WaveEntry,
entry: (await generalApiRequest({ entry, raw, editingEntry, host })) as WaveEntry,
isEditing: !!editingEntry
};
},
Expand Down
12 changes: 9 additions & 3 deletions src/features/waves/components/wave-form/api/use-waves-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useContext } from "react";
import { useGlobalStore } from "@/core/global-store";
import { PollsContext } from "@/features/polls";
import { Entry, FullAccount, WaveEntry } from "@/entities";
import { createReplyPermlink, tempEntry } from "@/utils";
import { createReplyPermlink, createWavePermlink, tempEntry } from "@/utils";
import { EntryMetadataManagement } from "@/features/entry-management";
import { comment } from "@/api/operations";
import { EcencyEntriesCacheManagement } from "@/core/caches";
Expand All @@ -24,19 +24,25 @@ export function useWavesApi() {
mutationFn: async ({
entry,
raw,
editingEntry
editingEntry,
host
}: {
entry: Entry;
raw: string;
editingEntry?: WaveEntry;
host?: string;
}) => {
if (!activeUser || !activeUser.data.__loaded) {
throw new Error("[Wave][Thread-base][API] – No active user");
}
const parentAuthor = editingEntry?.parent_author ?? entry.author;
const parentPermlink = editingEntry?.parent_permlink ?? entry.permlink;

const permlink = editingEntry?.permlink ?? createReplyPermlink(entry.author);
let permlink = editingEntry?.permlink ?? createReplyPermlink(entry.author);

if (host === "ecency.waves" && !editingEntry) {
permlink = createWavePermlink();
}
const tags = raw.match(/\#[a-zA-Z0-9]+/g)?.map((tag) => tag.replace("#", "")) ?? ["ecency"];

const jsonMeta = EntryMetadataManagement.EntryMetadataManager.shared
Expand Down
12 changes: 12 additions & 0 deletions src/utils/posting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ export const createReplyPermlink = (toAuthor?: string) => {
return `re-${toAuthor?.replace(/\./g, "")}-${timeFormat}`;
};

export function createWavePermlink() {
const t = new Date(Date.now());

const timeFormat = `${t.getFullYear().toString()}${(t.getMonth() + 1).toString()}${t
.getDate()
.toString()}t${t.getHours().toString()}${t.getMinutes().toString()}${t
.getSeconds()
.toString()}${t.getMilliseconds().toString()}z`;

return `wave-${timeFormat}`;
}

export const createPatch = (text1: string, text2: string): string | undefined => {
const dmp = new diff_match_patch();
if (text1 === "") return undefined;
Expand Down

0 comments on commit d3b3bcb

Please sign in to comment.