this repo has no description
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

irc: send typing notifications

+23 -1
+23 -1
src/irc.zig
··· 151 151 completer: Completer, 152 152 completer_shown: bool = false, 153 153 typing_last_active: u32 = 0, 154 + typing_last_sent: u32 = 0, 154 155 155 156 // Gutter (left side where time is printed) width 156 157 const gutter_width = 6; ··· 276 277 277 278 self.text_field.userdata = self; 278 279 self.text_field.onSubmit = Channel.onSubmit; 280 + self.text_field.onChange = Channel.onChange; 279 281 } 280 282 281 283 fn onSubmit(ptr: ?*anyopaque, ctx: *vxfw.EventContext, input: []const u8) anyerror!void { ··· 295 297 try self.client.print("PRIVMSG {s} :{s}\r\n", .{ self.name, local }); 296 298 } 297 299 ctx.redraw = true; 300 + } 301 + 302 + fn onChange(ptr: ?*anyopaque, _: *vxfw.EventContext, input: []const u8) anyerror!void { 303 + const self: *Channel = @ptrCast(@alignCast(ptr orelse unreachable)); 304 + if (std.mem.startsWith(u8, input, "/")) { 305 + return; 306 + } 307 + if (input.len == 0) { 308 + self.typing_last_sent = 0; 309 + try self.client.print("@+typing=done TAGMSG {s}\r\n", .{self.name}); 310 + return; 311 + } 312 + const now: u32 = @intCast(std.time.timestamp()); 313 + // Send another typing message if it's been more than 3 seconds 314 + if (self.typing_last_sent + 3 < now) { 315 + try self.client.print("@+typing=active TAGMSG {s}\r\n", .{self.name}); 316 + self.typing_last_sent = now; 317 + return; 318 + } 298 319 } 299 320 300 321 pub fn deinit(self: *Channel, alloc: std.mem.Allocator) void { ··· 2048 2069 const target = iter.next() orelse return; 2049 2070 var channel = try client.getOrCreateChannel(target); 2050 2071 2072 + const trimmed_nick = std.mem.trimRight(u8, user.nick, "_"); 2051 2073 // If it's our nick, we request chat history 2052 - if (mem.eql(u8, user.nick, client.nickname())) { 2074 + if (mem.eql(u8, trimmed_nick, client.nickname())) { 2053 2075 try client.requestHistory(.after, channel); 2054 2076 if (self.app.explicit_join) { 2055 2077 self.app.selectChannelName(client, target);