support reconnecting and refreshing note content
This commit is contained in:
parent
34d389cf6e
commit
77f17b9f67
17
Controllers/ApiController.cs
Normal file
17
Controllers/ApiController.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using BinaryDad.Notes.Services;
|
||||||
|
|
||||||
|
namespace BinaryDad.Notes.Controllers
|
||||||
|
{
|
||||||
|
public class ApiController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly INoteService noteService;
|
||||||
|
|
||||||
|
public ApiController(INoteService noteService)
|
||||||
|
{
|
||||||
|
this.noteService = noteService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Note() => noteService.Get();
|
||||||
|
}
|
||||||
|
}
|
@ -53,6 +53,15 @@ $(function () {
|
|||||||
showToast('#update-indicator');
|
showToast('#update-indicator');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// update content after reconnected
|
||||||
|
connection.onreconnected(function() {
|
||||||
|
$.get('api/note', function(content) {
|
||||||
|
$textarea.val(content);
|
||||||
|
showToast('#update-indicator');
|
||||||
|
console.log('Refreshed after disconnect');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// set dark mode
|
// set dark mode
|
||||||
if (window.location.hash == '#dark') {
|
if (window.location.hash == '#dark') {
|
||||||
$('body').addClass('dark');
|
$('body').addClass('dark');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user