1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-07-04 18:14:45 +02:00

Refactor to make it more like the Android app

This commit is contained in:
Philipp Heckel 2022-02-23 20:30:12 -05:00
parent 415ab57749
commit 3fac1c3432
9 changed files with 196 additions and 111 deletions
web/src/app

View file

@ -1,7 +1,7 @@
import {topicUrlJsonPoll, fetchLinesIterator, topicUrl} from "./utils";
class Api {
static async poll(baseUrl, topic) {
async poll(baseUrl, topic) {
const url = topicUrlJsonPoll(baseUrl, topic);
const messages = [];
console.log(`[Api] Polling ${url}`);
@ -11,7 +11,7 @@ class Api {
return messages.sort((a, b) => { return a.time < b.time ? 1 : -1; }); // Newest first
}
static async publish(baseUrl, topic, message) {
async publish(baseUrl, topic, message) {
const url = topicUrl(baseUrl, topic);
console.log(`[Api] Publishing message to ${url}`);
await fetch(url, {
@ -21,4 +21,5 @@ class Api {
}
}
export default Api;
const api = new Api();
export default api;