From e258c3be1f8471281f69183a697ed34ae7aac86f Mon Sep 17 00:00:00 2001 From: ItsOnlyBinary Date: Thu, 24 Aug 2023 21:40:00 +0100 Subject: [PATCH] Show topic creator and timestamp --- src/components/SidebarAboutBuffer.vue | 18 ++++++++++++++---- src/libs/IrcClient.js | 13 ++++++++++++- src/libs/state/BufferState.js | 4 +++- src/res/locales/app.dev.po | 14 +++++++++++--- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/components/SidebarAboutBuffer.vue b/src/components/SidebarAboutBuffer.vue index 8dd3cf97f..054b58861 100644 --- a/src/components/SidebarAboutBuffer.vue +++ b/src/components/SidebarAboutBuffer.vue @@ -10,13 +10,23 @@ {{ $t('about') }}
-

-

{{ $t('no_topic_set') }}

-

- {{ $t('created_at', { when: new Intl.DateTimeFormat().format(b.created_at) }) }} + {{ $t('created_on', { when: new Intl.DateTimeFormat().format(b.created_at) }) }}

+ +

{{ $t('no_topic_set') }}

+

{{ $t('person', {count: Object.keys(b.users || {}).length}) }} diff --git a/src/libs/IrcClient.js b/src/libs/IrcClient.js index b40d8355c..21704d45e 100644 --- a/src/libs/IrcClient.js +++ b/src/libs/IrcClient.js @@ -102,7 +102,7 @@ export function create(state, network) { return; } - // Workaround for unsetting the topic as to1459() will remove the trialling colon. + // Workaround for unsetting the topic as to1459() will remove the trailing colon. const isTopic = (args.length === 1 && args[0].indexOf('TOPIC') === 0); if (isTopic && args[0].lastIndexOf(':') === args[0].length - 1) { originalIrcClientRaw.apply(ircClient, args); @@ -1303,6 +1303,9 @@ function clientMiddleware(state, network) { let messageBody = ''; if (event.nick) { + buffer.topic_by = event.nick; + buffer.topic_when = event.time || Date.now(); + typeExtra = 'topic_change'; messageBody = TextFormatting.formatAndT( 'channel_topic', @@ -1327,6 +1330,14 @@ function clientMiddleware(state, network) { } } + if (command === 'topicsetby') { + let buffer = network.bufferByName(event.channel); + if (buffer) { + buffer.topic_by = event.nick; + buffer.topic_when = event.when * 1000; + } + } + if (command === 'help') { let buffer = state.getOrAddBufferByName(networkid, '*help'); state.addMessage(buffer, { diff --git a/src/libs/state/BufferState.js b/src/libs/state/BufferState.js index d1ba6daf6..497e9effe 100644 --- a/src/libs/state/BufferState.js +++ b/src/libs/state/BufferState.js @@ -16,10 +16,12 @@ export default class BufferState { this.networkid = networkid; this.name = name; this.topics = []; + this.topic_by = ''; + this.topic_when = 0; this.key = ''; this.joined = false; this.enabled = true; - this.created_at = null; + this.created_at = 0; this.users = Object.create(null); this.modes = Object.create(null); this.flags = { diff --git a/src/res/locales/app.dev.po b/src/res/locales/app.dev.po index 30fa8215e..c514844cb 100644 --- a/src/res/locales/app.dev.po +++ b/src/res/locales/app.dev.po @@ -758,13 +758,21 @@ msgstr "No buffer set" #: Sidebar About Buffer +#: About +msgid "about" +msgstr "About" + #: There is no topic for this channel msgid "no_topic_set" msgstr "There is no topic for this channel" -#: About -msgid "about" -msgstr "About" +#: Topic set by {{who}} on {{when}} +msgid "topic_setby" +msgstr "Set by {{who}} on {{when}}" + +#: Created on {{when}} +msgid "created_on" +msgstr "Created on {{when}}" #: Created at {{when}} msgid "created_at"