Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32210086
D4457.1765129334.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D4457.1765129334.diff
View Options
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<string>,
...
};
@@ -31,6 +33,10 @@
`(/|^)thread/(${locallyUniqueThreadIDRegex})(/|$)`,
'i',
);
+const threadCreationRegex = new RegExp(
+ '(/|^)thread/new(/([0-9]+([+][0-9]+)*))?(/|$)',
+ 'i',
+);
function infoFromURL(url: string): URLInfo {
const yearMatches = yearRegex.exec(url);
@@ -43,6 +49,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) {
@@ -61,6 +68,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/types/nav-types.js b/web/types/nav-types.js
--- a/web/types/nav-types.js
+++ b/web/types/nav-types.js
@@ -7,12 +7,16 @@
export type NavigationSettingsSection = 'account' | 'danger-zone';
+export type NavigationChatMode = 'view' | 'create';
+
export type NavInfo = {
...$Exact<BaseNavInfo>,
+tab: NavigationTab,
+activeChatThreadID: ?string,
+pendingThread?: ThreadInfo,
+settingsSection?: NavigationSettingsSection,
+ +selectedUserList?: $ReadOnlyArray<string>,
+ +chatMode?: NavigationChatMode,
};
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
@@ -54,9 +54,15 @@
newURL += `month/${month}/`;
}
} else if (navInfo.tab === 'chat') {
- const activeChatThreadID = navInfo.activeChatThreadID;
- if (activeChatThreadID) {
- newURL += `thread/${activeChatThreadID}/`;
+ if (navInfo.chatMode === 'create') {
+ const users = navInfo.selectedUserList?.join('+') ?? '';
+ const potentiallyTrailingSlash = users.length > 0 ? '/' : '';
+ newURL += `thread/new/${users}${potentiallyTrailingSlash}`;
+ } else {
+ const activeChatThreadID = navInfo.activeChatThreadID;
+ if (activeChatThreadID) {
+ newURL += `thread/${activeChatThreadID}/`;
+ }
}
} else if (navInfo.tab === 'settings' && navInfo.settingsSection) {
newURL += `${navInfo.settingsSection}/`;
@@ -108,21 +114,25 @@
tab = 'settings';
}
- const newNavInfo = {
+ const chatMode = urlInfo.threadCreation ? 'create' : 'view';
+
+ const newNavInfo: NavInfo = {
tab,
startDate: startDateForYearAndMonth(year, month),
endDate: endDateForYearAndMonth(year, month),
activeChatThreadID,
+ chatMode,
};
- if (!urlInfo.settings) {
- return newNavInfo;
+ if (urlInfo.selectedUserList) {
+ newNavInfo.selectedUserList = urlInfo.selectedUserList;
}
- return {
- ...newNavInfo,
- settingsSection: urlInfo.settings,
- };
+ if (urlInfo.settings) {
+ newNavInfo.settingsSection = urlInfo.settings;
+ }
+
+ return newNavInfo;
}
export { canonicalURLFromReduxState, navInfoFromURL };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 5:42 PM (22 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5844814
Default Alt Text
D4457.1765129334.diff (3 KB)
Attached To
Mode
D4457: [web] Introduce `chat-creation` mode in `navInfo`
Attached
Detach File
Event Timeline
Log In to Comment