-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Message/PresenceMessage.fromValues and related
Previously, fromValues() took an options object with a 'stringifyAction' bool property. If that was false, then it acted as a normal fromValues; if true, then it was effectively doing a partial fromDeserialized, parsing a wire protocol message into a message but without decoding the message.data. This seemed a bit silly. Removed the options object and replaced it with an explicit Message.fromWireProtocol. Also while doing that ended up changing a bunch of other things that seemed broken: - unnecessary type-assertions due to not having a wire-protocol type, or unnecessary use of any & unknown - channeloptions being type-asserted as cipheroptions, then type-assert back to channeloptions, which made no sense - crypto not being passed-in to history calls, so not getting decrypted
- Loading branch information
1 parent
dce28af
commit c406bef
Showing
17 changed files
with
217 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,35 @@ | ||
import * as API from '../../../../ably'; | ||
import Logger from '../util/logger'; | ||
import PresenceMessage, { fromEncoded, fromEncodedArray, fromValues } from './presencemessage'; | ||
import PresenceMessage, { | ||
fromEncoded, | ||
fromEncodedArray, | ||
fromValues, | ||
WireProtocolPresenceMessage, | ||
} from './presencemessage'; | ||
import Platform from 'common/platform'; | ||
import type { Properties } from '../util/utils'; | ||
|
||
/** | ||
`DefaultPresenceMessage` is the class returned by `DefaultRest` and `DefaultRealtime`’s `PresenceMessage` static property. It introduces the static methods described in the `PresenceMessageStatic` interface of the public API of the non tree-shakable version of the library. | ||
*/ | ||
export class DefaultPresenceMessage extends PresenceMessage { | ||
static async fromEncoded(encoded: unknown, inputOptions?: API.ChannelOptions): Promise<PresenceMessage> { | ||
return fromEncoded(Logger.defaultLogger, encoded, inputOptions); | ||
return fromEncoded(Logger.defaultLogger, Platform.Crypto, encoded as WireProtocolPresenceMessage, inputOptions); | ||
} | ||
|
||
static async fromEncodedArray( | ||
encodedArray: Array<unknown>, | ||
options?: API.ChannelOptions, | ||
): Promise<PresenceMessage[]> { | ||
return fromEncodedArray(Logger.defaultLogger, encodedArray, options); | ||
return fromEncodedArray( | ||
Logger.defaultLogger, | ||
Platform.Crypto, | ||
encodedArray as WireProtocolPresenceMessage[], | ||
options, | ||
); | ||
} | ||
|
||
static fromValues(values: PresenceMessage | Record<string, unknown>, stringifyAction?: boolean): PresenceMessage { | ||
return fromValues(values, stringifyAction); | ||
static fromValues(values: Properties<PresenceMessage>): PresenceMessage { | ||
return fromValues(values); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.