unread lines
This commit is contained in:
@@ -394,10 +394,14 @@ class Channel extends SnowFlake {
|
|||||||
return this.owner.info;
|
return this.owner.info;
|
||||||
}
|
}
|
||||||
readStateInfo(json: readyjson["d"]["read_state"]["entries"][0]) {
|
readStateInfo(json: readyjson["d"]["read_state"]["entries"][0]) {
|
||||||
|
const next = this.messages.get(this.idToNext.get(this.lastreadmessageid as string) as string);
|
||||||
this.lastreadmessageid = json.last_message_id;
|
this.lastreadmessageid = json.last_message_id;
|
||||||
this.mentions = json.mention_count;
|
this.mentions = json.mention_count;
|
||||||
this.mentions ??= 0;
|
this.mentions ??= 0;
|
||||||
this.lastpin = json.last_pin_timestamp;
|
this.lastpin = json.last_pin_timestamp;
|
||||||
|
if (next) {
|
||||||
|
next.generateMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
get hasunreads(): boolean {
|
get hasunreads(): boolean {
|
||||||
if (!this.hasPermission("VIEW_CHANNEL")) {
|
if (!this.hasPermission("VIEW_CHANNEL")) {
|
||||||
@@ -699,9 +703,13 @@ class Channel extends SnowFlake {
|
|||||||
headers: this.headers,
|
headers: this.headers,
|
||||||
body: JSON.stringify({}),
|
body: JSON.stringify({}),
|
||||||
});
|
});
|
||||||
|
const next = this.messages.get(this.idToNext.get(this.lastreadmessageid as string) as string);
|
||||||
this.lastreadmessageid = this.lastmessageid;
|
this.lastreadmessageid = this.lastmessageid;
|
||||||
this.guild.unreads();
|
this.guild.unreads();
|
||||||
this.unreads();
|
this.unreads();
|
||||||
|
if (next) {
|
||||||
|
next.generateMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
coatDropDiv(div: HTMLDivElement, container: HTMLElement | boolean = false) {
|
coatDropDiv(div: HTMLDivElement, container: HTMLElement | boolean = false) {
|
||||||
@@ -1509,7 +1517,11 @@ class Channel extends SnowFlake {
|
|||||||
this.lastmessageid = messagez.id;
|
this.lastmessageid = messagez.id;
|
||||||
|
|
||||||
if (messagez.author === this.localuser.user) {
|
if (messagez.author === this.localuser.user) {
|
||||||
|
const next = this.messages.get(this.idToNext.get(this.lastreadmessageid as string) as string);
|
||||||
this.lastreadmessageid = messagez.id;
|
this.lastreadmessageid = messagez.id;
|
||||||
|
if (next) {
|
||||||
|
next.generateMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.unreads();
|
this.unreads();
|
||||||
this.guild.unreads();
|
this.guild.unreads();
|
||||||
|
@@ -405,15 +405,26 @@ class Message extends SnowFlake {
|
|||||||
const build = document.createElement("div");
|
const build = document.createElement("div");
|
||||||
|
|
||||||
build.classList.add("flexltr", "message");
|
build.classList.add("flexltr", "message");
|
||||||
if (premessage && !dupe) {
|
|
||||||
|
const unreadLine = premessage && premessage.id === this.channel.lastreadmessageid;
|
||||||
|
if ((premessage || unreadLine) && !dupe) {
|
||||||
|
let datelineNeeded: boolean;
|
||||||
const thisTime = new Date(this.getUnixTime());
|
const thisTime = new Date(this.getUnixTime());
|
||||||
|
if (premessage && !unreadLine) {
|
||||||
const prevTime = new Date(premessage.getUnixTime());
|
const prevTime = new Date(premessage.getUnixTime());
|
||||||
const datelineNeeded =
|
datelineNeeded =
|
||||||
thisTime.getDay() !== prevTime.getDay() ||
|
thisTime.getDay() !== prevTime.getDay() ||
|
||||||
thisTime.getMonth() !== prevTime.getMonth() ||
|
thisTime.getMonth() !== prevTime.getMonth() ||
|
||||||
thisTime.getFullYear() !== prevTime.getFullYear();
|
thisTime.getFullYear() !== prevTime.getFullYear();
|
||||||
|
} else {
|
||||||
|
console.warn(div);
|
||||||
|
datelineNeeded = true;
|
||||||
|
}
|
||||||
if (datelineNeeded) {
|
if (datelineNeeded) {
|
||||||
const dateline = document.createElement("div");
|
const dateline = document.createElement("div");
|
||||||
|
if (unreadLine) {
|
||||||
|
dateline.classList.add("unreadDateline");
|
||||||
|
}
|
||||||
dateline.classList.add("flexltr", "dateline");
|
dateline.classList.add("flexltr", "dateline");
|
||||||
dateline.append(document.createElement("hr"));
|
dateline.append(document.createElement("hr"));
|
||||||
const span = document.createElement("span");
|
const span = document.createElement("span");
|
||||||
|
@@ -827,7 +827,12 @@ span.instanceStatus {
|
|||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
|
.unreadDateline{
|
||||||
|
color:var(--red);
|
||||||
|
hr{
|
||||||
|
background:var(--red);
|
||||||
|
}
|
||||||
|
}
|
||||||
/* Member Info (DM/Member List) */
|
/* Member Info (DM/Member List) */
|
||||||
.liststyle {
|
.liststyle {
|
||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
|
Reference in New Issue
Block a user