diff libervia/web/pages/_browser/dialog.py @ 1600:0a4433a343a3

browser (calls): implement WebRTC file sharing: - Send file through WebRTC when the new `file` button is used during a call. - Show a confirmation dialog and download file sent by WebRTC. rel 442
author Goffi <goffi@goffi.org>
date Sat, 06 Apr 2024 13:06:17 +0200
parents 7228fc3c4744
children
line wrap: on
line diff
--- a/libervia/web/pages/_browser/dialog.py	Tue Mar 05 16:40:25 2024 +0100
+++ b/libervia/web/pages/_browser/dialog.py	Sat Apr 06 13:06:17 2024 +0200
@@ -9,6 +9,11 @@
 class CancelError(Exception):
     """Dialog is cancelled"""
 
+    def __init__(self, reason: str = "", text: str = "") -> None:
+        self.reason = reason
+        self.text = text
+        super().__init__(text)
+
 
 class Confirm:
 
@@ -34,7 +39,7 @@
     def _default_cancel_cb(self, evt, notif_elt):
         notif_elt.remove()
 
-    def cancel(self):
+    def cancel(self, reason: str = "", text: str = ""):
         """Cancel the dialog, without calling any callback
 
         will raise a CancelError
@@ -45,7 +50,7 @@
             self._notif_elt.remove()
             self._notif_elt = None
             if self._reject_cb is not None:
-                self._reject_cb(CancelError)
+                self._reject_cb(CancelError(reason, text))
             else:
                 log.warning("no reject callback set")
         self.reset()