Monorepo for Tangled tangled.org

appview/{pages,state}: simplify LoginPage params #1023

open opened by boltless.me targeting master from sl/uvpzuszrulvq

We don't need to pass full MultiAccountUser here. just []AccountInfo should be enough. This way, we can make MultiAccountUser to always hold an active user.

Signed-off-by: Seongmin Lee git@boltless.me

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.pull/3mdcq5ouz7x22
+17 -17
Interdiff #2 #3
appview/oauth/accounts.go

This file has not been changed.

appview/oauth/accounts_test.go

This file has not been changed.

+8 -8
appview/pages/pages.go
··· 230 230 } 231 231 232 232 type LoginParams struct { 233 - ReturnUrl string 234 - ErrorCode string 235 - AddAccount bool 236 - Accounts []oauth.AccountInfo 233 + ReturnUrl string 234 + ErrorCode string 235 + AddAccount bool 236 + LoggedInUser *oauth.MultiAccountUser 237 237 } 238 238 239 239 func (p *Pages) Login(w io.Writer, params LoginParams) error { ··· 248 248 } 249 249 250 250 type LoginParams struct { 251 - ReturnUrl string 252 - ErrorCode string 253 - AddAccount bool 254 - LoggedInUser *oauth.MultiAccountUser 251 + ReturnUrl string 252 + ErrorCode string 253 + AddAccount bool 254 + Accounts []oauth.AccountInfo 255 255 } 256 256 257 257 func (p *Pages) Login(w io.Writer, params LoginParams) error {
+5 -5
appview/pages/templates/user/login.html
··· 11 11 </div> 12 12 {{ end }} 13 13 14 - {{ if and .LoggedInUser .LoggedInUser.Accounts }} 15 - {{ $accounts := .LoggedInUser.Accounts }} 14 + {{ if .Accounts }} 16 15 <div class="my-4 border border-gray-200 dark:border-gray-700 rounded overflow-hidden"> 17 16 <div class="px-3 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700"> 18 17 <span class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide font-medium">Saved accounts</span> 19 18 </div> 20 19 <div class="divide-y divide-gray-200 dark:divide-gray-700"> 21 - {{ range $accounts }} 20 + {{ range .Accounts }} 22 21 <div class="flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700"> 23 22 <button 24 23 type="button" ··· 31 30 </div> 32 31 {{ end }} 33 32 34 - {{ if .Accounts }} 33 + {{ if and .LoggedInUser .LoggedInUser.Accounts }} 34 + {{ $accounts := .LoggedInUser.Accounts }} 35 35 <div class="my-4 border border-gray-200 dark:border-gray-700 rounded overflow-hidden"> 36 36 <div class="px-3 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700"> 37 37 <span class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide font-medium">Saved accounts</span> 38 38 </div> 39 39 <div class="divide-y divide-gray-200 dark:divide-gray-700"> 40 - {{ range .Accounts }} 40 + {{ range $accounts }} 41 41 <div class="flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700"> 42 42 <button 43 43 type="button"
appview/pulls/pulls.go

This patch was likely rebased, as context lines do not match.

appview/reporesolver/resolver.go

This patch was likely rebased, as context lines do not match.

+2 -2
appview/state/login.go
··· 70 70 l := s.logger.With("handler", "Logout") 71 71 72 72 currentUser := s.oauth.GetMultiAccountUser(r) 73 - if currentUser == nil { 73 + if currentUser == nil || currentUser.Active == nil { 74 74 s.pages.HxRedirect(w, "/login") 75 75 return 76 76 } 77 77 l := s.logger.With("handler", "Logout") 78 78 79 79 currentUser := s.oauth.GetMultiAccountUser(r) 80 - if currentUser == nil || currentUser.Active == nil { 80 + if currentUser == nil { 81 81 s.pages.HxRedirect(w, "/login") 82 82 return 83 83 }
+1 -1
appview/state/state.go
··· 248 248 filtered := false 249 249 250 250 var userDid string 251 + if user != nil && user.Active != nil { 251 - if user != nil { 252 252 userDid = user.Active.Did 253 253 } 254 254 timeline, err := db.MakeTimeline(s.db, 50, userDid, filtered)
+1 -1
appview/state/timeline.go
··· 47 47 filtered := false 48 48 49 49 var userDid string 50 - if user != nil && user.Active != nil { 50 + if user != nil { 51 51 userDid = user.Active.Did 52 52 } 53 53 timeline, err := db.MakeTimeline(s.db, 50, userDid, filtered)

History

9 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
appview/{pages,state}: simplify LoginPage params
2/3 timeout, 1/3 success
expand
no conflicts, ready to merge
expand 0 comments
1 commit
expand
appview/{pages,state}: simplify LoginPage params
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
appview/{pages,state}: simplify LoginPage params
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
appview/{pages,state}: simplify LoginPage params
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
appview/{pages,state}: simplify LoginPage params
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
appview/{pages,state}: simplify LoginPage params
3/3 success
expand
expand 0 comments
1 commit
expand
appview/{pages,state}: simplify LoginPage params
2/3 failed, 1/3 success
expand
expand 0 comments
1 commit
expand
appview/{pages,state}: simplify LoginPage params
3/3 success
expand
expand 0 comments
1 commit
expand
appview/{pages,state}: simplify LoginPage params
2/3 failed, 1/3 success
expand
expand 0 comments