-
Notifications
You must be signed in to change notification settings - Fork 4
Feat/mobile upload flow #193
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
59e9812
fix: header logic in secondary
Sahil2004 9e0f554
fix: fixed the text in header in post
Sahil2004 7ac4cff
feat: trying some hack to get file image input.
Sahil2004 2a0baf1
feat: added image input on clicking the post bottom nav
Sahil2004 5856dcb
chore: got rid of non-required code.
Sahil2004 4e9a762
feat: added the logic to get the images from user on clicking post tab.
Sahil2004 468db66
feat: added store.
Sahil2004 f1e5ad4
feat: added correct conversion of files.
Sahil2004 78e648d
feat: added the correct display of image when uploading.
Sahil2004 cdfb4d4
feat: added settings tile to the post page and fixed the settingsTile…
Sahil2004 ae3ba2d
feat: added hte correct header for the audience page.
Sahil2004 89ac7ed
fix: fixed the page transition not happening to audience page.
Sahil2004 2a1eb67
feat: added audience setting
Sahil2004 16046c9
feat: added store to audience.
Sahil2004 bb019ac
chore: removed console log
Sahil2004 7ed4214
feat: added post button.
Sahil2004 74b859c
feat: correct button placement
Sahil2004 dabf6b9
Merge branch 'main' into feat/mobile-upload-flow
Sahil2004 73841de
fix: horizontal scroll
Sahil2004 9720ae8
fix: positioning of the post button.
Sahil2004 8c32220
fix: protecting post route when no image is selected.
Sahil2004 7f3a1a5
fix: improved type saftey
Sahil2004 e659343
feat: added memory helper function
Sahil2004 18e135d
feat: added memory cleanup.
Sahil2004 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
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,17 +1,25 @@ | ||
import type { PostData } from '$lib/types'; | ||
import type { Image, PostData } from "$lib/types"; | ||
|
||
export const isNavigatingThroughNav = $state({ | ||
value: false | ||
value: false, | ||
}); | ||
|
||
export const showComments = $state({ | ||
value: false | ||
value: false, | ||
}); | ||
|
||
export const ownerId = $state({ | ||
value: '1' | ||
value: "1", | ||
}); | ||
|
||
export const selectedPost: { value: PostData | null } = $state({ | ||
value: null | ||
value: null, | ||
}); | ||
|
||
export const uploadedImages: { value: Image[] | null } = $state({ | ||
value: null, | ||
}); | ||
|
||
export const audience: { value: string } = $state({ | ||
value: "Everyone", | ||
}); |
This file contains hidden or 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 |
---|---|---|
@@ -1,43 +1,48 @@ | ||
import type { SVGAttributes } from 'svelte/elements'; | ||
import type { SVGAttributes } from "svelte/elements"; | ||
|
||
export interface ISvgProps extends SVGAttributes<SVGElement> { | ||
size?: number | string; | ||
color?: string; | ||
size?: number | string; | ||
color?: string; | ||
} | ||
|
||
export type CommentType = { | ||
commentId: string; | ||
name: string; | ||
userImgSrc: string; | ||
comment: string; | ||
isUpVoted: boolean; | ||
isDownVoted: boolean; | ||
upVotes: number; | ||
time: string; | ||
replies: CommentType[]; | ||
commentId: string; | ||
name: string; | ||
userImgSrc: string; | ||
comment: string; | ||
isUpVoted: boolean; | ||
isDownVoted: boolean; | ||
upVotes: number; | ||
time: string; | ||
replies: CommentType[]; | ||
}; | ||
|
||
export type PostData = { | ||
id: string; | ||
avatar: string; | ||
userId: string; | ||
username: string; | ||
imgUris: string[]; | ||
caption: string; | ||
time: string; | ||
count: { | ||
likes: number; | ||
comments: number; | ||
}; | ||
id: string; | ||
avatar: string; | ||
userId: string; | ||
username: string; | ||
imgUris: string[]; | ||
caption: string; | ||
time: string; | ||
count: { | ||
likes: number; | ||
comments: number; | ||
}; | ||
}; | ||
|
||
export type userProfile = { | ||
userId: string; | ||
username: string; | ||
avatar: string; | ||
totalPosts: number; | ||
followers: number; | ||
following: number; | ||
userBio: string; | ||
posts: PostData[]; | ||
userId: string; | ||
username: string; | ||
avatar: string; | ||
totalPosts: number; | ||
followers: number; | ||
following: number; | ||
userBio: string; | ||
posts: PostData[]; | ||
}; | ||
|
||
export type Image = { | ||
url: string; | ||
alt: string; | ||
}; |
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './mergeClasses'; | ||
export * from './clickOutside'; | ||
export * from "./mergeClasses"; | ||
export * from "./clickOutside"; | ||
export * from "./memoryHelper"; |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { Image } from "$lib/types"; | ||
|
||
export const revokeImageUrls = (imageArray: Image[]) => { | ||
imageArray?.forEach((img) => URL.revokeObjectURL(img.url)); | ||
}; |
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<script lang="ts"> | ||
import { goto } from '$app/navigation'; | ||
import { SettingsTile, UploadedPostView } from '$lib/fragments'; | ||
import { audience, uploadedImages } from '$lib/store/store.svelte'; | ||
import { Button, Textarea } from '$lib/ui'; | ||
import { revokeImageUrls } from '$lib/utils'; | ||
|
||
let caption: string = $state(''); | ||
|
||
$effect(() => { | ||
if (!uploadedImages.value || uploadedImages.value.length === 0) { | ||
window.history.back(); | ||
} | ||
}) | ||
</script> | ||
|
||
<section class="h-fit w-full flex flex-col gap-3 justify-stretch"> | ||
<UploadedPostView | ||
images={uploadedImages.value ?? []} | ||
width="w-auto" | ||
height="h-40" | ||
callback={(i: number) => { | ||
if (uploadedImages.value) | ||
uploadedImages.value = uploadedImages.value.filter((img, index) => { | ||
revokeImageUrls([img]); | ||
return index !== i | ||
}); | ||
}} | ||
/> | ||
|
||
<label for="caption"> | ||
<span class="block mb-2 font-semibold">Add a caption</span> | ||
<Textarea name="caption" rows={3} bind:value={caption} placeholder="Hey guys..." /> | ||
</label> | ||
|
||
<SettingsTile | ||
title="Who can see your posts?" | ||
currentStatus={audience.value} | ||
onclick={() => goto('/post/audience')} | ||
/> | ||
|
||
<Button variant="secondary" callback={() => alert('TODO: Post created!')} class="mt-1">Post</Button> | ||
</section> |
20 changes: 20 additions & 0 deletions
20
platforms/metagram/src/routes/(protected)/post/audience/+page.svelte
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script lang="ts"> | ||
import { audience } from '$lib/store/store.svelte'; | ||
import { InputRadio } from '$lib/ui'; | ||
</script> | ||
|
||
<h1 class="mb-4">Who can see your posts?</h1> | ||
<span class="flex flex-col gap-4"> | ||
<label for="Everyone" class="flex items-center justify-between"> | ||
Everyone | ||
<InputRadio value="Everyone" name="audience" bind:selected={audience.value} /> | ||
</label> | ||
<label for="Only Followers" class="flex items-center justify-between"> | ||
Only Followers | ||
<InputRadio value="Only Followers" name="audience" bind:selected={audience.value} /> | ||
</label> | ||
<label for="No one" class="flex items-center justify-between"> | ||
No one | ||
<InputRadio value="No one" name="audience" bind:selected={audience.value} /> | ||
</label> | ||
</span> |
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.
🛠️ Refactor suggestion
Potential navigation issue with history.back().
Using
window.history.back()
can cause unpredictable behavior if the user didn't navigate from within the app (e.g., direct URL access, page refresh).This ensures users are redirected to a known safe route instead of relying on browser history.
🤖 Prompt for AI Agents