mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 05:08:54 -07:00
Bugfix dialogs
This commit is contained in:
@@ -6,8 +6,6 @@ import (
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"golang.org/x/sync/semaphore"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/messagedispatcher"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
@@ -27,16 +25,13 @@ type Bridge struct {
|
||||
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
|
||||
dialogSemaphore *semaphore.Weighted
|
||||
}
|
||||
|
||||
func NewBridge(myLogger *logger.Logger) *Bridge {
|
||||
result := &Bridge{
|
||||
myLogger: myLogger,
|
||||
upgrader: websocket.Upgrader{CheckOrigin: func(r *http.Request) bool { return true }},
|
||||
sessions: make(map[string]*session),
|
||||
dialogSemaphore: semaphore.NewWeighted(1),
|
||||
myLogger: myLogger,
|
||||
upgrader: websocket.Upgrader{CheckOrigin: func(r *http.Request) bool { return true }},
|
||||
sessions: make(map[string]*session),
|
||||
}
|
||||
|
||||
myLogger.SetLogLevel(1)
|
||||
@@ -85,7 +80,7 @@ func (b *Bridge) wsBridgeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func (b *Bridge) startSession(conn *websocket.Conn) {
|
||||
|
||||
// Create a new session for this connection
|
||||
s := newSession(conn, b.bindings, b.dispatcher, b.myLogger, b.ctx, b.dialogSemaphore)
|
||||
s := newSession(conn, b.bindings, b.dispatcher, b.myLogger, b.ctx)
|
||||
|
||||
// Setup the close handler
|
||||
conn.SetCloseHandler(func(int, string) error {
|
||||
|
||||
@@ -40,12 +40,6 @@ func (b BridgeClient) SaveDialog(dialogOptions *dialog.SaveDialog, callbackID st
|
||||
|
||||
func (b BridgeClient) MessageDialog(dialogOptions *dialog.MessageDialog, callbackID string) {
|
||||
|
||||
// Check there aren't other dialogs going on
|
||||
if !b.dialogSemaphore.TryAcquire(1) {
|
||||
return
|
||||
}
|
||||
defer b.dialogSemaphore.Release(1)
|
||||
|
||||
osa, err := exec.LookPath("osascript")
|
||||
if err != nil {
|
||||
b.session.log.Info("MessageDialog unavailable (osascript not found)")
|
||||
@@ -157,9 +151,8 @@ func (b BridgeClient) UpdateContextMenu(contextMenuJSON string) {
|
||||
b.session.log.Info("UpdateContextMenu unsupported in Bridge mode")
|
||||
}
|
||||
|
||||
func newBridgeClient(session *session, dialogSemaphore *semaphore.Weighted) *BridgeClient {
|
||||
func newBridgeClient(session *session) *BridgeClient {
|
||||
return &BridgeClient{
|
||||
session: session,
|
||||
dialogSemaphore: dialogSemaphore,
|
||||
session: session,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/messagedispatcher"
|
||||
"golang.org/x/sync/semaphore"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/wailsapp/wails/v2/internal/logger"
|
||||
@@ -38,7 +37,7 @@ type session struct {
|
||||
client *messagedispatcher.DispatchClient
|
||||
}
|
||||
|
||||
func newSession(conn *websocket.Conn, bindings string, dispatcher *messagedispatcher.Dispatcher, logger *logger.Logger, ctx context.Context, dialogSemaphore *semaphore.Weighted) *session {
|
||||
func newSession(conn *websocket.Conn, bindings string, dispatcher *messagedispatcher.Dispatcher, logger *logger.Logger, ctx context.Context) *session {
|
||||
result := &session{
|
||||
conn: conn,
|
||||
bindings: bindings,
|
||||
@@ -48,7 +47,7 @@ func newSession(conn *websocket.Conn, bindings string, dispatcher *messagedispat
|
||||
ctx: ctx,
|
||||
}
|
||||
|
||||
result.client = dispatcher.RegisterClient(newBridgeClient(result, dialogSemaphore))
|
||||
result.client = dispatcher.RegisterClient(newBridgeClient(result))
|
||||
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user