Skip to content

Commit

Permalink
feat(notifications): implement persistent notification system with to…
Browse files Browse the repository at this point in the history
…ast notification
  • Loading branch information
bajrangCoder committed Nov 12, 2024
1 parent 0bb5b7f commit 494a8e0
Show file tree
Hide file tree
Showing 37 changed files with 693 additions and 32 deletions.
4 changes: 3 additions & 1 deletion src/lang/ar-ye.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/be-by.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/bn-bd.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/cs-cz.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/de-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Sind sie sicher, das Sie {count} Einträge löschen wollen?",
"deleting items": "Löschen von {count} Einträgen...",
"import project zip": "Projekt(-Zip) importieren",
"changelog": "Änderungsbericht"
"changelog": "Änderungsbericht",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,5 +389,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/es-sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/fr-fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/hi-in.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,5 +389,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/hu-hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Biztosan töröl {count} elemet?",
"deleting items": "{count} elem törlése…",
"import project zip": "Projekt importálása zip-ből",
"changelog": "Változásnapló"
"changelog": "Változásnapló",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/id-id.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,5 +390,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/ir-fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,5 +389,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/it-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/ja-jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/ko-kr.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/ml-in.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/mm-unicode.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/mm-zawgyi.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/pl-pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/pu-in.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/ru-ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,5 +389,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/tl-ph.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/tr-tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/uk-ua.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/uz-uz.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/vi-vn.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,5 +389,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/zh-hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
4 changes: 3 additions & 1 deletion src/lang/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@
"delete entries": "Are you sure you want to delete {count} items?",
"deleting items": "Deleting {count} items...",
"import project zip": "Import Project(zip)",
"changelog": "Change Log"
"changelog": "Change Log",
"notifications": "Notifications",
"no_unread_notifications": "No unread notifications"
}
26 changes: 26 additions & 0 deletions src/lib/acode.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import commands from "lib/commands";
import EditorFile from "lib/editorFile";
import files from "lib/fileList";
import fonts from "lib/fonts";
import NotificationManager from "lib/notificationManager";
import openFolder from "lib/openFolder";
import projects from "lib/projects";
import selectionMenu from "lib/selectionMenu";
Expand Down Expand Up @@ -416,4 +417,29 @@ export default class Acode {
url = await helpers.toInternalUri(url);
return url;
}
/**
* Push a notification
* @param {string} title Title of the notification
* @param {string} message Message body of the notification
* @param {Object} options Notification options
* @param {string} [options.icon] Icon for the notification, can be a URL or a base64 encoded image or icon class or svg string
* @param {boolean} [options.autoClose=true] Whether notification should auto close
* @param {Function} [options.action=null] Action callback when notification is clicked
* @param {('info'|'warning'|'error'|'success')} [options.type='info'] Type of notification
*/
pushNotification(
title,
message,
{ icon, autoClose = true, action = null, type = "info" } = {},
) {
const nm = new NotificationManager();
nm.pushNotification({
title,
message,
icon,
autoClose,
action,
type,
});
}
}
6 changes: 5 additions & 1 deletion src/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { setKeyBindings } from "ace/commands";
import { initModes } from "ace/modelist";
import { keydownState } from "handlers/keyboard";
import { initFileList } from "lib/fileList";
import NotificationManager from "lib/notificationManager";
import { addedFolder } from "lib/openFolder";
import { getEncoding, initEncodings } from "utils/encodings";
import constants from "./constants";
Expand Down Expand Up @@ -369,7 +370,10 @@ async function loadApp() {
});
//#endregion

window.log("info", "Started app and services...");
const notificationManager = new NotificationManager();
notificationManager.init();

window.log("info", "Started app and its services...");

new EditorFile();

Expand Down
Loading

0 comments on commit 494a8e0

Please sign in to comment.