Skip to content

Commit

Permalink
misc: remove logs, check for length
Browse files Browse the repository at this point in the history
  • Loading branch information
not-nullptr committed Jul 15, 2024
1 parent e2868a8 commit bade5e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
3 changes: 0 additions & 3 deletions layouts/home/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ async function updateTimeline(mode = 'rewrite') {
if(vars.linkColorsInTL) {
let tlUsers = tl.map(t => t.user.id_str).filter(u => !linkColors[u]);
let linkData = await getLinkColors(tlUsers);
console.log(linkData)
if(linkData) for(let i in linkData) {
linkColors[linkData[i].id] = linkData[i].color;
}
Expand Down Expand Up @@ -297,7 +296,6 @@ async function renderTimeline(options = {}) {
if(vars.linkColorsInTL) {
let tlUsers = data.map(t => t.user.id_str).filter(u => !linkColors[u]);
let linkData = await getLinkColors(tlUsers);
console.log(linkData)
if(linkData) for(let i in linkData) {
linkColors[linkData[i].id] = linkData[i].color;
}
Expand Down Expand Up @@ -398,7 +396,6 @@ setTimeout(async () => {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight - 5000 && window.scrollY > 20) {
if (loadingNewTweets || timeline.data.length === 0) return;
document.getElementById('load-more').click();
console.log("Loading more tweets...");
}
}, { passive: true });

Expand Down
14 changes: 6 additions & 8 deletions scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1089,21 +1089,20 @@ const getLinkColors = async ids => {
new Promise(async (resolve, reject) => {
// firstly, get "legacyLinkColors" from storage
chrome.storage.local.get(["legacyLinkColors"], async data => {
console.log(data);
let legacyLinkColors = data.legacyLinkColors || {};
// each id will either have a hex colour or -1 if the user doesn't have a custom link colour
let hasColourIds = ids.filter(id => legacyLinkColors[id] && legacyLinkColors[id] !== -1);
let noColourIds = ids.filter(id => legacyLinkColors[id] && legacyLinkColors[id] === -1);
let fetched = [];
let toFetch = ids.filter(id => !hasColourIds.includes(id) && !noColourIds.includes(id));
console.log("Fetching uncached user colours:", toFetch);
let users = [];
try {
users = await API.user.lookup(toFetch);
} catch {
console.warn("User colours didn't fetch (were there any?)")
if (toFetch.length > 0) {
try {
users = await API.user.lookup(toFetch);
} catch {
console.warn("Legacy user colours failed to fetch!")
}
}
console.log(150, users);
for(let user of users) {
if(user.profile_link_color && user.profile_link_color !== "1DA1F2") {
fetched.push({id: user.id_str, color: user.profile_link_color});
Expand All @@ -1117,7 +1116,6 @@ const getLinkColors = async ids => {
fetched.push({id, color: legacyLinkColors[id]});
}
chrome.storage.local.set({legacyLinkColors}, () => {});
console.log("Fetched user colours:", fetched);
resolve(fetched);
});
})
Expand Down

0 comments on commit bade5e9

Please sign in to comment.