Merge pull request #3603 from thelounge/xpaw/condensed-more
Send 100 actual messages when requesting history with hidden or condensed status messages
This commit is contained in:
commit
356a896fe2
@ -9,6 +9,7 @@
|
||||
# Ignore client folder as it's being built into public/ folder
|
||||
# except for the specified files which are used by the server
|
||||
client/**
|
||||
!client/js/constants.js
|
||||
!client/js/helpers/ircmessageparser/findLinks.js
|
||||
!client/js/helpers/ircmessageparser/cleanIrcMessage.js
|
||||
!client/index.html.tpl
|
||||
|
@ -10,8 +10,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const constants = require("../js/constants");
|
||||
import throttle from "lodash/throttle";
|
||||
import constants from "../js/constants";
|
||||
import storage from "../js/localStorage";
|
||||
|
||||
import Sidebar from "./Sidebar.vue";
|
||||
|
@ -71,12 +71,12 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const constants = require("../js/constants");
|
||||
import dayjs from "dayjs";
|
||||
import Username from "./Username.vue";
|
||||
import LinkPreview from "./LinkPreview.vue";
|
||||
import ParsedMessage from "./ParsedMessage.vue";
|
||||
import MessageTypes from "./MessageTypes";
|
||||
import constants from "../js/constants";
|
||||
|
||||
MessageTypes.ParsedMessage = ParsedMessage;
|
||||
MessageTypes.LinkPreview = LinkPreview;
|
||||
|
@ -18,7 +18,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import constants from "../js/constants";
|
||||
const constants = require("../js/constants");
|
||||
import Message from "./Message.vue";
|
||||
|
||||
export default {
|
||||
|
@ -57,7 +57,7 @@
|
||||
<script>
|
||||
require("intersection-observer");
|
||||
|
||||
import constants from "../js/constants";
|
||||
const constants = require("../js/constants");
|
||||
import clipboard from "../js/clipboard";
|
||||
import socket from "../js/socket";
|
||||
import Message from "./Message.vue";
|
||||
@ -258,6 +258,7 @@ export default {
|
||||
socket.emit("more", {
|
||||
target: this.channel.id,
|
||||
lastId: lastMessage,
|
||||
condensed: this.$store.state.settings.statusMessages !== "shown",
|
||||
});
|
||||
},
|
||||
onLoadButtonObserved(entries) {
|
||||
|
@ -1,11 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
const constants = require("./constants");
|
||||
|
||||
import Mousetrap from "mousetrap";
|
||||
import {Textcomplete, Textarea} from "textcomplete";
|
||||
import fuzzy from "fuzzy";
|
||||
|
||||
import emojiMap from "./helpers/simplemap.json";
|
||||
import constants from "./constants";
|
||||
import store from "./store";
|
||||
|
||||
export default enableAutocomplete;
|
||||
|
@ -26,7 +26,8 @@ const timeFormats = {
|
||||
msgWithSeconds: "HH:mm:ss",
|
||||
};
|
||||
|
||||
export default {
|
||||
// This file is required by server, can't use es6 export
|
||||
module.exports = {
|
||||
colorCodeMap,
|
||||
commands: [],
|
||||
condensedTypes,
|
||||
|
@ -1,5 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const constants = require("./constants");
|
||||
|
||||
import Vue from "vue";
|
||||
import VueRouter from "vue-router";
|
||||
|
||||
@ -12,7 +14,6 @@ import Help from "../components/Windows/Help.vue";
|
||||
import Changelog from "../components/Windows/Changelog.vue";
|
||||
import NetworkEdit from "../components/Windows/NetworkEdit.vue";
|
||||
import RoutedChat from "../components/RoutedChat.vue";
|
||||
import constants from "./constants";
|
||||
import store from "./store";
|
||||
|
||||
const router = new VueRouter({
|
||||
|
@ -1,4 +1,4 @@
|
||||
import constants from "../constants";
|
||||
const constants = require("../constants");
|
||||
import socket from "../socket";
|
||||
|
||||
socket.on("commands", function(commands) {
|
||||
|
@ -1,12 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
const constants = require("./constants");
|
||||
|
||||
import Vue from "vue";
|
||||
import store from "./store";
|
||||
import App from "../components/App.vue";
|
||||
import localetime from "./helpers/localetime";
|
||||
import storage from "./localStorage";
|
||||
import {router, navigate} from "./router";
|
||||
import constants from "./constants";
|
||||
import socket from "./socket";
|
||||
|
||||
Vue.filter("localetime", localetime);
|
||||
|
@ -11,6 +11,7 @@ const Helper = require("./helper");
|
||||
const UAParser = require("ua-parser-js");
|
||||
const uuidv4 = require("uuid/v4");
|
||||
const escapeRegExp = require("lodash/escapeRegExp");
|
||||
const constants = require("../client/js/constants.js");
|
||||
const inputs = require("./plugins/inputs");
|
||||
const PublicClient = require("./plugins/packages/publicClient");
|
||||
|
||||
@ -465,7 +466,31 @@ Client.prototype.more = function(data) {
|
||||
|
||||
// If requested id is not found, an empty array will be sent
|
||||
if (index > 0) {
|
||||
messages = chan.messages.slice(Math.max(0, index - 100), index);
|
||||
let startIndex = index;
|
||||
|
||||
if (data.condensed) {
|
||||
// Limit to 1000 messages (that's 10x normal limit)
|
||||
const indexToStop = Math.max(0, index - 1000);
|
||||
let realMessagesLeft = 100;
|
||||
|
||||
for (let i = index - 1; i >= indexToStop; i--) {
|
||||
startIndex--;
|
||||
|
||||
// Do not count condensed messages towards the 100 messages
|
||||
if (constants.condensedTypes.has(chan.messages[i].type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Count up actual 100 visible messages
|
||||
if (--realMessagesLeft === 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
startIndex = Math.max(0, index - 100);
|
||||
}
|
||||
|
||||
messages = chan.messages.slice(startIndex, index);
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const expect = require("chai").expect;
|
||||
const constants = require("../../../client/js/constants").default;
|
||||
const constants = require("../../../client/js/constants");
|
||||
|
||||
describe("client-side constants", function() {
|
||||
describe(".colorCodeMap", function() {
|
||||
|
Loading…
Reference in New Issue
Block a user