mirror of
https://github.com/MathMan05/Fermi.git
synced 2026-05-11 19:44:48 +00:00
fix issues with unread states
This commit is contained in:
@@ -572,7 +572,8 @@ class Channel extends SnowFlake {
|
||||
if (!this.hasPermission("VIEW_CHANNEL")) {
|
||||
return false;
|
||||
}
|
||||
let lastreadmessage = this.messages.get(this.lastreadmessageid as string)?.timestamp;
|
||||
if (this.mentions) return true;
|
||||
let lastreadmessage = this.messages.get(this.lastreadmessageid as string)?.getTimeStamp();
|
||||
if (
|
||||
lastreadmessage === undefined &&
|
||||
this.lastreadmessageid &&
|
||||
@@ -580,7 +581,7 @@ class Channel extends SnowFlake {
|
||||
) {
|
||||
lastreadmessage = SnowFlake.stringToUnixTime(this.lastreadmessageid);
|
||||
}
|
||||
let lastmessage = this.lastmessage?.timestamp;
|
||||
let lastmessage = this.lastmessage?.getTimeStamp();
|
||||
if (lastmessage === undefined && this.lastmessageid && !isNaN(+this.lastmessageid)) {
|
||||
lastmessage = SnowFlake.stringToUnixTime(this.lastmessageid);
|
||||
}
|
||||
@@ -2464,9 +2465,6 @@ class Channel extends SnowFlake {
|
||||
if (this.lastmessageid) {
|
||||
this.idToNext.set(this.lastmessageid, messagez.id);
|
||||
this.idToPrev.set(messagez.id, this.lastmessageid);
|
||||
if (!this.messages.has(this.lastmessageid)) {
|
||||
console.error("something bad happened");
|
||||
}
|
||||
} else {
|
||||
console.error("something bad happened");
|
||||
}
|
||||
@@ -2518,6 +2516,8 @@ class Channel extends SnowFlake {
|
||||
notify(message: Message, deep = 0) {
|
||||
if (this.localuser.play) {
|
||||
this.localuser.playSound();
|
||||
} else {
|
||||
console.warn("no play 3:");
|
||||
}
|
||||
if ("Notification" in window && Notification.permission === "granted") {
|
||||
if (message.author.relationshipType == 2) {
|
||||
|
||||
+10
-3
@@ -3,7 +3,7 @@ import {Channel} from "./channel.js";
|
||||
import {Message} from "./message.js";
|
||||
import {Localuser} from "./localuser.js";
|
||||
import {User} from "./user.js";
|
||||
import {channeljson, dirrectjson, memberjson} from "./jsontypes.js";
|
||||
import {channeljson, dirrectjson, memberjson, readyjson} from "./jsontypes.js";
|
||||
import {Permissions} from "./permissions.js";
|
||||
import {SnowFlake} from "./snowflake.js";
|
||||
import {Contextmenu} from "./contextmenu.js";
|
||||
@@ -406,6 +406,7 @@ class Group extends Channel {
|
||||
this.lastmessageid = undefined;
|
||||
}
|
||||
this.mentions = 0;
|
||||
|
||||
this.setUpInfiniteScroller();
|
||||
this.updatePosition();
|
||||
}
|
||||
@@ -440,12 +441,18 @@ class Group extends Channel {
|
||||
notititle(message: Message) {
|
||||
return message.author.username;
|
||||
}
|
||||
readStateInfo(json: readyjson["d"]["read_state"]["entries"][0]): void {
|
||||
super.readStateInfo(json);
|
||||
if (this.lastmessageid !== this.lastreadmessageid && this.mentions === 0) {
|
||||
this.mentions++;
|
||||
}
|
||||
}
|
||||
readbottom() {
|
||||
super.readbottom();
|
||||
this.unreads();
|
||||
}
|
||||
all: WeakRef<HTMLElement> = new WeakRef(document.createElement("div"));
|
||||
noti: WeakRef<HTMLElement> = new WeakRef(document.createElement("div"));
|
||||
noti?: WeakRef<HTMLElement>;
|
||||
del() {
|
||||
const all = this.all.deref();
|
||||
if (all) {
|
||||
@@ -460,7 +467,7 @@ class Group extends Channel {
|
||||
const current = this.all.deref();
|
||||
if (this.hasunreads) {
|
||||
{
|
||||
const noti = this.noti.deref();
|
||||
const noti = this.noti?.deref();
|
||||
if (noti) {
|
||||
noti.textContent = this.mentions + "";
|
||||
return;
|
||||
|
||||
@@ -187,13 +187,14 @@ class Localuser {
|
||||
}
|
||||
onswap?: (l: Localuser) => void;
|
||||
constructor(userinfo: Specialuser | -1) {
|
||||
const events = ["click", "keydown", "touchstart"] as const;
|
||||
const func = () => {
|
||||
Play.playURL("/audio/sounds.jasf").then((_) => {
|
||||
this.play = _;
|
||||
});
|
||||
document.removeEventListener("click", func);
|
||||
events.forEach((event) => document.removeEventListener(event, func));
|
||||
};
|
||||
document.addEventListener("click", func);
|
||||
events.forEach((event) => document.addEventListener(event, func));
|
||||
//TODO get rid of this garbage
|
||||
if (userinfo === -1) {
|
||||
this.rights = new Rights("");
|
||||
@@ -1645,7 +1646,7 @@ class Localuser {
|
||||
serverlist.appendChild(br);
|
||||
const guilds = new Set(this.guilds);
|
||||
const dirrect = this.guilds.find((_) => _ instanceof Direct) as Direct;
|
||||
dirrect.unreaddms();
|
||||
|
||||
guilds.delete(dirrect);
|
||||
const folders = this.guildFolders
|
||||
.map((folder) => {
|
||||
@@ -1720,6 +1721,7 @@ class Localuser {
|
||||
});
|
||||
}
|
||||
this.unreads();
|
||||
dirrect.unreaddms();
|
||||
}
|
||||
passTemplateID(id: string) {
|
||||
this.createGuild(id);
|
||||
|
||||
@@ -32,7 +32,7 @@ class Message extends SnowFlake {
|
||||
message_id: string;
|
||||
};
|
||||
type!: number;
|
||||
timestamp!: number;
|
||||
private timestamp!: number | string;
|
||||
content!: MarkDown;
|
||||
static del: Promise<void>;
|
||||
static resolve: Function;
|
||||
@@ -53,6 +53,9 @@ class Message extends SnowFlake {
|
||||
member: Member | undefined;
|
||||
reactions!: messagejson["reactions"];
|
||||
pinned!: boolean;
|
||||
getTimeStamp() {
|
||||
return new Date(this.timestamp).getTime();
|
||||
}
|
||||
static setup() {
|
||||
this.del = new Promise((_) => {
|
||||
this.resolve = _;
|
||||
|
||||
Reference in New Issue
Block a user