diff --git a/lib/utils/url-utils.js b/lib/utils/url-utils.js --- a/lib/utils/url-utils.js +++ b/lib/utils/url-utils.js @@ -13,6 +13,8 @@ +apps?: boolean, +thread?: string, +settings?: 'account' | 'danger-zone', + +threadCreation?: boolean, + +selectedUserList?: $ReadOnlyArray, ... }; @@ -29,6 +31,10 @@ `(/|^)thread/(${locallyUniqueThreadIDRegex})(/|$)`, 'i', ); +const threadCreationRegex = new RegExp( + '(/|^)thread/new(/([0-9,]*))?(/|$)', + 'i', +); function infoFromURL(url: string): URLInfo { const yearMatches = yearRegex.exec(url); @@ -41,6 +47,7 @@ const accountSettingsTest = accountSettingsRegex.test(url); const dangerZoneTest = dangerZoneRegex.test(url); const threadPendingMatches = threadPendingRegex.exec(url); + const threadCreateMatches = threadCreationRegex.exec(url); const returnObj = {}; if (yearMatches) { @@ -59,6 +66,10 @@ if (threadPendingMatches) { returnObj.thread = threadPendingMatches[2]; } + if (threadCreateMatches) { + returnObj.threadCreation = true; + returnObj.selectedUserList = threadCreateMatches[3]?.split(',') ?? []; + } if (verifyMatches) { returnObj.verify = verifyMatches[2]; } diff --git a/web/app.react.js b/web/app.react.js --- a/web/app.react.js +++ b/web/app.react.js @@ -154,7 +154,7 @@ const { tab, settingsSection } = this.props.navInfo; if (tab === 'calendar') { mainContent = ; - } else if (tab === 'chat') { + } else if (tab === 'chat' || tab === 'chat-creation') { mainContent = ; } else if (tab === 'apps') { mainContent = ; diff --git a/web/types/nav-types.js b/web/types/nav-types.js --- a/web/types/nav-types.js +++ b/web/types/nav-types.js @@ -3,7 +3,12 @@ import type { BaseNavInfo } from 'lib/types/nav-types'; import type { ThreadInfo } from 'lib/types/thread-types'; -export type NavigationTab = 'calendar' | 'chat' | 'apps' | 'settings'; +export type NavigationTab = + | 'calendar' + | 'chat' + | 'chat-creation' + | 'apps' + | 'settings'; export type NavigationSettingsSection = 'account' | 'danger-zone'; @@ -13,6 +18,7 @@ +activeChatThreadID: ?string, +pendingThread?: ThreadInfo, +settingsSection?: NavigationSettingsSection, + +selectedUserList?: $ReadOnlyArray, }; export const updateNavInfoActionType = 'UPDATE_NAV_INFO'; diff --git a/web/url-utils.js b/web/url-utils.js --- a/web/url-utils.js +++ b/web/url-utils.js @@ -21,8 +21,8 @@ let newURL = `/`; if (loggedIn) { - newURL += `${navInfo.tab}/`; if (navInfo.tab === 'calendar') { + newURL += `${navInfo.tab}/`; const { startDate, endDate } = navInfo; const year = yearExtractor(startDate, endDate); if (urlInfo.year !== undefined) { @@ -54,12 +54,23 @@ newURL += `month/${month}/`; } } else if (navInfo.tab === 'chat') { + newURL += `${navInfo.tab}/`; const activeChatThreadID = navInfo.activeChatThreadID; if (activeChatThreadID) { newURL += `thread/${activeChatThreadID}/`; } + } else if (navInfo.tab === 'chat-creation') { + newURL += `chat/`; + const users = navInfo.selectedUserList?.join(',') ?? ''; + newURL += `thread/new/${users}`; + if (users.length) { + newURL += `/`; + } } else if (navInfo.tab === 'settings' && navInfo.settingsSection) { + newURL += `${navInfo.tab}/`; newURL += `${navInfo.settingsSection}/`; + } else { + newURL += `${navInfo.tab}/`; } } @@ -106,15 +117,24 @@ tab = 'apps'; } else if (urlInfo.settings) { tab = 'settings'; + } else if (urlInfo.threadCreation) { + tab = 'chat-creation'; } - const newNavInfo = { + let newNavInfo = { tab, startDate: startDateForYearAndMonth(year, month), endDate: endDateForYearAndMonth(year, month), activeChatThreadID, }; + if (urlInfo.selectedUserList) { + newNavInfo = { + ...newNavInfo, + selectedUserList: urlInfo.selectedUserList, + }; + } + if (!urlInfo.settings) { return newNavInfo; }