Skip to content

Commit

Permalink
Add more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Aug 31, 2023
1 parent 6a64d7c commit d8a6f85
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/services/subsocial/commentIds/mutation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getMaxMessageLength } from '@/constants/chat'
import useWaitHasEnergy from '@/hooks/useWaitHasEnergy'
import { useSaveFile } from '@/services/api/mutation'
import { useMessageData } from '@/stores/message'
import { MutationConfig } from '@/subsocial-query'
import { useSubsocialMutation } from '@/subsocial-query/subsocial/mutation'
import { IpfsWrapper, ReplyWrapper } from '@/utils/ipfs'
Expand Down Expand Up @@ -35,12 +36,16 @@ export function useSendMessage(config?: MutationConfig<SendMessageParams>) {
'Your message is too long, please split it up to multiple messages'
)

useMessageData.getState().setDoing('waiting energy')
console.log('waiting energy...')
await waitHasEnergy()
useMessageData.getState().setDoing('got energy')
const { cid, success } = await saveFile(generateMessageContent(params))
useMessageData.getState().setDoing('file saved')

if (!success) throw new Error('Failed to save file to IPFS')

useMessageData.getState().setDoing('creating post')
return {
tx: substrateApi.tx.posts.createPost(
null,
Expand Down
4 changes: 3 additions & 1 deletion src/subsocial-query/subsocial/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ async function createTxAndSend<Data>(
},
optimisticCallbacks?: ReturnType<typeof generateTxCallbacks>
) {
useMessageData.getState().setDoing('creating tx')
const { tx, summary } = await transactionGenerator(data, apis)
useMessageData.getState().setDoing('tx created')
return sendTransaction(
{
tx,
Expand All @@ -110,7 +112,7 @@ async function createTxAndSend<Data>(
optimisticCallbacks
)
}
function sendTransaction<Data, Context>(
function sendTransaction<Data>(
txInfo: {
tx: Transaction
summary: string
Expand Down

0 comments on commit d8a6f85

Please sign in to comment.