diff --git a/wasm/channels.go b/wasm/channels.go index c3ab3d6780b23da00977ccfd3c443ad8e21c9ea5..5c9fda34375d7a203557711fd0ed29a97b57ba37 100644 --- a/wasm/channels.go +++ b/wasm/channels.go @@ -763,26 +763,6 @@ func (cm *ChannelsManager) JoinChannel(_ js.Value, args []js.Value) any { return utils.CopyBytesToJS(ci) } -func (cm *ChannelsManager) EnableDirectMessages(_ js.Value, args []js.Value) any { - marshalledChanId := utils.CopyBytesToGo(args[0]) - err := cm.api.EnableDirectMessages(marshalledChanId) - if err != nil { - utils.Throw(utils.TypeError, err) - return nil - } - return nil -} - -func (cm *ChannelsManager) DisableDirectMessages(_ js.Value, args []js.Value) any { - marshalledChanId := utils.CopyBytesToGo(args[0]) - err := cm.api.DisableDirectMessages(marshalledChanId) - if err != nil { - utils.Throw(utils.TypeError, err) - return nil - } - return nil -} - // LeaveChannel leaves the given channel. It will return the error // [channels.ChannelDoesNotExistsErr] if the channel was not previously joined. // @@ -848,6 +828,42 @@ func (cm *ChannelsManager) GetChannels(js.Value, []js.Value) any { return utils.CopyBytesToJS(channelList) } +// EnableDirectMessages enables the token for direct messaging for this +// channel. +// +// Parameters: +// - args[0] - Marshalled bytes of the channel [id.ID] (Uint8Array). +// +// Returns: +// - Throws a TypeError if saving the DM token fails. +func (cm *ChannelsManager) EnableDirectMessages(_ js.Value, args []js.Value) any { + marshalledChanId := utils.CopyBytesToGo(args[0]) + err := cm.api.EnableDirectMessages(marshalledChanId) + if err != nil { + utils.Throw(utils.TypeError, err) + return nil + } + return nil +} + +// DisableDirectMessages removes the token for direct messaging for a +// given channel. +// +// Parameters: +// - args[0] - Marshalled bytes of the channel [id.ID] (Uint8Array). +// +// Returns: +// - Throws a TypeError if saving the DM token fails +func (cm *ChannelsManager) DisableDirectMessages(_ js.Value, args []js.Value) any { + marshalledChanId := utils.CopyBytesToGo(args[0]) + err := cm.api.DisableDirectMessages(marshalledChanId) + if err != nil { + utils.Throw(utils.TypeError, err) + return nil + } + return nil +} + //////////////////////////////////////////////////////////////////////////////// // Channel Share URL // ////////////////////////////////////////////////////////////////////////////////