mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-04 03:48:07 +02:00
add some shameless self promotion
This commit is contained in:
parent
98666186ee
commit
de5bcb8b9c
@ -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
|
||||
`)
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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) promptAnonymousReporting() error {
|
||||
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 gui.createConfirmationPanel(gui.g, nil, true, gui.Tr.SLocalize("ShamelessSelfPromotionTitle"), gui.Tr.SLocalize("ShamelessSelfPromotionMessage"), onConfirm, onConfirm)
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -438,6 +438,19 @@ func addEnglish(i18nObject *i18n.Bundle) error {
|
||||
}, &i18n.Message{
|
||||
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.`,
|
||||
|
Loading…
Reference in New Issue
Block a user