fix(systemviews): satisfy lint checks
- commit
- a8b7d7defd2c87cef9a4279b9aef1feaaf85b3df
- author
- brice · · 2026-04-11 19:23 UTC
- committer
- brice · · 2026-04-12 04:52 UTC
- parent
- a021447
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
6 files · +97 -93
M internal/infrastructure/systemviewsbridge/client_test.go +2 -2
| @@ -236,8 +236,8 @@ func TestClientCurrentAndDefaultDecodeConfigPayload(t *testing.T) { | |||
| 236 | 236 | } | |
| 237 | 237 | ||
| 238 | 238 | var msg port.WebUIMessage | |
| 239 | - | if err := json.Unmarshal(currentClient.native.(*fakeTransport).last, &msg); err != nil { | |
| 240 | - | t.Fatalf("unmarshal sent envelope: %v", err) | |
| 239 | + | if unmarshalErr := json.Unmarshal(currentClient.native.(*fakeTransport).last, &msg); unmarshalErr != nil { | |
| 240 | + | t.Fatalf("unmarshal sent envelope: %v", unmarshalErr) | |
| 241 | 241 | } | |
| 242 | 242 | if msg.Type != "/api/config" { | |
| 243 | 243 | t.Fatalf("sent type = %q, want %q", msg.Type, "/api/config") | |
| @@ -236,8 +236,8 @@ func TestClientCurrentAndDefaultDecodeConfigPayload(t *testing.T) { | |||||
| 236 | } | 236 | } | ||
| 237 | 237 | ||||
| 238 | var msg port.WebUIMessage | 238 | var msg port.WebUIMessage | ||
| 239 | - | if err := json.Unmarshal(currentClient.native.(*fakeTransport).last, &msg); err != nil { | 239 | + | if unmarshalErr := json.Unmarshal(currentClient.native.(*fakeTransport).last, &msg); unmarshalErr != nil { |
| 240 | - | t.Fatalf("unmarshal sent envelope: %v", err) | 240 | + | t.Fatalf("unmarshal sent envelope: %v", unmarshalErr) |
| 241 | } | 241 | } | ||
| 242 | if msg.Type != "/api/config" { | 242 | if msg.Type != "/api/config" { | ||
| 243 | t.Fatalf("sent type = %q, want %q", msg.Type, "/api/config") | 243 | t.Fatalf("sent type = %q, want %q", msg.Type, "/api/config") | ||
M internal/ui/systemviews/app.go +88 -81
| @@ -28,6 +28,8 @@ type App struct { | |||
| 28 | 28 | renderedHTML string | |
| 29 | 29 | } | |
| 30 | 30 | ||
| 31 | + | const historyTimelineLimit = 25 | |
| 32 | + | ||
| 31 | 33 | func NewApp(deps Dependencies) *App { | |
| 32 | 34 | return &App{deps: deps, currentRoute: RouteUnknown} | |
| 33 | 35 | } | |
| @@ -58,93 +60,98 @@ func (a *App) LoadInitial(ctx context.Context) error { | |||
| 58 | 60 | ||
| 59 | 61 | switch a.currentRoute { | |
| 60 | 62 | case RouteHistory: | |
| 61 | - | if a.deps.History == nil { | |
| 62 | - | a.historyEntries = nil | |
| 63 | - | a.favorites = nil | |
| 64 | - | a.folders = nil | |
| 65 | - | a.tags = nil | |
| 66 | - | a.renderedHTML = placeholderHTML(a.currentRoute) | |
| 67 | - | return nil | |
| 68 | - | } | |
| 69 | - | ||
| 70 | - | entries, err := a.deps.History.Timeline(ctx, 25, 0) | |
| 71 | - | if err != nil { | |
| 72 | - | return err | |
| 73 | - | } | |
| 74 | - | a.favorites = nil | |
| 75 | - | a.folders = nil | |
| 76 | - | a.tags = nil | |
| 77 | - | a.historyEntries = entries | |
| 78 | - | a.renderedHTML = historyHTML(entries) | |
| 79 | - | return nil | |
| 63 | + | return a.loadHistoryRoute(ctx) | |
| 80 | 64 | case RouteFavorites: | |
| 81 | - | if a.deps.Favorites == nil { | |
| 82 | - | a.historyEntries = nil | |
| 83 | - | a.favorites = nil | |
| 84 | - | a.folders = nil | |
| 85 | - | a.tags = nil | |
| 86 | - | a.renderedHTML = placeholderHTML(a.currentRoute) | |
| 87 | - | return nil | |
| 88 | - | } | |
| 89 | - | ||
| 90 | - | favorites, err := a.deps.Favorites.List(ctx) | |
| 91 | - | if err != nil { | |
| 92 | - | return err | |
| 93 | - | } | |
| 94 | - | folders, err := a.deps.Favorites.ListFolders(ctx) | |
| 95 | - | if err != nil { | |
| 96 | - | return err | |
| 97 | - | } | |
| 98 | - | tags, err := a.deps.Favorites.ListTags(ctx) | |
| 99 | - | if err != nil { | |
| 100 | - | return err | |
| 101 | - | } | |
| 102 | - | ||
| 103 | - | a.historyEntries = nil | |
| 104 | - | a.favorites = favorites | |
| 105 | - | a.folders = folders | |
| 106 | - | a.tags = tags | |
| 107 | - | a.renderedHTML = favoritesHTML(favorites, folders, tags) | |
| 108 | - | return nil | |
| 65 | + | return a.loadFavoritesRoute(ctx) | |
| 109 | 66 | case RouteConfig: | |
| 110 | - | if a.deps.Config == nil { | |
| 111 | - | a.historyEntries = nil | |
| 112 | - | a.favorites = nil | |
| 113 | - | a.folders = nil | |
| 114 | - | a.tags = nil | |
| 115 | - | a.config = nil | |
| 116 | - | a.keybindings = nil | |
| 117 | - | a.renderedHTML = placeholderHTML(a.currentRoute) | |
| 118 | - | return nil | |
| 119 | - | } | |
| 120 | - | ||
| 121 | - | config, err := a.deps.Config.Current(ctx) | |
| 122 | - | if err != nil { | |
| 123 | - | return err | |
| 124 | - | } | |
| 125 | - | keybindings, err := a.deps.Config.GetKeybindings(ctx) | |
| 126 | - | if err != nil { | |
| 127 | - | return err | |
| 128 | - | } | |
| 129 | - | ||
| 130 | - | a.historyEntries = nil | |
| 131 | - | a.favorites = nil | |
| 132 | - | a.folders = nil | |
| 133 | - | a.tags = nil | |
| 134 | - | a.config = &config | |
| 135 | - | a.keybindings = keybindings | |
| 136 | - | a.renderedHTML = configHTML(config, keybindings) | |
| 137 | - | return nil | |
| 67 | + | return a.loadConfigRoute(ctx) | |
| 138 | 68 | default: | |
| 139 | - | a.historyEntries = nil | |
| 140 | - | a.favorites = nil | |
| 141 | - | a.folders = nil | |
| 142 | - | a.tags = nil | |
| 143 | - | a.config = nil | |
| 144 | - | a.keybindings = nil | |
| 69 | + | a.resetRouteState() | |
| 70 | + | a.renderedHTML = placeholderHTML(a.currentRoute) | |
| 71 | + | return nil | |
| 72 | + | } | |
| 73 | + | } | |
| 74 | + | ||
| 75 | + | func (a *App) loadHistoryRoute(ctx context.Context) error { | |
| 76 | + | if a.deps.History == nil { | |
| 77 | + | a.resetRouteState() | |
| 78 | + | a.renderedHTML = placeholderHTML(a.currentRoute) | |
| 79 | + | return nil | |
| 80 | + | } | |
| 81 | + | ||
| 82 | + | entries, err := a.deps.History.Timeline(ctx, historyTimelineLimit, 0) | |
| 83 | + | if err != nil { | |
| 84 | + | return err | |
| 85 | + | } | |
| 86 | + | a.favorites = nil | |
| 87 | + | a.folders = nil | |
| 88 | + | a.tags = nil | |
| 89 | + | a.historyEntries = entries | |
| 90 | + | a.renderedHTML = historyHTML(entries) | |
| 91 | + | return nil | |
| 92 | + | } | |
| 93 | + | ||
| 94 | + | func (a *App) loadFavoritesRoute(ctx context.Context) error { | |
| 95 | + | if a.deps.Favorites == nil { | |
| 96 | + | a.resetRouteState() | |
| 97 | + | a.renderedHTML = placeholderHTML(a.currentRoute) | |
| 98 | + | return nil | |
| 99 | + | } | |
| 100 | + | ||
| 101 | + | favorites, err := a.deps.Favorites.List(ctx) | |
| 102 | + | if err != nil { | |
| 103 | + | return err | |
| 104 | + | } | |
| 105 | + | folders, err := a.deps.Favorites.ListFolders(ctx) | |
| 106 | + | if err != nil { | |
| 107 | + | return err | |
| 108 | + | } | |
| 109 | + | tags, err := a.deps.Favorites.ListTags(ctx) | |
| 110 | + | if err != nil { | |
| 111 | + | return err | |
| 112 | + | } | |
| 113 | + | ||
| 114 | + | a.historyEntries = nil | |
| 115 | + | a.favorites = favorites | |
| 116 | + | a.folders = folders | |
| 117 | + | a.tags = tags | |
| 118 | + | a.renderedHTML = favoritesHTML(favorites, folders, tags) | |
| 119 | + | return nil | |
| 120 | + | } | |
| 121 | + | ||
| 122 | + | func (a *App) loadConfigRoute(ctx context.Context) error { | |
| 123 | + | if a.deps.Config == nil { | |
| 124 | + | a.resetRouteState() | |
| 145 | 125 | a.renderedHTML = placeholderHTML(a.currentRoute) | |
| 146 | 126 | return nil | |
| 147 | 127 | } | |
| 128 | + | ||
| 129 | + | config, err := a.deps.Config.Current(ctx) | |
| 130 | + | if err != nil { | |
| 131 | + | return err | |
| 132 | + | } | |
| 133 | + | keybindings, err := a.deps.Config.GetKeybindings(ctx) | |
| 134 | + | if err != nil { | |
| 135 | + | return err | |
| 136 | + | } | |
| 137 | + | ||
| 138 | + | a.historyEntries = nil | |
| 139 | + | a.favorites = nil | |
| 140 | + | a.folders = nil | |
| 141 | + | a.tags = nil | |
| 142 | + | a.config = &config | |
| 143 | + | a.keybindings = keybindings | |
| 144 | + | a.renderedHTML = configHTML(config, keybindings) | |
| 145 | + | return nil | |
| 146 | + | } | |
| 147 | + | ||
| 148 | + | func (a *App) resetRouteState() { | |
| 149 | + | a.historyEntries = nil | |
| 150 | + | a.favorites = nil | |
| 151 | + | a.folders = nil | |
| 152 | + | a.tags = nil | |
| 153 | + | a.config = nil | |
| 154 | + | a.keybindings = nil | |
| 148 | 155 | } | |
| 149 | 156 | ||
| 150 | 157 | func (a *App) CurrentRoute() Route { | |
| @@ -28,6 +28,8 @@ type App struct { | |||||
| 28 | renderedHTML string | 28 | renderedHTML string | ||
| 29 | } | 29 | } | ||
| 30 | 30 | ||||
| 31 | + | const historyTimelineLimit = 25 | |||
| 32 | + | ||||
| 31 | func NewApp(deps Dependencies) *App { | 33 | func NewApp(deps Dependencies) *App { | ||
| 32 | return &App{deps: deps, currentRoute: RouteUnknown} | 34 | return &App{deps: deps, currentRoute: RouteUnknown} | ||
| 33 | } | 35 | } | ||
| @@ -58,93 +60,98 @@ func (a *App) LoadInitial(ctx context.Context) error { | |||||
| 58 | 60 | ||||
| 59 | switch a.currentRoute { | 61 | switch a.currentRoute { | ||
| 60 | case RouteHistory: | 62 | case RouteHistory: | ||
| 61 | - | if a.deps.History == nil { | 63 | + | return a.loadHistoryRoute(ctx) |
| 62 | - | a.historyEntries = nil | |||
| 63 | - | a.favorites = nil | |||
| 64 | - | a.folders = nil | |||
| 65 | - | a.tags = nil | |||
| 66 | - | a.renderedHTML = placeholderHTML(a.currentRoute) | |||
| 67 | - | return nil | |||
| 68 | - | } | |||
| 69 | - | ||||
| 70 | - | entries, err := a.deps.History.Timeline(ctx, 25, 0) | |||
| 71 | - | if err != nil { | |||
| 72 | - | return err | |||
| 73 | - | } | |||
| 74 | - | a.favorites = nil | |||
| 75 | - | a.folders = nil | |||
| 76 | - | a.tags = nil | |||
| 77 | - | a.historyEntries = entries | |||
| 78 | - | a.renderedHTML = historyHTML(entries) | |||
| 79 | - | return nil | |||
| 80 | case RouteFavorites: | 64 | case RouteFavorites: | ||
| 81 | - | if a.deps.Favorites == nil { | 65 | + | return a.loadFavoritesRoute(ctx) |
| 82 | - | a.historyEntries = nil | |||
| 83 | - | a.favorites = nil | |||
| 84 | - | a.folders = nil | |||
| 85 | - | a.tags = nil | |||
| 86 | - | a.renderedHTML = placeholderHTML(a.currentRoute) | |||
| 87 | - | return nil | |||
| 88 | - | } | |||
| 89 | - | ||||
| 90 | - | favorites, err := a.deps.Favorites.List(ctx) | |||
| 91 | - | if err != nil { | |||
| 92 | - | return err | |||
| 93 | - | } | |||
| 94 | - | folders, err := a.deps.Favorites.ListFolders(ctx) | |||
| 95 | - | if err != nil { | |||
| 96 | - | return err | |||
| 97 | - | } | |||
| 98 | - | tags, err := a.deps.Favorites.ListTags(ctx) | |||
| 99 | - | if err != nil { | |||
| 100 | - | return err | |||
| 101 | - | } | |||
| 102 | - | ||||
| 103 | - | a.historyEntries = nil | |||
| 104 | - | a.favorites = favorites | |||
| 105 | - | a.folders = folders | |||
| 106 | - | a.tags = tags | |||
| 107 | - | a.renderedHTML = favoritesHTML(favorites, folders, tags) | |||
| 108 | - | return nil | |||
| 109 | case RouteConfig: | 66 | case RouteConfig: | ||
| 110 | - | if a.deps.Config == nil { | 67 | + | return a.loadConfigRoute(ctx) |
| 111 | - | a.historyEntries = nil | |||
| 112 | - | a.favorites = nil | |||
| 113 | - | a.folders = nil | |||
| 114 | - | a.tags = nil | |||
| 115 | - | a.config = nil | |||
| 116 | - | a.keybindings = nil | |||
| 117 | - | a.renderedHTML = placeholderHTML(a.currentRoute) | |||
| 118 | - | return nil | |||
| 119 | - | } | |||
| 120 | - | ||||
| 121 | - | config, err := a.deps.Config.Current(ctx) | |||
| 122 | - | if err != nil { | |||
| 123 | - | return err | |||
| 124 | - | } | |||
| 125 | - | keybindings, err := a.deps.Config.GetKeybindings(ctx) | |||
| 126 | - | if err != nil { | |||
| 127 | - | return err | |||
| 128 | - | } | |||
| 129 | - | ||||
| 130 | - | a.historyEntries = nil | |||
| 131 | - | a.favorites = nil | |||
| 132 | - | a.folders = nil | |||
| 133 | - | a.tags = nil | |||
| 134 | - | a.config = &config | |||
| 135 | - | a.keybindings = keybindings | |||
| 136 | - | a.renderedHTML = configHTML(config, keybindings) | |||
| 137 | - | return nil | |||
| 138 | default: | 68 | default: | ||
| 139 | - | a.historyEntries = nil | 69 | + | a.resetRouteState() |
| 140 | - | a.favorites = nil | 70 | + | a.renderedHTML = placeholderHTML(a.currentRoute) |
| 141 | - | a.folders = nil | 71 | + | return nil |
| 142 | - | a.tags = nil | 72 | + | } |
| 143 | - | a.config = nil | 73 | + | } |
| 144 | - | a.keybindings = nil | 74 | + | |
| 75 | + | func (a *App) loadHistoryRoute(ctx context.Context) error { | |||
| 76 | + | if a.deps.History == nil { | |||
| 77 | + | a.resetRouteState() | |||
| 78 | + | a.renderedHTML = placeholderHTML(a.currentRoute) | |||
| 79 | + | return nil | |||
| 80 | + | } | |||
| 81 | + | ||||
| 82 | + | entries, err := a.deps.History.Timeline(ctx, historyTimelineLimit, 0) | |||
| 83 | + | if err != nil { | |||
| 84 | + | return err | |||
| 85 | + | } | |||
| 86 | + | a.favorites = nil | |||
| 87 | + | a.folders = nil | |||
| 88 | + | a.tags = nil | |||
| 89 | + | a.historyEntries = entries | |||
| 90 | + | a.renderedHTML = historyHTML(entries) | |||
| 91 | + | return nil | |||
| 92 | + | } | |||
| 93 | + | ||||
| 94 | + | func (a *App) loadFavoritesRoute(ctx context.Context) error { | |||
| 95 | + | if a.deps.Favorites == nil { | |||
| 96 | + | a.resetRouteState() | |||
| 97 | + | a.renderedHTML = placeholderHTML(a.currentRoute) | |||
| 98 | + | return nil | |||
| 99 | + | } | |||
| 100 | + | ||||
| 101 | + | favorites, err := a.deps.Favorites.List(ctx) | |||
| 102 | + | if err != nil { | |||
| 103 | + | return err | |||
| 104 | + | } | |||
| 105 | + | folders, err := a.deps.Favorites.ListFolders(ctx) | |||
| 106 | + | if err != nil { | |||
| 107 | + | return err | |||
| 108 | + | } | |||
| 109 | + | tags, err := a.deps.Favorites.ListTags(ctx) | |||
| 110 | + | if err != nil { | |||
| 111 | + | return err | |||
| 112 | + | } | |||
| 113 | + | ||||
| 114 | + | a.historyEntries = nil | |||
| 115 | + | a.favorites = favorites | |||
| 116 | + | a.folders = folders | |||
| 117 | + | a.tags = tags | |||
| 118 | + | a.renderedHTML = favoritesHTML(favorites, folders, tags) | |||
| 119 | + | return nil | |||
| 120 | + | } | |||
| 121 | + | ||||
| 122 | + | func (a *App) loadConfigRoute(ctx context.Context) error { | |||
| 123 | + | if a.deps.Config == nil { | |||
| 124 | + | a.resetRouteState() | |||
| 145 | a.renderedHTML = placeholderHTML(a.currentRoute) | 125 | a.renderedHTML = placeholderHTML(a.currentRoute) | ||
| 146 | return nil | 126 | return nil | ||
| 147 | } | 127 | } | ||
| 128 | + | ||||
| 129 | + | config, err := a.deps.Config.Current(ctx) | |||
| 130 | + | if err != nil { | |||
| 131 | + | return err | |||
| 132 | + | } | |||
| 133 | + | keybindings, err := a.deps.Config.GetKeybindings(ctx) | |||
| 134 | + | if err != nil { | |||
| 135 | + | return err | |||
| 136 | + | } | |||
| 137 | + | ||||
| 138 | + | a.historyEntries = nil | |||
| 139 | + | a.favorites = nil | |||
| 140 | + | a.folders = nil | |||
| 141 | + | a.tags = nil | |||
| 142 | + | a.config = &config | |||
| 143 | + | a.keybindings = keybindings | |||
| 144 | + | a.renderedHTML = configHTML(config, keybindings) | |||
| 145 | + | return nil | |||
| 146 | + | } | |||
| 147 | + | ||||
| 148 | + | func (a *App) resetRouteState() { | |||
| 149 | + | a.historyEntries = nil | |||
| 150 | + | a.favorites = nil | |||
| 151 | + | a.folders = nil | |||
| 152 | + | a.tags = nil | |||
| 153 | + | a.config = nil | |||
| 154 | + | a.keybindings = nil | |||
| 148 | } | 155 | } | ||
| 149 | 156 | ||||
| 150 | func (a *App) CurrentRoute() Route { | 157 | func (a *App) CurrentRoute() Route { | ||
M internal/ui/systemviews/app_test.go +1 -1
| @@ -67,7 +67,7 @@ func TestAppLoadInitialHistoryRouteRendersEntries(t *testing.T) { | |||
| 67 | 67 | ||
| 68 | 68 | require.NoError(t, app.LoadInitial(context.Background())) | |
| 69 | 69 | assert.Equal(t, RouteHistory, app.CurrentRoute()) | |
| 70 | - | assert.Equal(t, 1, len(app.historyEntries)) | |
| 70 | + | assert.Len(t, app.historyEntries, 1) | |
| 71 | 71 | assert.Contains(t, app.renderedHTML, "Example") | |
| 72 | 72 | assert.Contains(t, app.renderedHTML, "https://example.com") | |
| 73 | 73 | assert.True(t, history.called) | |
| @@ -67,7 +67,7 @@ func TestAppLoadInitialHistoryRouteRendersEntries(t *testing.T) { | |||||
| 67 | 67 | ||||
| 68 | require.NoError(t, app.LoadInitial(context.Background())) | 68 | require.NoError(t, app.LoadInitial(context.Background())) | ||
| 69 | assert.Equal(t, RouteHistory, app.CurrentRoute()) | 69 | assert.Equal(t, RouteHistory, app.CurrentRoute()) | ||
| 70 | - | assert.Equal(t, 1, len(app.historyEntries)) | 70 | + | assert.Len(t, app.historyEntries, 1) |
| 71 | assert.Contains(t, app.renderedHTML, "Example") | 71 | assert.Contains(t, app.renderedHTML, "Example") | ||
| 72 | assert.Contains(t, app.renderedHTML, "https://example.com") | 72 | assert.Contains(t, app.renderedHTML, "https://example.com") | ||
| 73 | assert.True(t, history.called) | 73 | assert.True(t, history.called) | ||
M internal/ui/systemviews/config_view.go +2 -2
| @@ -39,7 +39,7 @@ func configHTML(cfg port.SystemviewConfigPayload, keybindings any) string { | |||
| 39 | 39 | ) | |
| 40 | 40 | } | |
| 41 | 41 | ||
| 42 | - | func summarizeKeybindings(keybindings any) (groups int, bindings int, loaded bool) { | |
| 42 | + | func summarizeKeybindings(keybindings any) (groups, bindings int, loaded bool) { | |
| 43 | 43 | switch v := keybindings.(type) { | |
| 44 | 44 | case nil: | |
| 45 | 45 | return 0, 0, false | |
| @@ -57,7 +57,7 @@ func summarizeKeybindings(keybindings any) (groups int, bindings int, loaded boo | |||
| 57 | 57 | } | |
| 58 | 58 | } | |
| 59 | 59 | ||
| 60 | - | func countBridgeKeybindings(data map[string]any) (groups int, bindings int, loaded bool) { | |
| 60 | + | func countBridgeKeybindings(data map[string]any) (groups, bindings int, loaded bool) { | |
| 61 | 61 | groupValue, ok := data["groups"] | |
| 62 | 62 | if !ok { | |
| 63 | 63 | return 1, 0, true | |
| @@ -39,7 +39,7 @@ func configHTML(cfg port.SystemviewConfigPayload, keybindings any) string { | |||||
| 39 | ) | 39 | ) | ||
| 40 | } | 40 | } | ||
| 41 | 41 | ||||
| 42 | - | func summarizeKeybindings(keybindings any) (groups int, bindings int, loaded bool) { | 42 | + | func summarizeKeybindings(keybindings any) (groups, bindings int, loaded bool) { |
| 43 | switch v := keybindings.(type) { | 43 | switch v := keybindings.(type) { | ||
| 44 | case nil: | 44 | case nil: | ||
| 45 | return 0, 0, false | 45 | return 0, 0, false | ||
| @@ -57,7 +57,7 @@ func summarizeKeybindings(keybindings any) (groups int, bindings int, loaded boo | |||||
| 57 | } | 57 | } | ||
| 58 | } | 58 | } | ||
| 59 | 59 | ||||
| 60 | - | func countBridgeKeybindings(data map[string]any) (groups int, bindings int, loaded bool) { | 60 | + | func countBridgeKeybindings(data map[string]any) (groups, bindings int, loaded bool) { |
| 61 | groupValue, ok := data["groups"] | 61 | groupValue, ok := data["groups"] | ||
| 62 | if !ok { | 62 | if !ok { | ||
| 63 | return 1, 0, true | 63 | return 1, 0, true | ||
M internal/ui/systemviews/favorites_view.go +3 -3
| @@ -51,7 +51,7 @@ func favoriteItemsHTML(favorites []*entity.Favorite) string { | |||
| 51 | 51 | if label == "" { | |
| 52 | 52 | label = favorite.URL | |
| 53 | 53 | } | |
| 54 | - | items.WriteString(fmt.Sprintf(`<li><a href="%s">%s</a></li>`, html.EscapeString(favorite.URL), html.EscapeString(label))) | |
| 54 | + | _, _ = fmt.Fprintf(&items, `<li><a href="%s">%s</a></li>`, html.EscapeString(favorite.URL), html.EscapeString(label)) | |
| 55 | 55 | } | |
| 56 | 56 | if items.Len() == 0 { | |
| 57 | 57 | return "<li>No favorites</li>" | |
| @@ -69,7 +69,7 @@ func folderItemsHTML(folders []*entity.Folder) string { | |||
| 69 | 69 | if folder == nil { | |
| 70 | 70 | continue | |
| 71 | 71 | } | |
| 72 | - | items.WriteString(fmt.Sprintf("<li>%s</li>", html.EscapeString(folder.Name))) | |
| 72 | + | _, _ = fmt.Fprintf(&items, "<li>%s</li>", html.EscapeString(folder.Name)) | |
| 73 | 73 | } | |
| 74 | 74 | if items.Len() == 0 { | |
| 75 | 75 | return "<li>No folders</li>" | |
| @@ -87,7 +87,7 @@ func tagItemsHTML(tags []*entity.Tag) string { | |||
| 87 | 87 | if tag == nil { | |
| 88 | 88 | continue | |
| 89 | 89 | } | |
| 90 | - | items.WriteString(fmt.Sprintf("<li>%s</li>", html.EscapeString(tag.Name))) | |
| 90 | + | _, _ = fmt.Fprintf(&items, "<li>%s</li>", html.EscapeString(tag.Name)) | |
| 91 | 91 | } | |
| 92 | 92 | if items.Len() == 0 { | |
| 93 | 93 | return "<li>No tags</li>" | |
| @@ -51,7 +51,7 @@ func favoriteItemsHTML(favorites []*entity.Favorite) string { | |||||
| 51 | if label == "" { | 51 | if label == "" { | ||
| 52 | label = favorite.URL | 52 | label = favorite.URL | ||
| 53 | } | 53 | } | ||
| 54 | - | items.WriteString(fmt.Sprintf(`<li><a href="%s">%s</a></li>`, html.EscapeString(favorite.URL), html.EscapeString(label))) | 54 | + | _, _ = fmt.Fprintf(&items, `<li><a href="%s">%s</a></li>`, html.EscapeString(favorite.URL), html.EscapeString(label)) |
| 55 | } | 55 | } | ||
| 56 | if items.Len() == 0 { | 56 | if items.Len() == 0 { | ||
| 57 | return "<li>No favorites</li>" | 57 | return "<li>No favorites</li>" | ||
| @@ -69,7 +69,7 @@ func folderItemsHTML(folders []*entity.Folder) string { | |||||
| 69 | if folder == nil { | 69 | if folder == nil { | ||
| 70 | continue | 70 | continue | ||
| 71 | } | 71 | } | ||
| 72 | - | items.WriteString(fmt.Sprintf("<li>%s</li>", html.EscapeString(folder.Name))) | 72 | + | _, _ = fmt.Fprintf(&items, "<li>%s</li>", html.EscapeString(folder.Name)) |
| 73 | } | 73 | } | ||
| 74 | if items.Len() == 0 { | 74 | if items.Len() == 0 { | ||
| 75 | return "<li>No folders</li>" | 75 | return "<li>No folders</li>" | ||
| @@ -87,7 +87,7 @@ func tagItemsHTML(tags []*entity.Tag) string { | |||||
| 87 | if tag == nil { | 87 | if tag == nil { | ||
| 88 | continue | 88 | continue | ||
| 89 | } | 89 | } | ||
| 90 | - | items.WriteString(fmt.Sprintf("<li>%s</li>", html.EscapeString(tag.Name))) | 90 | + | _, _ = fmt.Fprintf(&items, "<li>%s</li>", html.EscapeString(tag.Name)) |
| 91 | } | 91 | } | ||
| 92 | if items.Len() == 0 { | 92 | if items.Len() == 0 { | ||
| 93 | return "<li>No tags</li>" | 93 | return "<li>No tags</li>" | ||
M internal/ui/systemviews/history_view.go +1 -4
| @@ -21,10 +21,7 @@ func historyHTML(entries []*entity.HistoryEntry) string { | |||
| 21 | 21 | if label == "" { | |
| 22 | 22 | label = entry.URL | |
| 23 | 23 | } | |
| 24 | - | items.WriteString(fmt.Sprintf(`<li><a href="%s">%s</a></li>`, | |
| 25 | - | html.EscapeString(entry.URL), | |
| 26 | - | html.EscapeString(label), | |
| 27 | - | )) | |
| 24 | + | _, _ = fmt.Fprintf(&items, `<li><a href="%s">%s</a></li>`, html.EscapeString(entry.URL), html.EscapeString(label)) | |
| 28 | 25 | } | |
| 29 | 26 | } | |
| 30 | 27 | ||
| @@ -21,10 +21,7 @@ func historyHTML(entries []*entity.HistoryEntry) string { | |||||
| 21 | if label == "" { | 21 | if label == "" { | ||
| 22 | label = entry.URL | 22 | label = entry.URL | ||
| 23 | } | 23 | } | ||
| 24 | - | items.WriteString(fmt.Sprintf(`<li><a href="%s">%s</a></li>`, | 24 | + | _, _ = fmt.Fprintf(&items, `<li><a href="%s">%s</a></li>`, html.EscapeString(entry.URL), html.EscapeString(label)) |
| 25 | - | html.EscapeString(entry.URL), | |||
| 26 | - | html.EscapeString(label), | |||
| 27 | - | )) | |||
| 28 | } | 25 | } | ||
| 29 | } | 26 | } | ||
| 30 | 27 | ||||