more checks for staying at bottom
This commit is contained in:
parent
12ad9c00b9
commit
71dd54fc0e
4 changed files with 27 additions and 7 deletions
|
@ -53,11 +53,17 @@ class InfiniteScroller {
|
||||||
currrunning = false;
|
currrunning = false;
|
||||||
async addedBottom() {
|
async addedBottom() {
|
||||||
this.updatestuff();
|
this.updatestuff();
|
||||||
const scrollBottom = this.scrollBottom;
|
const func = this.snapBottom();
|
||||||
await this.watchForChange();
|
await this.watchForChange();
|
||||||
|
func();
|
||||||
|
}
|
||||||
|
snapBottom() {
|
||||||
|
const scrollBottom = this.scrollBottom;
|
||||||
|
return () => {
|
||||||
if (scrollBottom < 30) {
|
if (scrollBottom < 30) {
|
||||||
this.scroll.scrollTop = this.scroll.scrollHeight;
|
this.scroll.scrollTop = this.scroll.scrollHeight;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
async watchForTop() {
|
async watchForTop() {
|
||||||
let again = false;
|
let again = false;
|
||||||
|
|
|
@ -103,6 +103,7 @@ class Message {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
giveData(messagejson) {
|
giveData(messagejson) {
|
||||||
|
const func = this.channel.infinite.snapBottom();
|
||||||
for (const thing of Object.keys(messagejson)) {
|
for (const thing of Object.keys(messagejson)) {
|
||||||
if (thing === "attachments") {
|
if (thing === "attachments") {
|
||||||
this.attachments = [];
|
this.attachments = [];
|
||||||
|
@ -154,6 +155,7 @@ class Message {
|
||||||
if (this.div) {
|
if (this.div) {
|
||||||
this.generateMessage();
|
this.generateMessage();
|
||||||
}
|
}
|
||||||
|
func();
|
||||||
}
|
}
|
||||||
canDelete() {
|
canDelete() {
|
||||||
return this.channel.hasPermission("MANAGE_MESSAGES") || this.author.snowflake === this.localuser.user.snowflake;
|
return this.channel.hasPermission("MANAGE_MESSAGES") || this.author.snowflake === this.localuser.user.snowflake;
|
||||||
|
@ -389,6 +391,7 @@ class Message {
|
||||||
const reactdiv = this.reactdiv.deref();
|
const reactdiv = this.reactdiv.deref();
|
||||||
if (!reactdiv)
|
if (!reactdiv)
|
||||||
return;
|
return;
|
||||||
|
const func = this.channel.infinite.snapBottom();
|
||||||
reactdiv.innerHTML = "";
|
reactdiv.innerHTML = "";
|
||||||
for (const thing of this.reactions) {
|
for (const thing of this.reactions) {
|
||||||
console.log(thing, ":3");
|
console.log(thing, ":3");
|
||||||
|
@ -418,6 +421,7 @@ class Message {
|
||||||
this.reactionToggle(thing.emoji.name);
|
this.reactionToggle(thing.emoji.name);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
func();
|
||||||
}
|
}
|
||||||
giveReaction(data, member) {
|
giveReaction(data, member) {
|
||||||
for (const thing of this.reactions) {
|
for (const thing of this.reactions) {
|
||||||
|
|
|
@ -55,12 +55,18 @@ class InfiniteScroller{
|
||||||
currrunning:boolean=false;
|
currrunning:boolean=false;
|
||||||
async addedBottom(){
|
async addedBottom(){
|
||||||
this.updatestuff();
|
this.updatestuff();
|
||||||
const scrollBottom=this.scrollBottom;
|
const func=this.snapBottom();
|
||||||
await this.watchForChange();
|
await this.watchForChange();
|
||||||
|
func();
|
||||||
|
}
|
||||||
|
snapBottom(){
|
||||||
|
const scrollBottom=this.scrollBottom;
|
||||||
|
return ()=>{
|
||||||
if(scrollBottom<30){
|
if(scrollBottom<30){
|
||||||
this.scroll.scrollTop=this.scroll.scrollHeight;
|
this.scroll.scrollTop=this.scroll.scrollHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private async watchForTop():Promise<void>{
|
private async watchForTop():Promise<void>{
|
||||||
let again=false;
|
let again=false;
|
||||||
if(this.scrollTop===0){
|
if(this.scrollTop===0){
|
||||||
|
|
|
@ -110,6 +110,7 @@ class Message{
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
giveData(messagejson:messagejson){
|
giveData(messagejson:messagejson){
|
||||||
|
const func=this.channel.infinite.snapBottom();
|
||||||
for(const thing of Object.keys(messagejson)){
|
for(const thing of Object.keys(messagejson)){
|
||||||
if(thing==="attachments"){
|
if(thing==="attachments"){
|
||||||
this.attachments=[];
|
this.attachments=[];
|
||||||
|
@ -158,6 +159,7 @@ class Message{
|
||||||
if(this.div){
|
if(this.div){
|
||||||
this.generateMessage();
|
this.generateMessage();
|
||||||
}
|
}
|
||||||
|
func();
|
||||||
}
|
}
|
||||||
canDelete(){
|
canDelete(){
|
||||||
return this.channel.hasPermission("MANAGE_MESSAGES")||this.author.snowflake===this.localuser.user.snowflake;
|
return this.channel.hasPermission("MANAGE_MESSAGES")||this.author.snowflake===this.localuser.user.snowflake;
|
||||||
|
@ -394,6 +396,7 @@ class Message{
|
||||||
updateReactions(){
|
updateReactions(){
|
||||||
const reactdiv=this.reactdiv.deref();
|
const reactdiv=this.reactdiv.deref();
|
||||||
if(!reactdiv) return;
|
if(!reactdiv) return;
|
||||||
|
const func=this.channel.infinite.snapBottom();
|
||||||
reactdiv.innerHTML="";
|
reactdiv.innerHTML="";
|
||||||
for(const thing of this.reactions){
|
for(const thing of this.reactions){
|
||||||
console.log(thing,":3")
|
console.log(thing,":3")
|
||||||
|
@ -422,6 +425,7 @@ class Message{
|
||||||
this.reactionToggle(thing.emoji.name);
|
this.reactionToggle(thing.emoji.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func();
|
||||||
}
|
}
|
||||||
giveReaction(data:{name:string},member:Member|{id:string}){
|
giveReaction(data:{name:string},member:Member|{id:string}){
|
||||||
for(const thing of this.reactions){
|
for(const thing of this.reactions){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue