Software /
code /
verse
Diff
plugins/disco.lua @ 475:68a4fb45afbc
disco: Fire disco-info-changed when necessary, move presence resending there
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 17 Mar 2023 11:15:18 +0000 |
parent | 474:fca0c7672148 |
child | 490:6b2f31da9610 |
line wrap: on
line diff
--- a/plugins/disco.lua Fri Mar 17 11:12:12 2023 +0000 +++ b/plugins/disco.lua Fri Mar 17 11:15:18 2023 +0000 @@ -94,25 +94,25 @@ function stream:set_identity(identity, node) self.disco.info[node or false].identities = { identity }; - stream:resend_presence(); + stream:event("disco-info-changed"); end function stream:add_identity(identity, node) local identities = self.disco.info[node or false].identities; identities[#identities + 1] = identity; - stream:resend_presence(); + stream:event("disco-info-changed"); end function stream:add_disco_feature(feature, node) local feature = feature.var or feature; self.disco.info[node or false].features[feature] = true; - stream:resend_presence(); + stream:event("disco-info-changed"); end function stream:remove_disco_feature(feature, node) local feature = feature.var or feature; self.disco.info[node or false].features[feature] = nil; - stream:resend_presence(); + stream:event("disco-info-changed"); end function stream:add_disco_item(item, node) @@ -339,6 +339,10 @@ presence:remove_children("c", xmlns_caps); presence:reset():add_child(stream:caps()):reset(); end, 10); + + stream:hook("disco-info-changed", function () + stream:resend_presence(); + end); end -- end of disco.lua