summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-11-10 22:07:45 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-11-10 22:32:13 +1100
commitde5bcb8b9c65e63a992ce278e63f0f8e31a57969 (patch)
tree7df962782d7345e3b002d4578fa152e5507d2ad1
parent98666186ee3365cd9b65df7a9a7ed4f430b77d50 (diff)
add some shameless self promotion
-rw-r--r--pkg/config/app_config.go5
-rw-r--r--pkg/gui/confirmation_panel.go2
-rw-r--r--pkg/gui/gui.go55
-rw-r--r--pkg/i18n/english.go13
4 files changed, 61 insertions, 14 deletions
diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go
index 50690c8c5..d0294de01 100644
--- a/pkg/config/app_config.go
+++ b/pkg/config/app_config.go
@@ -37,7 +37,7 @@ type AppConfigurer interface {
GetUserConfig() *viper.Viper
GetUserConfigDir() string
GetAppState() *AppState
- WriteToUserConfig(string, string) error
+ WriteToUserConfig(string, interface{}) error
SaveAppState() error
LoadAppState() error
SetIsNewRepo(bool)
@@ -192,7 +192,7 @@ func LoadAndMergeFile(v *viper.Viper, filename string) (string, error) {
}
// WriteToUserConfig adds a key/value pair to the user's config and saves it
-func (c *AppConfig) WriteToUserConfig(key, value string) error {
+func (c *AppConfig) WriteToUserConfig(key string, value interface{}) error {
// reloading the user config directly (without defaults) so that we're not
// writing any defaults back to the user's config
v, _, err := LoadConfig("config", false)
@@ -263,6 +263,7 @@ update:
method: prompt # can be: prompt | background | never
days: 14 # how often a update is checked for
reporting: 'undetermined' # one of: 'on' | 'off' | 'undetermined'
+splashUpdatesIndex: 0
confirmOnQuit: false
`)
}
diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go
index d0516f2e8..6913400a1 100644
--- a/pkg/gui/confirmation_panel.go
+++ b/pkg/gui/confirmation_panel.go
@@ -56,7 +56,7 @@ func (gui *Gui) getMessageHeight(wrap bool, message string, width int) int {
func (gui *Gui) getConfirmationPanelDimensions(g *gocui.Gui, wrap bool, prompt string) (int, int, int, int) {
width, height := g.Size()
- panelWidth := width / 2
+ panelWidth := 4 * width / 7
panelHeight := gui.getMessageHeight(wrap, prompt, panelWidth)
return width/2 - panelWidth/2,
height/2 - panelHeight/2 - panelHeight%2 - 1,
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index b75d73e87..b65f01747 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -30,6 +30,8 @@ import (
"github.com/sirupsen/logrus"
)
+const StartupPopupVersion = 1
+
// OverlappingEdges determines if panel edges overlap
var OverlappingEdges = false
@@ -618,20 +620,42 @@ func (gui *Gui) loadNewRepo() error {
return err
}
- if gui.Config.GetUserConfig().GetString("reporting") == "undetermined" {
- if err := gui.promptAnonymousReporting(); err != nil {
- return err
+ return nil
+}
+
+func (gui *Gui) showInitialPopups(tasks []func(chan struct{}) error) {
+ gui.waitForIntro.Add(len(tasks))
+ done := make(chan struct{})
+
+ go func() {
+ for _, task := range tasks {
+ go func() {
+ if err := task(done); err != nil {
+ _ = gui.createErrorPanel(gui.g, err.Error())
+ }
+ }()
+
+ <-done
+ gui.waitForIntro.Done()
}
+ }()
+}
+
+func (gui *Gui) showShamelessSelfPromotionMessage(done chan struct{}) error {
+ onConfirm := func(g *gocui.Gui, v *gocui.View) error {
+ done <- struct{}{}
+ return gui.Config.WriteToUserConfig("startupPopupVersion", StartupPopupVersion)
}
- return nil
+
+ return gui.createConfirmationPanel(gui.g, nil, true, gui.Tr.SLocalize("ShamelessSelfPromotionTitle"), gui.Tr.SLocalize("ShamelessSelfPromotionMessage"), onConfirm, onConfirm)
}
-func (gui *Gui) promptAnonymousReporting() error {
+func (gui *Gui) promptAnonymousReporting(done chan struct{}) error {
return gui.createConfirmationPanel(gui.g, nil, true, gui.Tr.SLocalize("AnonymousReportingTitle"), gui.Tr.SLocalize("AnonymousReportingPrompt"), func(g *gocui.Gui, v *gocui.View) error {
- gui.waitForIntro.Done()
+ done <- struct{}{}
return gui.Config.WriteToUserConfig("reporting", "on")
}, func(g *gocui.Gui, v *gocui.View) error {
- gui.waitForIntro.Done()
+ done <- struct{}{}
return gui.Config.WriteToUserConfig("reporting", "off")
})
}
@@ -717,15 +741,22 @@ func (gui *Gui) Run() error {
return err
}
+ popupTasks := []func(chan struct{}) error{}
if gui.Config.GetUserConfig().GetString("reporting") == "undetermined" {
- gui.waitForIntro.Add(2)
- } else {
- gui.waitForIntro.Add(1)
+ popupTasks = append(popupTasks, gui.promptAnonymousReporting)
+ }
+ configPopupVersion := gui.Config.GetUserConfig().GetInt("StartupPopupVersion")
+ // -1 means we've disabled these popups
+ if configPopupVersion != -1 && configPopupVersion < StartupPopupVersion {
+ popupTasks = append(popupTasks, gui.showShamelessSelfPromotionMessage)
}
+ gui.showInitialPopups(popupTasks)
+ gui.waitForIntro.Add(1)
if gui.Config.GetUserConfig().GetBool("git.autoFetch") {
go gui.startBackgroundFetch()
}
+
gui.goEvery(time.Second*10, gui.refreshFiles)
gui.goEvery(time.Millisecond*50, gui.renderAppStatus)
@@ -735,6 +766,8 @@ func (gui *Gui) Run() error {
return err
}
+ gui.Log.Warn("starting main loop")
+
err = g.MainLoop()
return err
}
@@ -806,7 +839,7 @@ func (gui *Gui) handleDonate(g *gocui.Gui, v *gocui.View) error {
if cx > len(gui.Tr.SLocalize("Donate")) {
return nil
}
- return gui.OSCommand.OpenLink("https://donorbox.org/lazygit")
+ return gui.OSCommand.OpenLink("https://github.com/sponsors/jesseduffield")
}
// setColorScheme sets the color scheme for the app based on the user config
diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go
index 3d19c0e8a..96880cc7d 100644
--- a/pkg/i18n/english.go
+++ b/pkg/i18n/english.go
@@ -439,6 +439,19 @@ func addEnglish(i18nObject *i18n.Bundle) error {
ID: "AnonymousReportingPrompt",
Other: "Would you like to enable anonymous reporting data to help improve lazygit? (enter/esc)",
}, &i18n.Message{
+ ID: "ShamelessSelfPromotionTitle",
+ Other: "Shameless Self Promotion",
+ }, &i18n.Message{
+ ID: "ShamelessSelfPromotionMessage",
+ Other: `Thanks for using lazygit! Three things to share with you:
+
+1) lazygit now has basic mouse support!
+
+2) If you want to learn about lazygit's features, watch this vid:
+ https://youtu.be/CPLdltN7wgE
+
+3) Github are now matching any donations dollar-for-dollar for the next 12 months, so if you've been tossing up over whether to click the donate link in the bottom right corner, now is the time!`,
+ }, &i18n.Message{
ID: "GitconfigParseErr",
Other: `Gogit failed to parse your gitconfig file due to the presence of unquoted '\' characters. Removing these should fix the issue.`,
}, &i18n.Message{