Monorepo for Tangled tangled.org

appview: allow users to set their preferences for the punchcard being displayed #1077

merged opened by willdot.net targeting master from willdot.net/tangled-fork: punchcard-prefs

This allows users to set their preference for the punchcard.

It allows them to either:

1: Hide their punchcard so that no one can see it 2: Hide all punchcards so that they don't see anyones punchcards

Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:dadhhalkfcq3gucaq25hjqon/sh.tangled.repo.pull/3meygakiwru22
+9 -3
Interdiff #0 โ†’ #1
+2 -2
appview/db/db.go
··· 576 576 create table if not exists punchcard_preferences ( 577 577 id integer primary key autoincrement, 578 578 user_did text not null unique, 579 - hide_mine bool, 580 - hide_all bool 579 + hide_mine integer default 0, 580 + hide_all integer default 0 581 581 ); 582 582 583 583 -- indexes for better performance
+7 -1
appview/db/preferences.go
··· 11 11 Did: did, 12 12 } 13 13 14 + hideMine := 0 15 + hideAll := 0 16 + 14 17 err := e.QueryRow( 15 18 `select id, hide_mine, hide_all from punchcard_preferences where user_did = ?`, 16 19 did, 17 - ).Scan(&preference.ID, &preference.HideMine, &preference.HideAll) 20 + ).Scan(&preference.ID, &hideMine, &hideAll) 18 21 if err == sql.ErrNoRows { 19 22 return preference, nil 20 23 } 21 24 25 + preference.HideMine = hideMine > 0 26 + preference.HideAll = hideAll > 0 27 + 22 28 if err != nil { 23 29 return preference, err 24 30 }
appview/db/profile.go

This file has not been changed.

appview/models/preferences.go

This file has not been changed.

appview/pages/pages.go

This file has not been changed.

appview/pages/templates/layouts/profilebase.html

This file has not been changed.

appview/pages/templates/user/settings/profile.html

This file has not been changed.

appview/settings/settings.go

This file has not been changed.

appview/state/profile.go

This file has not been changed.

appview/state/router.go

This file has not been changed.

History

5 rounds 3 comments
sign up or login to add to the discussion
1 commit
expand
appview: allow users to set their preferences for the punchcard being displayed
expand 1 comment

thanks for the work on this! this looks good to me in the current state.

pull request successfully merged
1 commit
expand
appview: allow users to set their preferences for the punchcard being displayed
expand 0 comments
1 commit
expand
appview: allow users to set their preferences for the punchcard being displayed
expand 0 comments
1 commit
expand
appview: allow users to set their preferences for the punchcard being displayed
expand 0 comments
1 commit
expand
appview: allow users to set their preferences for the punchcard being displayed
expand 2 comments
  • here: there is no bool type in sqlite! so we will have to use ints here. i tested this locally and it seems that is valid sql and executes fine, but it seems any value can be stored in that column.
  • here: nice, this is super neat

all in all, rest of the code lgtm!

Oh wow, TIL that there isn't a bool type in sqlite ๐Ÿซฃ

I've fixed that so that the field is an integer type with a default of 0 (false) and then added the relevant mapping into the query code to map 0 is false and > 0 is true.

Tested by stuffing random integers manually into the table and appears to work as expected.