-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(mini-mode): comments input #971
Merged
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bebbf35
WIP: mini comment input component
sachin-into fe1844e
replaced NewsFeedInput with MiniCommentInout
sachin-into d488e8b
added select image and video
sachin-into c497ecd
added style props to comment wrapper component
sachin-into 797e384
added form data for mini mode in useIpfs hooks,
sachin-into 32f03e7
fix mini mode check on useIpfs
sachin-into e697952
added description after ts-expect-error
sachin-into 55028d3
Merge branch 'main' of github.com:TERITORI/teritori-dapp into feat/mi…
omniwired c7159e2
merge with upsteram
omniwired d6bc993
splitted MiniCommentInput into smaller components of CommentTextInput…
sachin-into 6d75f5a
Merge branch 'feat/mini-comments' of https://github.com/TERITORI/teri…
sachin-into f1437f9
fixed forward ref type
sachin-into fda7eaa
fix: replaced appmode check with Platform.OS check in useIPFS hooks
sachin-into File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,13 @@ import { useSelector } from "react-redux"; | |
import { parseUserId } from "@/networks"; | ||
import { selectNFTStorageAPI } from "@/store/slices/settings"; | ||
import { generateIpfsKey } from "@/utils/ipfs"; | ||
import { AppMode } from "@/utils/types/app-mode"; | ||
import { LocalFileData, RemoteFileData } from "@/utils/types/files"; | ||
|
||
interface UploadPostFilesToPinataParams { | ||
files: LocalFileData[]; | ||
pinataJWTKey: string; | ||
mode?: AppMode; | ||
} | ||
|
||
interface IPFSUploadProgress { | ||
|
@@ -22,6 +24,7 @@ interface IPFSUploadProgress { | |
export interface PinataFileProps { | ||
file: LocalFileData; | ||
pinataJWTKey: string; | ||
mode?: AppMode; | ||
} | ||
|
||
export const useIpfs = () => { | ||
|
@@ -33,10 +36,20 @@ export const useIpfs = () => { | |
async ({ | ||
file, | ||
pinataJWTKey, | ||
mode, | ||
}: PinataFileProps): Promise<string | undefined> => { | ||
try { | ||
const formData = new FormData(); | ||
formData.append("file", file.file); | ||
if (mode === "mini") { | ||
//@ts-expect-error: description instead of adding file when adding url in formdata file upload to pinata | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand the comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I state in above comment, to create formData for app side, I did it in that way. |
||
formData.append("file", { | ||
uri: file.url, | ||
name: file.fileName, | ||
type: file.mimeType, | ||
}); | ||
} else { | ||
formData.append("file", file.file); | ||
} | ||
|
||
const responseFile = await axios({ | ||
onUploadProgress: (progressEvent) => { | ||
|
@@ -74,6 +87,7 @@ export const useIpfs = () => { | |
async ({ | ||
files, | ||
pinataJWTKey, | ||
mode = "normal", | ||
}: UploadPostFilesToPinataParams): Promise<RemoteFileData[]> => { | ||
setIpfsUploadProgresses([]); | ||
|
||
|
@@ -83,7 +97,9 @@ export const useIpfs = () => { | |
const fileIpfsHash = await pinataPinFileToIPFS({ | ||
file, | ||
pinataJWTKey, | ||
mode, | ||
}); | ||
|
||
const url = !fileIpfsHash ? "" : "ipfs://" + fileIpfsHash; | ||
|
||
if (file.thumbnailFileData) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this hook need to be aware of the app mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While uploading file from app instead of converting selected file to File type similar to WEB, I just used file URL to create formData and upload it to pinata. So, just to check if we are uploading from web or app I added that appmode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, app mode is not related to mobile or desktop, it's the mode of the ui.
an user could use mini-mode on desktop, btw mini means minimalist, not small screen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use Platform.OS in here directly if possible and remove the new prop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I didn't know that. Will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced app mode check with Platform.OS check