Page MenuHomePhabricator

D9148.id30966.diff
No OneTemporary

D9148.id30966.diff

diff --git a/lib/utils/conversion-utils.js b/lib/utils/conversion-utils.js
--- a/lib/utils/conversion-utils.js
+++ b/lib/utils/conversion-utils.js
@@ -4,7 +4,12 @@
import _mapValues from 'lodash/fp/mapValues.js';
import type { TInterface, TType } from 'tcomb';
+import { convertIDToNewSchema } from './migration-utils.js';
import { assertWithValidator, tID } from './validation-utils.js';
+import {
+ getPendingThreadID,
+ parsePendingThreadID,
+} from '../shared/thread-utils.js';
function convertServerIDsToClientIDs<T>(
serverPrefixID: string,
@@ -16,7 +21,7 @@
console.warn(`Server id '${id}' already has a prefix`);
return id;
}
- return `${serverPrefixID}|${id}`;
+ return convertIDToNewSchema(id, serverPrefixID);
};
return convertObject(outputValidator, data, [tID], conversionFunction);
@@ -33,6 +38,19 @@
return id.substr(prefix.length);
}
+ const pendingIDContents = parsePendingThreadID(id);
+ if (pendingIDContents) {
+ if (!pendingIDContents.sourceMessageID) {
+ return id;
+ }
+
+ return getPendingThreadID(
+ pendingIDContents.threadType,
+ pendingIDContents.memberIDs,
+ pendingIDContents.sourceMessageID.substr(prefix.length),
+ );
+ }
+
throw new Error('invalid_client_id_prefix');
};
diff --git a/lib/utils/conversion-utils.test.js b/lib/utils/conversion-utils.test.js
--- a/lib/utils/conversion-utils.test.js
+++ b/lib/utils/conversion-utils.test.js
@@ -67,3 +67,18 @@
}
});
});
+
+describe('Pending ids tests', () => {
+ it('should convert pending ids', () => {
+ const validator = t.list(tID);
+ const serverData = ['pending/sidebar/1', 'pending/type4/1+2+3'];
+ const clientData = ['pending/sidebar/0|1', 'pending/type4/1+2+3'];
+
+ expect(
+ convertServerIDsToClientIDs('0', validator, serverData),
+ ).toStrictEqual(clientData);
+ expect(
+ convertClientIDsToServerIDs('0', validator, clientData),
+ ).toStrictEqual(serverData);
+ });
+});
diff --git a/web/redux/initial-state-gate.js b/web/redux/initial-state-gate.js
--- a/web/redux/initial-state-gate.js
+++ b/web/redux/initial-state-gate.js
@@ -6,7 +6,9 @@
import type { Persistor } from 'redux-persist/es/types';
import { useServerCall } from 'lib/utils/action-utils.js';
+import { convertIDToNewSchema } from 'lib/utils/migration-utils.js';
import { infoFromURL } from 'lib/utils/url-utils.js';
+import { ashoatKeyserverID } from 'lib/utils/validation-utils.js';
import { getInitialReduxState, setInitialReduxState } from './action-types.js';
import { useSelector } from './redux-utils.js';
@@ -29,7 +31,14 @@
if (!prevIsRehydrated.current && isRehydrated) {
prevIsRehydrated.current = isRehydrated;
(async () => {
- const urlInfo = infoFromURL(decodeURI(window.location.href));
+ let urlInfo = infoFromURL(decodeURI(window.location.href));
+ // Handle older links
+ if (urlInfo.thread) {
+ urlInfo = {
+ ...urlInfo,
+ thread: convertIDToNewSchema(urlInfo.thread, ashoatKeyserverID),
+ };
+ }
const payload = await callGetInitialReduxState(urlInfo);
dispatch({ type: setInitialReduxState, payload });
})();

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 1:25 AM (21 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2587237
Default Alt Text
D9148.id30966.diff (3 KB)

Event Timeline