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
|
# Ignore client folder as it's being built into public/ folder
|
||||||
# except for the specified files which are used by the server
|
# except for the specified files which are used by the server
|
||||||
client/**
|
client/**
|
||||||
|
!client/js/constants.js
|
||||||
!client/js/helpers/ircmessageparser/findLinks.js
|
!client/js/helpers/ircmessageparser/findLinks.js
|
||||||
!client/js/helpers/ircmessageparser/cleanIrcMessage.js
|
!client/js/helpers/ircmessageparser/cleanIrcMessage.js
|
||||||
!client/index.html.tpl
|
!client/index.html.tpl
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
const constants = require("../js/constants");
|
||||||
import throttle from "lodash/throttle";
|
import throttle from "lodash/throttle";
|
||||||
import constants from "../js/constants";
|
|
||||||
import storage from "../js/localStorage";
|
import storage from "../js/localStorage";
|
||||||
|
|
||||||
import Sidebar from "./Sidebar.vue";
|
import Sidebar from "./Sidebar.vue";
|
||||||
|
@ -71,12 +71,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
const constants = require("../js/constants");
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import Username from "./Username.vue";
|
import Username from "./Username.vue";
|
||||||
import LinkPreview from "./LinkPreview.vue";
|
import LinkPreview from "./LinkPreview.vue";
|
||||||
import ParsedMessage from "./ParsedMessage.vue";
|
import ParsedMessage from "./ParsedMessage.vue";
|
||||||
import MessageTypes from "./MessageTypes";
|
import MessageTypes from "./MessageTypes";
|
||||||
import constants from "../js/constants";
|
|
||||||
|
|
||||||
MessageTypes.ParsedMessage = ParsedMessage;
|
MessageTypes.ParsedMessage = ParsedMessage;
|
||||||
MessageTypes.LinkPreview = LinkPreview;
|
MessageTypes.LinkPreview = LinkPreview;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import constants from "../js/constants";
|
const constants = require("../js/constants");
|
||||||
import Message from "./Message.vue";
|
import Message from "./Message.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
<script>
|
<script>
|
||||||
require("intersection-observer");
|
require("intersection-observer");
|
||||||
|
|
||||||
import constants from "../js/constants";
|
const constants = require("../js/constants");
|
||||||
import clipboard from "../js/clipboard";
|
import clipboard from "../js/clipboard";
|
||||||
import socket from "../js/socket";
|
import socket from "../js/socket";
|
||||||
import Message from "./Message.vue";
|
import Message from "./Message.vue";
|
||||||
@ -258,6 +258,7 @@ export default {
|
|||||||
socket.emit("more", {
|
socket.emit("more", {
|
||||||
target: this.channel.id,
|
target: this.channel.id,
|
||||||
lastId: lastMessage,
|
lastId: lastMessage,
|
||||||
|
condensed: this.$store.state.settings.statusMessages !== "shown",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onLoadButtonObserved(entries) {
|
onLoadButtonObserved(entries) {
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
const constants = require("./constants");
|
||||||
|
|
||||||
import Mousetrap from "mousetrap";
|
import Mousetrap from "mousetrap";
|
||||||
import {Textcomplete, Textarea} from "textcomplete";
|
import {Textcomplete, Textarea} from "textcomplete";
|
||||||
import fuzzy from "fuzzy";
|
import fuzzy from "fuzzy";
|
||||||
|
|
||||||
import emojiMap from "./helpers/simplemap.json";
|
import emojiMap from "./helpers/simplemap.json";
|
||||||
import constants from "./constants";
|
|
||||||
import store from "./store";
|
import store from "./store";
|
||||||
|
|
||||||
export default enableAutocomplete;
|
export default enableAutocomplete;
|
||||||
|
@ -26,7 +26,8 @@ const timeFormats = {
|
|||||||
msgWithSeconds: "HH:mm:ss",
|
msgWithSeconds: "HH:mm:ss",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
// This file is required by server, can't use es6 export
|
||||||
|
module.exports = {
|
||||||
colorCodeMap,
|
colorCodeMap,
|
||||||
commands: [],
|
commands: [],
|
||||||
condensedTypes,
|
condensedTypes,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
const constants = require("./constants");
|
||||||
|
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
import VueRouter from "vue-router";
|
import VueRouter from "vue-router";
|
||||||
|
|
||||||
@ -12,7 +14,6 @@ import Help from "../components/Windows/Help.vue";
|
|||||||
import Changelog from "../components/Windows/Changelog.vue";
|
import Changelog from "../components/Windows/Changelog.vue";
|
||||||
import NetworkEdit from "../components/Windows/NetworkEdit.vue";
|
import NetworkEdit from "../components/Windows/NetworkEdit.vue";
|
||||||
import RoutedChat from "../components/RoutedChat.vue";
|
import RoutedChat from "../components/RoutedChat.vue";
|
||||||
import constants from "./constants";
|
|
||||||
import store from "./store";
|
import store from "./store";
|
||||||
|
|
||||||
const router = new VueRouter({
|
const router = new VueRouter({
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import constants from "../constants";
|
const constants = require("../constants");
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
|
|
||||||
socket.on("commands", function(commands) {
|
socket.on("commands", function(commands) {
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
const constants = require("./constants");
|
||||||
|
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
import store from "./store";
|
import store from "./store";
|
||||||
import App from "../components/App.vue";
|
import App from "../components/App.vue";
|
||||||
import localetime from "./helpers/localetime";
|
import localetime from "./helpers/localetime";
|
||||||
import storage from "./localStorage";
|
import storage from "./localStorage";
|
||||||
import {router, navigate} from "./router";
|
import {router, navigate} from "./router";
|
||||||
import constants from "./constants";
|
|
||||||
import socket from "./socket";
|
import socket from "./socket";
|
||||||
|
|
||||||
Vue.filter("localetime", localetime);
|
Vue.filter("localetime", localetime);
|
||||||
|
@ -11,6 +11,7 @@ const Helper = require("./helper");
|
|||||||
const UAParser = require("ua-parser-js");
|
const UAParser = require("ua-parser-js");
|
||||||
const uuidv4 = require("uuid/v4");
|
const uuidv4 = require("uuid/v4");
|
||||||
const escapeRegExp = require("lodash/escapeRegExp");
|
const escapeRegExp = require("lodash/escapeRegExp");
|
||||||
|
const constants = require("../client/js/constants.js");
|
||||||
const inputs = require("./plugins/inputs");
|
const inputs = require("./plugins/inputs");
|
||||||
const PublicClient = require("./plugins/packages/publicClient");
|
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 requested id is not found, an empty array will be sent
|
||||||
if (index > 0) {
|
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 {
|
return {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const expect = require("chai").expect;
|
const expect = require("chai").expect;
|
||||||
const constants = require("../../../client/js/constants").default;
|
const constants = require("../../../client/js/constants");
|
||||||
|
|
||||||
describe("client-side constants", function() {
|
describe("client-side constants", function() {
|
||||||
describe(".colorCodeMap", function() {
|
describe(".colorCodeMap", function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user