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

Made URL of new channel creation page more generic #4863

Open
wants to merge 19 commits into
base: unstable
Choose a base branch
from

Conversation

shruti862
Copy link
Contributor

Summary

Made URL of new channel creation page more generic to avoid 404 channel not found message on refreshing the page
Screencast from 22-12-24 12:22:47 AM IST.webm

References

Fixes issue #2389

Reviewer guidance

Copy link
Member

@bjester bjester left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! I tested it and it works, but I have several requested changes and suggestions

.then(channel => {
if (this.isNew) {
const newChannelId = channel.id;
window.location = window.Urls.channel(newChannelId);
Copy link
Member

Choose a reason for hiding this comment

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

I realize this line of code was existing, but ideally it should have used window.location.assign. Since the behavior of the new channel creation page is changing, I think it might be better to either use window.location.replace directly, or perhaps replace the current location with the RouteNames.CHANNEL_EDIT route using the new channel ID, then assign to window.Urls.channel(newChannelId)

if (this.isNew) {
const newChannelId = channel.id;
window.location = window.Urls.channel(newChannelId);
this.$store.dispatch('showSnackbarSimple', this.$tr('channelCreated'));
Copy link
Member

Choose a reason for hiding this comment

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

Since the page needs a reload, I don't know that this snackbar is worth it. The display of it must race the page load, which could mean it's never shown, depending on various factors related to speed.

if (!id) {
throw ReferenceError('id must be defined to update a channel');
throw new ReferenceError('id must be defined to update a channel');
Copy link
Member

Choose a reason for hiding this comment

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

nice catch

}

// Log the data before sending it to create a new channel
console.log('Creating new channel with data:', newChannelData);
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the console.log statements in this vuex action. Thank you


// If there's no channelId (i.e., it's a new channel), skip verifications
if (!channelId) {
//this.isNew = true;
Copy link
Member

Choose a reason for hiding this comment

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

Please remove this commented out code.

// If there's no channelId (i.e., it's a new channel), skip verifications
if (!channelId) {
//this.isNew = true;
this.header = 'New Channel'; // Default header for a new channel
Copy link
Member

Choose a reason for hiding this comment

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

This seems redundant with the code in mounted. I suggest removing this.

this.header = this.channel.name; // Get channel name when user enters modal
if (this.isNew) {
// For a new channel, set a default header
this.header = 'New Channel';
Copy link
Member

Choose a reason for hiding this comment

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

This needs to use our UI strings. For example, using this.$tr with the preexisting string key in the $trs object of the component.

return Channel.createModel(newChannelData).then(response => {
console.log('API Response:', response);

const createdChannel = response.data || response; // Adjust based on API structure
Copy link
Member

Choose a reason for hiding this comment

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

It must be one or the other-- either response.data or response? I suggest making this specific.

}
if (contentDefaults !== NOVALUE) {
newChannelData.content_defaults = contentDefaults;
}
Copy link
Member

Choose a reason for hiding this comment

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

The above code is very similar to the if branch above in this function. I'm requesting deduplication of the code because the only real difference should be the presence of id which isn't significant enough to warrant the duplication. For example, it seems there are differences here in how it handles the thumbnail above, which leads to a regression that I can see when you upload a thumbnail for a new channel and adjust it's cropping.

@shruti862
Copy link
Contributor Author

shruti862 commented Jan 23, 2025

hey @bjester ,I’ve implemented the changes you suggested, and everything is working as expected in terms of the channel creation process. However, I’ve encountered another issue. Whenever I close the ChannelModal without creating a new channel or when selecting the "EXIT WITHOUT SAVING" option after editing, an empty channel is still being created which on reloading the empty channel vanishes.
Screenshot from 2025-01-23 16-07-18

I don't know why this is happening ,Could you kindly assist in identifying the root cause of this behavior and help me resolve it?

@MisRob
Copy link
Member

MisRob commented Jan 27, 2025

However, I’ve encountered another issue. Whenever I close the ChannelModal without creating a new channel or when selecting the "EXIT WITHOUT SAVING" option after editing, an empty channel is still being created which on reloading the page vanishes.

@shruti862 was this the case before your latest changes in this pull request? If so, feel free to open a new issue if there is not one yet. If your changes introduce it, it'd be best to spend some time debugging and resolve it in this pull request.

@shruti862
Copy link
Contributor Author

@MisRob, the empty channel creation issue is due to my recent changes. After debugging, I have identified the root cause and will resolve it soon.

@shruti862
Copy link
Contributor Author

Hey, @MisRob @bjester , createChannel function was creating an empty channel ::

  newChannel() {
        this.$analytics.trackClick('channel_list', 'Create channel');
        this.createChannel().then(id => {
          this.$router.push({
            name: RouteNames.CHANNEL_EDIT,
            params: { channelId: id, tab: 'edit' },
            query: { last: this.$route.name },
          });
        });
      },

When I removed the function from the line of code:

newChannel() {
        this.$analytics.trackClick('channel_list', 'Create channel');
        
          this.$router.push({
            name: RouteNames.NEW_CHANNEL,
            query: { last: this.$route.name },
          });
      },

Due to this change ,one frontend test is failing which says new channel should be created when new channel button is clicked which should not be the case because clicking on create button in new channel modal should create a new channel.
Screenshot from 2025-01-29 16-58-48

@shruti862 shruti862 requested a review from bjester January 30, 2025 11:44
@shruti862
Copy link
Contributor Author

Hey @MisRob @bjester,

Could you assist me with the failing frontend test issue? I’d like to understand the cause and how to resolve it. Your guidance would be greatly appreciated.

Thanks!

@MisRob
Copy link
Member

MisRob commented Jan 31, 2025

Hello @shruti862, we will follow-up with you, however please be patient as we have a large queue of pull request to work through. It's good to send a reminder if we don't reply roughly after a week. Thank you!

@shruti862
Copy link
Contributor Author

@MisRob ,I apologize if I caused any inconvenience. I appreciate your time and will wait patiently. Thank you!

@MisRob
Copy link
Member

MisRob commented Jan 31, 2025

No problem @shruti862 at all. Thank you.

@MisRob
Copy link
Member

MisRob commented Feb 3, 2025

Hi @shruti862

the empty channel creation issue is due to my recent changes. After debugging, I have identified the root cause and will resolve it soon.

Good news, thanks.

Due to this change ,one frontend test is failing which says new channel should be created when new channel button is clicked which should not be the case because clicking on create button in new channel modal should create a new channel

This sounds that you just need to update tests to align them well with your changes, is that right? Basically the test suite would ideally correspond to user experience so you're welcome to update the test accordingly.

@MisRob
Copy link
Member

MisRob commented Feb 3, 2025

@shruti862 Also if you find any other tests related to this feature that are perhaps still passing but their description or implementation doesn't correspond anymore, that's always great to update too. Thanks for reaching out to clarify this and let us know if you needed anything else.

@shruti862
Copy link
Contributor Author

Hey @MisRob ,Thank you for clarifying my doubt :). I will soon update the test.

@shruti862
Copy link
Contributor Author

Hey @MisRob @bjester, I’ve implemented all the suggested changes and also fixed the failing frontend test. Whenever you have a moment, could you please take a look at my changes and let me know if any further improvements are needed? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refreshing the channel creation page leads to 404 channel not found
3 participants