Skip to content

Commit

Permalink
Merge pull request #619 from whakama/master
Browse files Browse the repository at this point in the history
small fixes of bugs that slightly annoyed me
  • Loading branch information
dimdenGD authored Nov 27, 2023
2 parents 1e1ce15 + 9ce3ace commit dc4c581
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion layouts/bookmarks/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ body {
}
#user-avatar {
margin-left: 7px;
border: 4px solid white;
border: 4px solid var(--background-color);
margin-top: -32px;
border-radius: 7px;
}
Expand Down
2 changes: 1 addition & 1 deletion layouts/header/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,7 @@ let userDataFunction = async user => {
}

if(updates.user_events && updates.user_events.entries) { //new messages in inbox
let conversationIds = updates.user_events.entries.map(m => m.message.conversation_id);
let conversationIds = updates.user_events.entries.map(m => m.message && m.message.conversation_id);
await updateInboxData(conversationIds);
}
}, 5000);
Expand Down
2 changes: 1 addition & 1 deletion scripts/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ const API = {

let entries = data.timeline.instructions.find(i => i.addEntries).addEntries.entries;
let cursorTop = entries.find(e => e.entryId.startsWith('cursor-top-')).content.operation.cursor.value;
let cursorBottom = entries.find(e => e.entryId.startsWith('cursor-bottom-')).content.operation.cursor.value;
let cursorBottom = entries.find(e => e.entryId.startsWith('cursor-bottom-'))?.content.operation.cursor.value;
let unreadBefore = +data.timeline.instructions.find(i => i.markEntriesUnreadGreaterThanSortIndex).markEntriesUnreadGreaterThanSortIndex.sortIndex;
let unreadNotifications = 0;
let res = [];
Expand Down
17 changes: 11 additions & 6 deletions scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3735,18 +3735,23 @@ function renderNotification(n, options = {}) {
setTimeout(async () => {
document.getElementsByClassName('navbar-new-tweet-text')[0].value = LOC.anniversary_tweet.message;

var userJoinYear = new Date(user.created_at).getFullYear();
var currentYear = new Date().getFullYear();
var yearsSinceJoin = currentYear - userJoinYear;
var anniversaryPicUrl = `https://ton.twimg.com/ntab_public/twitterversary/year${yearsSinceJoin}.jpg`;
var anniversaryPicBlob = await (await fetch(anniversaryPicUrl)).blob();
var anniversaryPicFile = new File([anniversaryPicBlob], `year${yearsSinceJoin}.jpg`, { type: 'image/jpeg' });
let userJoinYear = new Date(user.created_at).getFullYear();
let currentYear = new Date().getFullYear();
let yearsSinceJoin = currentYear - userJoinYear;
let anniversaryPicUrl = `https://ton.twimg.com/ntab_public/twitterversary/year${yearsSinceJoin}.jpg`;
let anniversaryPicBlob = await (await fetch(anniversaryPicUrl)).blob();
let anniversaryPicFile = new File([anniversaryPicBlob], `year${yearsSinceJoin}.jpg`, { type: 'image/jpeg' });

mediaToUpload = [];
handleFiles([anniversaryPicFile], mediaToUpload, document.getElementsByClassName('navbar-new-tweet-media-c')[0]);
}, 10);
} else if(n.tweet && n.tweet.user) {
new TweetViewer(user, n.tweet.retweeted_status ? n.tweet.retweeted_status : n.tweet);
} else if(n.entry.content.notification.url) { //this should always be last because most (if not all) notifications have a url for good measure
let url = new URL(n.entry.content.notification.url.url);
url.searchParams.append('newtwitter', true);

openInNewTab(url.href)
}
}
});
Expand Down

0 comments on commit dc4c581

Please sign in to comment.