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

fix: set link default value to random (copy) #181

Merged
merged 3 commits into from Jul 1, 2023

Conversation

pierrbt
Copy link
Contributor

@pierrbt pierrbt commented Jul 1, 2023

The link input has now a default value, which is a random string.
I've kept the Generate link to make another one, if the user wants, or if he make a bad manipulation and have to generate another link.

@pierrbt
Copy link
Contributor Author

pierrbt commented Jul 1, 2023

This Pull Request resolves #180

package.json Outdated Show resolved Hide resolved
@stonith404
Copy link
Owner

Nice, thanks again for all your PRs :)

@pierrbt
Copy link
Contributor Author

pierrbt commented Jul 1, 2023

No problems, I'm working on the reverse shares options.

@pierrbt
Copy link
Contributor Author

pierrbt commented Jul 1, 2023

@stonith404

I'll just need help because I had to modify a bit the database, to add a string, which contains a JSON object :

export type ReverseShareOptions = {
  easyMode: boolean;

  customLinkEnabled: boolean;
  passwordEnabled: boolean;
  descriptionEnabled: boolean;
  maximalViewsEnabled: boolean;
}

And I also changed the backend service and DTOs, but I would like to add this modification, without breaking the current db, how can I do that ? I would like to put default values for all the current reverse shares but I don't know how to do ...

@pierrbt
Copy link
Contributor Author

pierrbt commented Jul 1, 2023

For the frontend there is no problem, because I can do smth like this :

const getMyReverseShares = async (): Promise<MyReverseShare[]> => {
  const shares = (await api.get("reverseShares")).data;
  for (const share of shares)
  {
    share.sharesOptions = JSON.parse(share.sharesOptions);
    if(Object.keys(share.sharesOptions).length === 0)
      share.sharesOptions = structuredClone(defaultReverseShareOptions);
  }

  return shares;
};

But the backend db resets if the schema has changed. Personally, I have regenerated the db :

npx prisma db push
npx prisma db seed

But for all the other users, how could I make the new release without having to reset their db ?

@stonith404
Copy link
Owner

@pierrbt I probably would add a new table and add a 1:1 connection between the ReverseShare and ReverseShareOptions table as a a relational database shouldn't have a JSON object inside a cell.

For the migration part, it is quite easy with prisma. You just have to run npx prisma dev. Then a sql file will get created in ./prisma/migrations/{your_migration}. Now you can update the sql file that the existing reverse shares will get the correct data.

Btw. you can write me on Discord (stonith404) then we don't have to discuss things in random PRs or issues.

@stonith404 stonith404 merged commit 4e1f4f8 into stonith404:main Jul 1, 2023
1 check passed
@pierrbt pierrbt changed the title fix: set link default value to random fix: set link default value to random (copy) Jul 10, 2023
stonith404 added a commit that referenced this pull request Jul 10, 2023
* fix: set link default value to random

* fix: add auto EOL and add conventional-changelog package

* feat: Adding reverse shares' shares a clickable link (#178)

* Add clickable link to reverse share's shares

* Ran format

* Apply suggestions from code review

* fix: set link default value to random (#181)

* fix: set link default value to random

* fix: add auto EOL and add conventional-changelog package

* Apply suggestions from code review

---------

Co-authored-by: Elias Schneider <login@eliasschneider.com>

* feat: Adding reverse share ability to copy the link (#179)

---------

Co-authored-by: Elias Schneider <login@eliasschneider.com>
stonith404 added a commit that referenced this pull request Jul 10, 2023
* Add clickable link to reverse share's shares

* Ran format

* Adding copy icon to the reverse share list

* Remove console.log

* Ran format

* Ran format in backend

* fix: copy to clipboard spelling

* Open the share in another window

* feat: Adding reverse shares' shares a clickable link (#178)

* Add clickable link to reverse share's shares

* Ran format

* fix: set link default value to random (#181)

* fix: set link default value to random

* fix: add auto EOL and add conventional-changelog package

* Apply suggestions from code review

---------

Co-authored-by: Elias Schneider <login@eliasschneider.com>

* feat: Adding reverse share ability to copy the link (#179)

---------

Co-authored-by: Elias Schneider <login@eliasschneider.com>
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.

None yet

2 participants