Skip to content

Commit

Permalink
Show topic creator and timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsOnlyBinary committed Aug 25, 2023
1 parent 378b98b commit e258c3b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
18 changes: 14 additions & 4 deletions src/components/SidebarAboutBuffer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@
<i class="fa fa-angle-right" /> {{ $t('about') }}
</h4>
<div>
<p v-if="b.topic" v-html="formattedTopic" />
<p v-else>{{ $t('no_topic_set') }}</p>

<p v-if="b.created_at">
{{ $t('created_at', { when: new Intl.DateTimeFormat().format(b.created_at) }) }}
{{ $t('created_on', { when: new Intl.DateTimeFormat().format(b.created_at) }) }}
</p>

<template v-if="b.topic">
<p v-html="formattedTopic" />
<p v-if="b.topic_by && b.topic_when">
{{
$t('topic_setby', {
who: b.topic_by,
when: new Intl.DateTimeFormat().format(b.topic_when)
})
}}
</p>
</template>
<p v-else>{{ $t('no_topic_set') }}</p>

<p class="kiwi-aboutbuffer-usercount">
<a class="u-link " @click="sidebarState.showNicklist()">
{{ $t('person', {count: Object.keys(b.users || {}).length}) }}
Expand Down
13 changes: 12 additions & 1 deletion src/libs/IrcClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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',
Expand All @@ -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, {
Expand Down
4 changes: 3 additions & 1 deletion src/libs/state/BufferState.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
14 changes: 11 additions & 3 deletions src/res/locales/app.dev.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e258c3b

Please sign in to comment.