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

added share option #510

Merged
merged 5 commits into from
Feb 4, 2021
Merged

added share option #510

merged 5 commits into from
Feb 4, 2021

Conversation

prabureddy
Copy link
Contributor

Resolves #509

Copy link
Collaborator

@daltonfury42 daltonfury42 left a comment

Choose a reason for hiding this comment

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

Neatly done. Thanks.

simplq/src/components/pages/Admin/ShareQueue.jsx Outdated Show resolved Hide resolved
@@ -26,4 +46,87 @@ const ShareQueue = (props) => {
);
};

const ShareQueue = (props) => {
const [open, setOpen] = useState(false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

The component gets re-rendered in the background when we make an API call to the server in the background. (See here)

This causes the popper to close. You can observe this by opening it, and waiting for less than 10s. If it's trivial to get around this, you can try, otherwise leave it as is. This can be handled later more elegantly after #507.

Copy link
Contributor Author

@prabureddy prabureddy Feb 2, 2021

Choose a reason for hiding this comment

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

I used memo() even then the component is rendering.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Alright, you mean that it is not helping, right? If not, let's remove the memo()

Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed this too, let me see if I can figure out why.

Copy link
Collaborator

@maaverik maaverik Feb 2, 2021

Choose a reason for hiding this comment

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

It's due to us polling for updates, some logic like this would work, atleast it looks like there are no problems when I tried it.

Suggested change
const [open, setOpen] = useState(false);
let prevData;
const update = useCallback(() => {
clearTimeout(timeoutId);
requestMaker(QueueRequestFactory.get(queueId)).then((data) => {
if (data && (JSON.stringify(prevData) !== JSON.stringify(data))) {
setTokens(data.tokens);
...

Basically comparing old data with new one and only changing state if needed. There might be some inbuilt method that react provides for this, not really sure yet.

Copy link
Collaborator

@daltonfury42 daltonfury42 Feb 3, 2021

Choose a reason for hiding this comment

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

A positive side effect of #507 is that, then one component will fire an action (refresh button, periodic refresh service), and only the component that subscribes to this data gets re-rendered.

Then we would not have this problem. If we can wait till #507 is done, we can leave it as is and merge this PR. I don't see an urgent need to update main site. Else if we are going to do some quick-fix, let us leave a comment here explaining what and why, so that we remove it post #507 .

Copy link
Contributor

Choose a reason for hiding this comment

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

#507 has its first component ready. To do all the components it will take more time or hands on deck. It should be a priority since it's gonna make a lot of things easier.

Copy link
Collaborator

@daltonfury42 daltonfury42 Feb 3, 2021

Choose a reason for hiding this comment

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

@mradenovic Can you do one component and let us finalise and merge that. Once that's done, me, @maaverik and others will migrate the remaining components taking your PR as a reference.

I think we can do a lot of other things in the same way. You lead the way and do one sample. Remaining repetitive work, we will take up. ✌️

Copy link
Contributor

Choose a reason for hiding this comment

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

Absolutely @daltonfury42 , Anything for me?

Copy link
Collaborator

@daltonfury42 daltonfury42 Feb 3, 2021

Choose a reason for hiding this comment

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

Yes, can you review #507? You can also send a proposal for #490 if you want to do some CSS

simplq/src/components/pages/Admin/ShareQueue.jsx Outdated Show resolved Hide resolved
@prabureddy
Copy link
Contributor Author

Updated!!!! 💯

Copy link
Collaborator

@maaverik maaverik left a comment

Choose a reason for hiding this comment

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

This is a great start, kudos @prabureddy. We can brainstorm and improve it further down the line. A small addition I thought would be nice is if we could add a small border or a gradient difference between the dropdown arrow and the "Copy Queue Link" text, to make it really obvious that the arrow does something else, like we see in the fork and star button vs count in github.
Screenshot from 2021-02-03 00-48-37

@prabureddy prabureddy requested a review from maaverik February 3, 2021 13:24
@@ -19,6 +19,7 @@
"react/destructuring-assignment": 0,
"prefer-destructuring": 0,
"import/no-named-as-default": 0,
"dot-notation": 0
"dot-notation": 0,
"react/jsx-props-no-spreading": 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we avoid this and explicitly pass down props?

I was checking, and props spreading does affect readability.

If there is a good reason you need to do this in the PR, we can disable it inline where you are using it, but try to avoid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, removed (react/jsx-props-no-spreading) and passed down props. Now it is readable.

2. removed react/jsx-props-no-spreading
Copy link
Collaborator

@maaverik maaverik left a comment

Choose a reason for hiding this comment

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

Great PR. Thanks!

@maaverik maaverik merged commit 218d73e into SimplQ:master Feb 4, 2021
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.

Add a new button on the admin page to share queue info to different platforms
5 participants