Skip to content

Commit

Permalink
main: use window.location.hash for article IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
arpith committed Jan 3, 2022
1 parent b3d2926 commit 6da1e48
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const splitPathname = window.location.pathname.split('/');
const isArticle = splitPathname[splitPathname.length - 1] === 'articles';
const labelArticles = {};
const userLinkDiv = document.getElementById('userLinkContainer');
let hash = splitPathname.pop();
let hash = window.location.hash;
let pathname = splitPathname.join('/');
let current;
let articles;
Expand Down Expand Up @@ -123,7 +123,7 @@ function updateState() {
const articleTitle = articleDiv.childNodes[0].firstChild.innerHTML;
const feedTitle = articleDiv.childNodes[1].firstChild.innerHTML;
document.title = `${articleTitle} - ${feedTitle} (feedreader.co)`;
history.replaceState({ id: current.id }, '', `https://${window.location.hostname}${pathname}${current.id}`);
history.replaceState({ id: current.id }, '', `https://${window.location.hostname}${pathname}#${current.id}`);
if (token) {
console.log(`Marking ${id} as read`);
lib.user.labels.post('read', id).then(() => {
Expand All @@ -137,11 +137,6 @@ function updateState() {

pathname = `${pathname}/`;

if ((hash.length !== 32) && (hash.length !== 40)) {
pathname = `${pathname}${hash}/`;
hash = '';
}

window.onscroll = updateState;

if (!user) {
Expand Down

0 comments on commit 6da1e48

Please sign in to comment.