chore: Minor fix

This commit is contained in:
iamsivin
2025-10-14 19:20:32 +05:30
parent 20bc51e45e
commit fe24fe418b

View File

@@ -362,37 +362,29 @@ export default {
) )
this.avatarUrl = this.inbox.avatar_url; this.avatarUrl = this.inbox.avatar_url;
}, },
setTabFromRoute() {
const tabParam = this.$route.params.tab;
if (!tabParam) {
this.selectedTabIndex = 0;
return;
}
const tabIndex = this.tabs.findIndex(tab => tab.key === tabParam);
this.selectedTabIndex = tabIndex >= 0 ? tabIndex : 0;
},
onTabChange(selectedTabIndex) { onTabChange(selectedTabIndex) {
this.selectedTabIndex = selectedTabIndex; this.selectedTabIndex = selectedTabIndex;
this.refreshAvatarUrlOnTabChange(selectedTabIndex); this.refreshAvatarUrlOnTabChange(selectedTabIndex);
this.updateRouteWithoutRefresh(selectedTabIndex);
},
updateRouteWithoutRefresh(selectedTabIndex) {
const tab = this.tabs[selectedTabIndex];
if (!tab) return;
// Update URL const { accountId, inboxId } = this.$route.params;
const currentTab = this.tabs[selectedTabIndex]; const baseUrl = `/app/accounts/${accountId}/settings/inboxes/${inboxId}`;
if (!currentTab) return;
const params = { // Append the tab key only if it's not the default.
accountId: this.$route.params.accountId, const newUrl =
inboxId: this.$route.params.inboxId, tab.key === 'inbox-settings' ? baseUrl : `${baseUrl}/${tab.key}`;
}; // Update URL without triggering route watcher
window.history.replaceState(null, '', newUrl);
},
setTabFromRouteParam() {
const { tab: tabParam } = this.$route.params;
const tabIndex = this.tabs.findIndex(tab => tab.key === tabParam);
// Only add tab param if not the first tab (inbox-settings) this.selectedTabIndex = tabIndex === -1 ? 0 : tabIndex;
if (currentTab.key !== 'inbox-settings') {
params.tab = currentTab.key;
}
this.$router.replace({
name: 'settings_inbox_show',
params,
});
}, },
fetchInboxSettings() { fetchInboxSettings() {
this.selectedAgents = []; this.selectedAgents = [];
@@ -421,8 +413,8 @@ export default {
? this.inbox.help_center.slug ? this.inbox.help_center.slug
: ''; : '';
// Set tab from route after inbox data is loaded and tabs are computed // Set initial tab after inbox data is loaded
this.setTabFromRoute(); this.setTabFromRouteParam();
}); });
}, },
async updateInbox() { async updateInbox() {