Skip to content
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: Persist 'Share as Image' options #1581

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

sharunkumar
Copy link
Contributor

@sharunkumar sharunkumar commented Aug 11, 2024

Resolves #1547

All the toggle buttons would be persisted

In the case where the user hits the upper limit for parent comments, the setting would remember it and set all future shares to have all parent comments visible


db.setSetting(
"share_as_image_preferences",
JSON.parse(JSON.stringify(state)),
Copy link
Contributor Author

@sharunkumar sharunkumar Aug 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative to this was

Suggested change
JSON.parse(JSON.stringify(state)),
{
post: { ...state.post },
comment: { ...state.comment },
}

passing state directly, or using structuredClone didn't work either.

@@ -0,0 +1,16 @@
import { ShareAsImagePreferences } from "./ShareAsImagePreferences";

export const defaultPreferences: ShareAsImagePreferences = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to have these in a separate file, as I intend to flip some of these values downstream

@sharunkumar
Copy link
Contributor Author

sharunkumar commented Aug 11, 2024

@aeharding also, currently one of the toggles is labelled "Include Post Text", which seems to be misleading. In case of image posts, this actually toggles the image within the screenshot

Update: I've renamed it to "Include Post Content"

@sharunkumar sharunkumar marked this pull request as ready for review August 11, 2024 20:01
@aeharding
Copy link
Owner

Thanks for making this PR!

I tried to run locally, but the image isn't appearing (Firefox). It working in main but I haven't investigated further.

Screenshot 2024-08-12 at 10 55 48 PM

@sharunkumar
Copy link
Contributor Author

sharunkumar commented Aug 13, 2024

I tried opening the built docker version on Firefox and it seems to be working:
image

arch linux btw

Update: it even works as expected when running with pnpm dev:

image

@aeharding
Copy link
Owner

@sharunkumar Can you try share as image on the post, not a comment? That is where it fails for me.

@sharunkumar
Copy link
Contributor Author

@sharunkumar Can you try share as image on the post, not a comment? That is where it fails for me.

I'll look into it in a bit

Comment on lines -128 to -170
const [includePostDetails, setIncludePostDetails] = useState(
!("comment" in data),
);
Copy link
Contributor Author

@sharunkumar sharunkumar Oct 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aeharding I guess this was the cause of the issue, and its not browser dependent. I tried it in incognito window in edge and its reproducing

includePostDetails is currently false by default in my config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I have fixed the issue in my latest commit: c8af557 (#1581)

let me know if there's anything else

@sharunkumar sharunkumar force-pushed the persist-share-as-image-choices branch from a273f68 to c8af557 Compare October 5, 2024 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Options to configure defaults on 'Share as Image' on comments
2 participants