feat: add Jira URL integration and relay functionality
- Implemented OpenBrowserURL function to open Jira links - Updated components to utilize the new Jira URL feature - Added relay server to manage real-time URL updates - Set default Jira URL in settings if not specified
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"daily-timer/internal/models"
|
||||
"daily-timer/internal/relay"
|
||||
"daily-timer/internal/services/updater"
|
||||
"daily-timer/internal/storage"
|
||||
"daily-timer/internal/timer"
|
||||
@@ -25,6 +26,7 @@ type App struct {
|
||||
currentLogs map[uint]*models.ParticipantLog
|
||||
participantURLs map[uint]string
|
||||
jiraBaseURL string
|
||||
relay *relay.Server
|
||||
updater *updater.Updater
|
||||
}
|
||||
|
||||
@@ -32,12 +34,20 @@ func New(store *storage.Storage) *App {
|
||||
return &App{
|
||||
store: store,
|
||||
currentLogs: make(map[uint]*models.ParticipantLog),
|
||||
relay: relay.New(),
|
||||
updater: updater.New(),
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) Startup(ctx context.Context) {
|
||||
a.ctx = ctx
|
||||
a.relay.Start()
|
||||
}
|
||||
|
||||
func (a *App) OpenBrowserURL(url string) {
|
||||
if url != "" {
|
||||
runtime.BrowserOpenURL(a.ctx, url)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) OnDomReady(ctx context.Context) {
|
||||
@@ -205,7 +215,8 @@ func (a *App) StartMeeting(participantOrder []uint, attendance map[uint]bool) er
|
||||
}
|
||||
|
||||
if jiraURL != "" {
|
||||
runtime.EventsEmit(a.ctx, "jira:open", jiraURL)
|
||||
a.relay.Broadcast(jiraURL)
|
||||
go runtime.BrowserOpenURL(a.ctx, fmt.Sprintf("http://127.0.0.1:%d/", relay.Port))
|
||||
}
|
||||
|
||||
a.timer = timer.New(meeting.TimeLimit, warningThreshold)
|
||||
@@ -214,6 +225,10 @@ func (a *App) StartMeeting(participantOrder []uint, attendance map[uint]bool) er
|
||||
go a.handleTimerEvents()
|
||||
a.timer.Start()
|
||||
|
||||
if jiraURL != "" {
|
||||
go runtime.BrowserOpenURL(a.ctx, jiraURL)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -233,8 +248,10 @@ func (a *App) handleTimerEvents() {
|
||||
case timer.EventSpeakerChanged:
|
||||
a.saveSpeakerLog(event.State)
|
||||
if url, ok := a.participantURLs[event.State.CurrentSpeakerID]; ok && url != "" {
|
||||
a.relay.Broadcast(url)
|
||||
runtime.EventsEmit(a.ctx, "jira:open", url)
|
||||
} else if a.jiraBaseURL != "" {
|
||||
a.relay.Broadcast(a.jiraBaseURL)
|
||||
runtime.EventsEmit(a.ctx, "jira:open", a.jiraBaseURL)
|
||||
}
|
||||
runtime.EventsEmit(a.ctx, "timer:speaker_changed", event.State)
|
||||
|
||||
Reference in New Issue
Block a user