Comparison

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
comparison
equal deleted inserted replaced
474:fca0c7672148 475:68a4fb45afbc
92 end 92 end
93 }) 93 })
94 94
95 function stream:set_identity(identity, node) 95 function stream:set_identity(identity, node)
96 self.disco.info[node or false].identities = { identity }; 96 self.disco.info[node or false].identities = { identity };
97 stream:resend_presence(); 97 stream:event("disco-info-changed");
98 end 98 end
99 99
100 function stream:add_identity(identity, node) 100 function stream:add_identity(identity, node)
101 local identities = self.disco.info[node or false].identities; 101 local identities = self.disco.info[node or false].identities;
102 identities[#identities + 1] = identity; 102 identities[#identities + 1] = identity;
103 stream:resend_presence(); 103 stream:event("disco-info-changed");
104 end 104 end
105 105
106 function stream:add_disco_feature(feature, node) 106 function stream:add_disco_feature(feature, node)
107 local feature = feature.var or feature; 107 local feature = feature.var or feature;
108 self.disco.info[node or false].features[feature] = true; 108 self.disco.info[node or false].features[feature] = true;
109 stream:resend_presence(); 109 stream:event("disco-info-changed");
110 end 110 end
111 111
112 function stream:remove_disco_feature(feature, node) 112 function stream:remove_disco_feature(feature, node)
113 local feature = feature.var or feature; 113 local feature = feature.var or feature;
114 self.disco.info[node or false].features[feature] = nil; 114 self.disco.info[node or false].features[feature] = nil;
115 stream:resend_presence(); 115 stream:event("disco-info-changed");
116 end 116 end
117 117
118 function stream:add_disco_item(item, node) 118 function stream:add_disco_item(item, node)
119 local items = self.disco.items[node or false]; 119 local items = self.disco.items[node or false];
120 items[#items +1] = item; 120 items[#items +1] = item;
337 337
338 stream:hook("presence-out", function (presence) 338 stream:hook("presence-out", function (presence)
339 presence:remove_children("c", xmlns_caps); 339 presence:remove_children("c", xmlns_caps);
340 presence:reset():add_child(stream:caps()):reset(); 340 presence:reset():add_child(stream:caps()):reset();
341 end, 10); 341 end, 10);
342
343 stream:hook("disco-info-changed", function ()
344 stream:resend_presence();
345 end);
342 end 346 end
343 347
344 -- end of disco.lua 348 -- end of disco.lua