anki icon indicating copy to clipboard operation
anki copied to clipboard

solved issue: error code removed and error page styled and close butt…

Open medProgAyat opened this issue 2 months ago • 4 comments

Screenshot 1404-07-14 at 18 39 06

I solved issue from post.ts where error code added to error agenda for debugging, instead i used this expression:

throw new Error(process.env.NODE_ENV === "production"?`${msg}`:`${result.status}: ${msg}`); 
// which is much more proper that hard coding like removing 500: using regex 
// which can failed in future commits like by producing another code other than 500 
// or even using dash instead of `:` after error code

that is according to profile that is used to run program, if producion then status code will be removed, that is more accurate i think.

the main error message is changed to 'The selected file is empty. Please choose a valid file.' that is more user friendly as issued in issue tracker

in implementing error message and its box and button i tried to use _base.scss classes to make error page compatible with theme changes.

and in +page.ts i used @josod827 PR experience which was about producing error from t=other than ErrorPage.svelte and change in that file doesnt shown so i used it commits to implement correct behavoir

medProgAyat avatar Oct 06 '25 15:10 medProgAyat

Hi I want to use rpc but i need to have subject cleared. So please explain me wat should i do. I mean i used bridging "pycmd jn last commits and command bridge in new one" to close window and if backend isnt a windowed one like qt or other desktop apps then we should try browser api like history.back. then if i want to add rpc so, wats next? I think you mean i should replace command bridge with rpc and then close window from a function inside python, but wat about history.back? It still needed because if we arent at app there isnt any rpc , we are at website browser and it is best practice to send browser history.back()

medProgAyat avatar Oct 13 '25 14:10 medProgAyat

I think you mean i should replace command bridge with rpc and then close window from a function inside python, but wat about history.back? It still needed because if we arent at app there isnt any rpc , we are at website browser and it is best practice to send browser history.back()

Most communication with the backend is happening via Protobuf methods and the page will not function at all without that, so we don't have to fall back to different behavior here. If we implement a method such as deckOptionsRequireClose, a different implementation can be written for each client. AnkiDroid for example has its own implementation: https://github.com/ankidroid/Anki-Android/blob/32a1b44ee14c7e8915ecd427a9fa70f07f93a2ad/AnkiDroid/src/main/java/com/ichi2/anki/pages/DeckOptions.kt#L316C22-L316C45

If the importing page is integrated in a website eventually (AnkiWeb maybe), the website will have to provide its own implementations of some Protobuf methods (specifically, the ones in frontend.proto).

abdnh avatar Oct 14 '25 05:10 abdnh

Mostly looks good, but please either implement the RPC as suggested, or remove the close button.

I’m still a bit confused — it seems like gRPC is mainly used for communication between Python and Rust, but in this case, we’re trying to communicate from Svelte to Python. Could you please tell me exactly what I should do? You know, this is actually the first time I’ve ever worked with Protobuf, and to make things more complicated, I’ve realized that AQT is also involved here. Where can I look to better understand the source code so I can write it the way you want?

medProgAyat avatar Nov 01 '25 19:11 medProgAyat

@medProgAyat Have you checked deckOptionsRequireClose and deck_options_require_close in the source as I suggested? That should give you a good idea.

abdnh avatar Nov 06 '25 03:11 abdnh