1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-21 21:30:08 +00:00

Add user option to limit maximum amount of messages per tab

This commit is contained in:
Maximilian Mader 2014-12-17 21:04:55 +01:00
parent ea693dae00
commit 5d43af828b
5 changed files with 45 additions and 15 deletions

View File

@ -703,6 +703,13 @@ Insert the given messages into the chat stream.
createNewMessage = yes
clearChannel 0
if message.isInPrivateChannel and message.sender is WCF.User.userID
container = $ "#timsChatMessageContainer#{message.receiver} > ul"
else if message.isInPrivateChannel
container = $ "#timsChatMessageContainer#{message.sender} > ul"
else
container = $ '#timsChatMessageContainer0 > ul'
if createNewMessage
message.isFollowUp = no
output = v.messageTemplate.fetch
@ -716,32 +723,35 @@ Insert the given messages into the chat stream.
li.addClass 'ownMessage' if message.sender is WCF.User.userID
li.append output
if message.isInPrivateChannel and message.sender is WCF.User.userID
li.appendTo $ "#timsChatMessageContainer#{message.receiver} > ul"
else if message.isInPrivateChannel
li.appendTo $ "#timsChatMessageContainer#{message.sender} > ul"
else
li.appendTo $ '#timsChatMessageContainer0 > ul'
li.appendTo container
else
message.isFollowUp = yes
output = v.messageTemplate.fetch
message: message
messageTypes: v.config.messageTypes
if message.isInPrivateChannel and message.sender is WCF.User.userID
messageContainerID = message.receiver
else if message.isInPrivateChannel
messageContainerID = message.sender
else
messageContainerID = 0
textContainer = $("#timsChatMessageContainer#{messageContainerID}").find '.timsChatMessage:last-child .timsChatTextContainer'
textContainer = container.find '.timsChatMessage:last-child .timsChatTextContainer'
textContainer.append $(output).find('.timsChatTextContainer li:last-child')
# unmark messages
textContainer.parents('.timsChatMessage').removeClass 'checked'
textContainer.siblings('.timsChatMessageGroupMarker').prop 'checked', false
if v.config.messagesPerTab
timsChatText = container.find '.timsChatText'
if timsChatText.length > v.config.messagesPerTab
firstMessage = do timsChatText.first
timsChatMessage = firstMessage.parents '.timsChatMessage'
if timsChatMessage.find('.timsChatTextContainer').children().length > 1
time = firstMessage.siblings(':first').find '> time'
timsChatMessage.find('.timsChatInnerMessage > time').replaceWith time
do firstMessage.remove
else
do timsChatMessage.remove
lastMessage = message
$('.timsChatMessageContainer.active').scrollTop $('.timsChatMessageContainer.active').prop('scrollHeight') if $('#timsChatAutoscroll').data('status') is 1

View File

@ -125,6 +125,11 @@
<item name="wcf.user.activityPoint.objectType.be.bastelstu.chat.activityPointEvent.message"><![CDATA[Chat-Nachrichten]]></item>
</category>
<category name="wcf.user.option">
<item name="wcf.user.option.chatMessagesPerTab"><![CDATA[Chat-Nachrichten]]></item>
<item name="wcf.user.option.chatMessagesPerTab.description"><![CDATA[Anzahl der Chat-Nachrichten, die pro Tab angezeigt werden. [0 für unbeschränkt]]]></item>
</category>
<category name="chat.error">
<item name="chat.error.notFound"><![CDATA[Der Befehl „{$exception->getCommand()}“ wurde nicht gefunden.]]></item>
<item name="chat.error.userNotFound"><![CDATA[Der Benutzer „{$exception->getUsername()}“ wurde nicht gefunden.]]></item>

View File

@ -125,6 +125,11 @@
<item name="wcf.user.activityPoint.objectType.be.bastelstu.chat.activityPointEvent.message"><![CDATA[Chat Messages]]></item>
</category>
<category name="wcf.user.option">
<item name="wcf.user.option.chatMessagesPerTab"><![CDATA[Chat Messages]]></item>
<item name="wcf.user.option.chatMessagesPerTab.description"><![CDATA[Amount of messages per tab being displayed at once. [0 for infinite]]]></item>
</category>
<category name="chat.error">
<item name="chat.error.notFound"><![CDATA[The command “{$exception->getCommand()}” could not be found.]]></item>
<item name="chat.error.userNotFound"><![CDATA[The user “{$exception->getUsername()}” could not be found.]]></item>

View File

@ -58,7 +58,8 @@
messageURL: '{link application="chat" controller="NewMessages"}{/link}',
installedCommands: [ {implode from=$commands item='command'}'{$command|encodeJS}'{/implode} ],
messageTypes: { {implode from=$messageTypes key='name' item='messageType'}'{$name|substr:5|encodeJS}': {$messageType}{/implode} },
autoAwayTime: {@CHAT_AUTOAWAY}
autoAwayTime: {@CHAT_AUTOAWAY},
messagesPerTab: {@$__wcf->getUser()->chatMessagesPerTab}
};
{event name='beforeInit'}

View File

@ -19,6 +19,15 @@
<optiontype>boolean</optiontype>
<defaultvalue>1</defaultvalue>
</option>
<option name="chatMessagesPerTab">
<categoryname>settings.general.interface</categoryname>
<optiontype>integer</optiontype>
<visible>1</visible>
<editable>1</editable>
<defaultvalue>0</defaultvalue>
<minvalue>0</minvalue>
</option>
</options>
</import>
</data>