Revert "GODT-1932: frontend is instantiated before bridge."

This reverts commit db2379e2fd.
This commit is contained in:
James Houlahan
2022-10-12 22:21:33 +02:00
parent cc9ad17ea5
commit 3b0bc1ca15
7 changed files with 67 additions and 145 deletions

View File

@ -19,6 +19,7 @@
package frontend
import (
"github.com/ProtonMail/proton-bridge/v2/internal/bridge"
"github.com/ProtonMail/proton-bridge/v2/internal/frontend/cli"
"github.com/ProtonMail/proton-bridge/v2/internal/frontend/grpc"
"github.com/ProtonMail/proton-bridge/v2/internal/frontend/types"
@ -27,17 +28,8 @@ import (
"github.com/ProtonMail/proton-bridge/v2/pkg/listener"
)
// Type describes the available types of frontend.
type Type int
const (
CLI Type = iota
GRPC
NonInteractive
)
type Frontend interface {
Loop(b types.Bridger) error
Loop() error
NotifyManualUpdate(update updater.VersionInfo, canInstall bool)
SetVersion(update updater.VersionInfo)
NotifySilentUpdateInstalled()
@ -45,38 +37,38 @@ type Frontend interface {
WaitUntilFrontendIsReady()
}
// New returns initialized frontend based on `frontendType`, which can be `CLI` or `GRPC`.
// New returns initialized frontend based on `frontendType`, which can be `cli` or `grpc`.
func New(
frontendType Type,
frontendType string,
showWindowOnStart bool,
panicHandler types.PanicHandler,
eventListener listener.Listener,
updater types.Updater,
bridge *bridge.Bridge,
restarter types.Restarter,
locations *locations.Locations,
) Frontend {
switch frontendType {
case GRPC:
case "grpc":
return grpc.NewService(
showWindowOnStart,
panicHandler,
eventListener,
updater,
bridge,
restarter,
locations,
)
case CLI:
case "cli":
return cli.New(
panicHandler,
eventListener,
updater,
bridge,
restarter,
)
case NonInteractive:
fallthrough
default:
return nil
}