mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-05-31 23:59:27 +03:00
Add channel and message counting to tracker, and display them in the controller UI
This commit is contained in:
parent
6d612016ad
commit
b9d50ddb01
@ -14,6 +14,22 @@ var GUI = (function(){
|
||||
controller.ui.btnUpload.disabled = controller.ui.btnSettings.disabled = STATE.isTracking();
|
||||
controller.ui.btnToggleTracking.innerHTML = STATE.isTracking() ? "Pause Tracking" : "Start Tracking";
|
||||
}
|
||||
|
||||
if (type === "data" || force){
|
||||
var messageCount = 0;
|
||||
var channelCount = 0;
|
||||
|
||||
if (STATE.hasSavedData()){
|
||||
messageCount = STATE.getSavefile().countMessages();
|
||||
channelCount = STATE.getSavefile().countChannels();
|
||||
}
|
||||
|
||||
controller.ui.textStatus.innerHTML = [
|
||||
messageCount, " message", (messageCount === 1 ? "" : "s"),
|
||||
" from ",
|
||||
channelCount, " channel", (channelCount === 1 ? "" : "s")
|
||||
].join("");
|
||||
}
|
||||
}
|
||||
|
||||
if (settings){
|
||||
|
@ -87,6 +87,8 @@ var SAVEFILE = function(parsedObj){
|
||||
|
||||
this.tmp = {};
|
||||
this.tmp.userlookup = {};
|
||||
this.tmp.channelkeys = new Set();
|
||||
this.tmp.messagekeys = new Set();
|
||||
};
|
||||
|
||||
SAVEFILE.isValid = function(parsedObj){
|
||||
@ -139,6 +141,7 @@ SAVEFILE.prototype.tryRegisterChannel = function(serverIndex, channelId, channel
|
||||
name: channelName
|
||||
};
|
||||
|
||||
this.tmp.channelkeys.add(channelId);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@ -148,6 +151,7 @@ SAVEFILE.prototype.addMessage = function(channelId, messageId, messageObject){
|
||||
var wasPresent = messageId in container;
|
||||
|
||||
container[messageId] = messageObject;
|
||||
this.tmp.messagekeys.add(messageId);
|
||||
return !wasPresent;
|
||||
};
|
||||
|
||||
@ -202,6 +206,14 @@ SAVEFILE.prototype.addMessagesFromDiscord = function(channelId, discordMessageAr
|
||||
return hasNewMessages;
|
||||
};
|
||||
|
||||
SAVEFILE.prototype.countChannels = function(){
|
||||
return this.tmp.channelkeys.size;
|
||||
};
|
||||
|
||||
SAVEFILE.prototype.countMessages = function(){
|
||||
return this.tmp.messagekeys.size;
|
||||
};
|
||||
|
||||
SAVEFILE.prototype.combineWith = function(obj){
|
||||
for(var userId in obj.meta.users){
|
||||
this.findOrRegisterUser(userId, obj.meta.users[userId].name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user