Skip to content

Commit

Permalink
Only sync messages from the last 24h
Browse files Browse the repository at this point in the history
  • Loading branch information
f-r00t committed Feb 28, 2024
1 parent a5f9a8c commit 2da57d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ class globals {

this.notificationQueue = [];

this.lastMessageTimestamp = 0;
this.lastMessageTimestamp = Date.now() - (24 * 60 * 60 * 1000);

this.lastDMTimestamp = 0;
this.lastDMTimestamp = Date.now() - (24 * 60 * 60 * 1000);

}

Expand Down
6 changes: 3 additions & 3 deletions src/HuginUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ export async function cacheSync(latest_board_message_timestamp=0, first=true, pa
if (Globals.lastMessageTimestamp > latest_board_message_timestamp) latest_board_message_timestamp = Globals.lastMessageTimestamp;

let cacheURL = Globals.preferences.cache ? Globals.preferences.cache : Config.defaultCache;

console.log(`${cacheURL}/api/v1/posts-encrypted-group?from=${parseInt(latest_board_message_timestamp/1000)}&to=${parseInt(Date.now()/1000)}&size=50&page=` + page);
fetch(`${cacheURL}/api/v1/posts-encrypted-group?from=${parseInt(latest_board_message_timestamp/1000)}&to=${parseInt(Date.now()/1000)}&size=50&page=` + page)
.then((response) => response.json())
.then(async (json) => {
Expand All @@ -491,7 +491,7 @@ export async function cacheSync(latest_board_message_timestamp=0, first=true, pa
if (json.current_page < json.total_pages) {
cacheSync(latest_board_message_timestamp, false, page+1);
} else {
Globals.lastMessageTimestamp = items.slice(-1)[0].created_at + 1;
Globals.lastMessageTimestamp = (parseInt(items.slice(-1)[0].created_at) + 1) * 1000;
}
})

Expand Down Expand Up @@ -532,7 +532,7 @@ export async function cacheSyncDMs(latest_board_message_timestamp=0, first=true,
if (json.current_page < json.total_pages) {
cacheSyncDMs(latest_board_message_timestamp, false, page+1);
} else {
Globals.lastDMTimestamp = items.slice(-1)[0].created_at + 1;
Globals.lastDMTimestamp = (parseInt(items.slice(-1)[0].created_at) + 1) * 1000;
}
})

Expand Down

0 comments on commit 2da57d3

Please sign in to comment.