Compare commits

...

2 Commits

Author SHA1 Message Date
Philipp Heckel
b9b53bcdf0 Fix Chrome/Firefox inconsistencies with sorting 2021-11-08 10:35:46 -05:00
Philipp Heckel
a1385f6785 Update readme 2021-11-08 09:48:55 -05:00
3 changed files with 22 additions and 25 deletions

View File

@@ -129,13 +129,13 @@ sudo apt install ntfy
**Debian/Ubuntu** (*manual install*)**:** **Debian/Ubuntu** (*manual install*)**:**
```bash ```bash
sudo apt install tmux sudo apt install tmux
wget https://github.com/binwiederhier/ntfy/releases/download/v1.2.4/ntfy_1.2.4_amd64.deb wget https://github.com/binwiederhier/ntfy/releases/download/v1.3.0/ntfy_1.3.0_amd64.deb
dpkg -i ntfy_1.2.4_amd64.deb dpkg -i ntfy_1.3.0_amd64.deb
``` ```
**Fedora/RHEL/CentOS:** **Fedora/RHEL/CentOS:**
```bash ```bash
rpm -ivh https://github.com/binwiederhier/ntfy/releases/download/v1.2.4/ntfy_1.2.4_amd64.rpm rpm -ivh https://github.com/binwiederhier/ntfy/releases/download/v1.3.0/ntfy_1.3.0_amd64.rpm
``` ```
**Docker:** **Docker:**
@@ -150,8 +150,8 @@ go get -u heckel.io/ntfy
**Manual install** (*any x86_64-based Linux*)**:** **Manual install** (*any x86_64-based Linux*)**:**
```bash ```bash
wget https://github.com/binwiederhier/ntfy/releases/download/v1.2.4/ntfy_1.2.4_linux_x86_64.tar.gz wget https://github.com/binwiederhier/ntfy/releases/download/v1.3.0/ntfy_1.3.0_linux_x86_64.tar.gz
sudo tar -C /usr/bin -zxf ntfy_1.2.4_linux_x86_64.tar.gz ntfy sudo tar -C /usr/bin -zxf ntfy_1.3.0_linux_x86_64.tar.gz ntfy
./ntfy ./ntfy
``` ```

View File

@@ -278,8 +278,9 @@ li {
#detail #detailMain { #detail #detailMain {
max-width: 900px; max-width: 900px;
margin: 0 auto 50px auto; margin: 0 auto;
position: relative; /* required for close button's "position: absolute" */ position: relative; /* required for close button's "position: absolute" */
padding-bottom: 50px; /* Chrome and Firefox behave differently regarding bottom margin */
} }
#detail #detailCloseButton { #detail #detailCloseButton {

View File

@@ -73,7 +73,7 @@ const subscribeInternal = (topic, persist, delaySec) => {
eventSource.onmessage = (e) => { eventSource.onmessage = (e) => {
const event = JSON.parse(e.data); const event = JSON.parse(e.data);
topics[topic]['messages'].push(event); topics[topic]['messages'].push(event);
topics[topic]['messages'].sort((a, b) => { return a.time < b.time; }) // Newest first topics[topic]['messages'].sort((a, b) => { return a.time < b.time ? 1 : -1; }); // Newest first
if (currentTopic === topic) { if (currentTopic === topic) {
rerenderDetailView(); rerenderDetailView();
} }
@@ -123,7 +123,7 @@ const fetchCachedMessages = async (topic) => {
const message = JSON.parse(line); const message = JSON.parse(line);
topics[topic]['messages'].push(message); topics[topic]['messages'].push(message);
} }
topics[topic]['messages'].sort((a, b) => { return a.time < b.time; }) // Newest first topics[topic]['messages'].sort((a, b) => { return a.time < b.time ? 1 : -1; }); // Newest first
}; };
const showDetail = (topic) => { const showDetail = (topic) => {
@@ -258,27 +258,23 @@ if (!window["Notification"] || !window["EventSource"]) {
// Reset UI // Reset UI
topicField.value = ""; topicField.value = "";
// Restore topics
const storedTopics = JSON.parse(localStorage.getItem('topics') || "[]");
if (storedTopics) {
storedTopics.forEach((topic) => { subscribeInternal(topic, true, 0); });
if (storedTopics.length === 0) {
topicsHeader.style.display = 'none';
}
} else {
topicsHeader.style.display = 'none';
}
// (Temporarily) subscribe topic if we navigated to /sometopic URL // (Temporarily) subscribe topic if we navigated to /sometopic URL
const match = location.pathname.match(/^\/([-_a-zA-Z0-9]{1,64})$/) // Regex must match Go & Android app! const match = location.pathname.match(/^\/([-_a-zA-Z0-9]{1,64})$/) // Regex must match Go & Android app!
if (match) { if (match) {
currentTopic = match[1]; currentTopic = match[1];
subscribeInternal(currentTopic, false,0); if (!storedTopics.includes(currentTopic)) {
} subscribeInternal(currentTopic, false,0);
// Restore topics
const storedTopics = localStorage.getItem('topics');
if (storedTopics) {
const storedTopicsArray = JSON.parse(storedTopics);
storedTopicsArray.forEach((topic) => { subscribeInternal(topic, true, 0); });
if (storedTopicsArray.length === 0) {
topicsHeader.style.display = 'none';
}
if (currentTopic) {
currentTopicUnsubscribeOnClose = !storedTopicsArray.includes(currentTopic);
}
} else {
topicsHeader.style.display = 'none';
if (currentTopic) {
currentTopicUnsubscribeOnClose = true; currentTopicUnsubscribeOnClose = true;
} }
} }