Skip to content

Commit

Permalink
store: Replace/revive URL instances.
Browse files Browse the repository at this point in the history
Like we did in bfe7949, for ZulipVersion instances. We don't store
any of these in Redux yet, but we will soon.
  • Loading branch information
chrisbobbe committed Sep 16, 2020
1 parent 26272d8 commit 0e8820e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/boot/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ const SERIALIZED_TYPE_FIELD_NAME: '__serializedType__' = '__serializedType__';
const customReplacer = (key, value, defaultReplacer) => {
if (value instanceof ZulipVersion) {
return { data: value.raw(), [SERIALIZED_TYPE_FIELD_NAME]: 'ZulipVersion' };
} else if (value instanceof URL) {
return { data: value.toString(), [SERIALIZED_TYPE_FIELD_NAME]: 'URL' };
}
return defaultReplacer(key, value);
};
Expand All @@ -273,6 +275,8 @@ const customReviver = (key, value, defaultReviver) => {
switch (value[SERIALIZED_TYPE_FIELD_NAME]) {
case 'ZulipVersion':
return new ZulipVersion(data);
case 'URL':
return new URL(data);
default:
// Fall back to defaultReviver, below
}
Expand Down

0 comments on commit 0e8820e

Please sign in to comment.