Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: impl compact mode setting (#2935)

Mehad Nadeemd2434111b425
diff --git a/api/v2/apidocs.swagger.yaml b/api/v2/apidocs.swagger.yaml
index 1a474600e..122cb468c 100644
--- a/api/v2/apidocs.swagger.yaml
+++ b/api/v2/apidocs.swagger.yaml
@@ -170,16 +170,12 @@ paths:
type: integer
format: int32
- name: pageToken
- description: |-
- A page token, received from a previous `ListMemos` call.
- Provide this to retrieve the subsequent page.
+ description: "A page token, received from a previous `ListMemos` call.\r\nProvide this to retrieve the subsequent page."
in: query
required: false
type: string
- name: filter
- description: |-
- Filter is used to filter memos returned in the list.
- Format: "creator == users/{username} && visibilities == ['PUBLIC', 'PROTECTED']"
+ description: "Filter is used to filter memos returned in the list.\r\nFormat: \"creator == users/{username} && visibilities == ['PUBLIC', 'PROTECTED']\""
in: query
required: false
type: string
@@ -240,17 +236,12 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: name
- description: |-
- name is the name of the user to get stats for.
- Format: users/{username}
+ description: "name is the name of the user to get stats for.\r\nFormat: users/{username}"
in: query
required: false
type: string
- name: timezone
- description: |-
- timezone location
- Format: uses tz identifier
- https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
+ description: "timezone location\r\nFormat: uses tz identifier\r\nhttps://en.wikipedia.org/wiki/List_of_tz_database_time_zones"
in: query
required: false
type: string
@@ -483,9 +474,7 @@ paths:
$ref: '#/definitions/apiv2RowStatus'
creator:
type: string
- title: |-
- The name of the creator.
- Format: users/{username}
+ title: "The name of the creator.\r\nFormat: users/{username}"
creatorId:
type: integer
format: int32
@@ -712,9 +701,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: user
- description: |-
- The creator of tags.
- Format: users/{username}
+ description: "The creator of tags.\r\nFormat: users/{username}"
in: query
required: false
type: string
@@ -738,9 +725,7 @@ paths:
required: false
type: string
- name: tag.creator
- description: |-
- The creator of tags.
- Format: users/{username}
+ description: "The creator of tags.\r\nFormat: users/{username}"
in: query
required: false
type: string
@@ -780,9 +765,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: user
- description: |-
- The creator of tags.
- Format: users/{username}
+ description: "The creator of tags.\r\nFormat: users/{username}"
in: query
required: false
type: string
@@ -805,9 +788,7 @@ paths:
- TagService
/api/v2/tags:rename:
patch:
- summary: |-
- RenameTag renames a tag.
- All related memos will be updated.
+ summary: "RenameTag renames a tag.\r\nAll related memos will be updated."
operationId: TagService_RenameTag
responses:
"200":
@@ -820,9 +801,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: user
- description: |-
- The creator of tags.
- Format: users/{username}
+ description: "The creator of tags.\r\nFormat: users/{username}"
in: query
required: false
type: string
@@ -1046,9 +1025,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: inbox.name
- description: |-
- The name of the inbox.
- Format: inboxes/{uid}
+ description: "The name of the inbox.\r\nFormat: inboxes/{uid}"
in: path
required: true
type: string
@@ -1092,9 +1069,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: name_1
- description: |-
- The name of the inbox to delete.
- Format: inboxes/{uid}
+ description: "The name of the inbox to delete.\r\nFormat: inboxes/{uid}"
in: path
required: true
type: string
@@ -1116,9 +1091,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: name
- description: |-
- The name of the user.
- Format: users/{username}
+ description: "The name of the user.\r\nFormat: users/{username}"
in: path
required: true
type: string
@@ -1139,9 +1112,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: name
- description: |-
- The name of the user.
- Format: users/{username}
+ description: "The name of the user.\r\nFormat: users/{username}"
in: path
required: true
type: string
@@ -1163,9 +1134,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: name
- description: |-
- The name of the user.
- Format: users/{username}
+ description: "The name of the user.\r\nFormat: users/{username}"
in: path
required: true
type: string
@@ -1186,9 +1155,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: name
- description: |-
- The name of the user.
- Format: users/{username}
+ description: "The name of the user.\r\nFormat: users/{username}"
in: path
required: true
type: string
@@ -1215,9 +1182,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: name
- description: |-
- The name of the user.
- Format: users/{username}
+ description: "The name of the user.\r\nFormat: users/{username}"
in: path
required: true
type: string
@@ -1244,9 +1209,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: name
- description: |-
- The name of the user.
- Format: users/{username}
+ description: "The name of the user.\r\nFormat: users/{username}"
in: path
required: true
type: string
@@ -1268,9 +1231,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: setting.name
- description: |-
- The name of the user.
- Format: users/{username}
+ description: "The name of the user.\r\nFormat: users/{username}"
in: path
required: true
type: string
@@ -1313,9 +1274,7 @@ paths:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: user.name
- description: |-
- The name of the user.
- Format: users/{username}
+ description: "The name of the user.\r\nFormat: users/{username}"
in: path
required: true
type: string
@@ -1438,9 +1397,7 @@ definitions:
properties:
name:
type: string
- title: |-
- The name of the user.
- Format: users/{username}
+ title: "The name of the user.\r\nFormat: users/{username}"
locale:
type: string
description: The preferred locale of the user.
@@ -1625,9 +1582,7 @@ definitions:
additionalProperties:
type: integer
format: int32
- description: |-
- stats is the stats of memo creating/updating activities.
- key is the year-month-day string. e.g. "2020-01-01".
+ description: "stats is the stats of memo creating/updating activities.\r\nkey is the year-month-day string. e.g. \"2020-01-01\"."
v2GetUserResponse:
type: object
properties:
@@ -1653,9 +1608,7 @@ definitions:
properties:
name:
type: string
- title: |-
- The name of the inbox.
- Format: inboxes/{uid}
+ title: "The name of the inbox.\r\nFormat: inboxes/{uid}"
sender:
type: string
title: 'Format: users/{username}'
@@ -1728,9 +1681,7 @@ definitions:
$ref: '#/definitions/v2Memo'
nextPageToken:
type: string
- description: |-
- A token, which can be sent as `page_token` to retrieve the next page.
- If this field is omitted, there are no subsequent pages.
+ description: "A token, which can be sent as `page_token` to retrieve the next page.\r\nIf this field is omitted, there are no subsequent pages."
v2ListResourcesResponse:
type: object
properties:
@@ -1785,9 +1736,7 @@ definitions:
$ref: '#/definitions/apiv2RowStatus'
creator:
type: string
- title: |-
- The name of the creator.
- Format: users/{username}
+ title: "The name of the creator.\r\nFormat: users/{username}"
creatorId:
type: integer
format: int32
@@ -1898,9 +1847,7 @@ definitions:
type: string
creator:
type: string
- title: |-
- The creator of tags.
- Format: users/{username}
+ title: "The creator of tags.\r\nFormat: users/{username}"
v2UpdateInboxResponse:
type: object
properties:
@@ -1951,9 +1898,7 @@ definitions:
properties:
name:
type: string
- title: |-
- The name of the user.
- Format: users/{username}
+ title: "The name of the user.\r\nFormat: users/{username}"
id:
type: integer
format: int32
diff --git a/store/db/mysql/user_setting.go b/store/db/mysql/user_setting.go
index 8a2114de8..f5edd8e62 100644
--- a/store/db/mysql/user_setting.go
+++ b/store/db/mysql/user_setting.go
@@ -3,6 +3,7 @@ package mysql
import (
"context"
"database/sql"
+ "strconv"
"strings"
"github.com/pkg/errors"
@@ -29,6 +30,8 @@ func (d *DB) UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting)
valueString = upsert.GetMemoVisibility()
} else if upsert.Key == storepb.UserSettingKey_USER_SETTING_TELEGRAM_USER_ID {
valueString = upsert.GetTelegramUserId()
+ } else if upsert.Key == storepb.UserSettingKey_USER_SETTING_COMPACT_VIEW {
+ valueString = strconv.FormatBool(upsert.GetCompactView())
} else {
return nil, errors.Errorf("unknown user setting key: %s", upsert.Key.String())
}
@@ -93,6 +96,14 @@ func (d *DB) ListUserSettings(ctx context.Context, find *store.FindUserSetting)
userSetting.Value = &storepb.UserSetting_TelegramUserId{
TelegramUserId: valueString,
}
+ } else if userSetting.Key == storepb.UserSettingKey_USER_SETTING_COMPACT_VIEW {
+ compactView, err := strconv.ParseBool(valueString)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse compact view value: %s", valueString)
+ }
+ userSetting.Value = &storepb.UserSetting_CompactView{
+ CompactView: compactView,
+ }
} else {
// Skip unknown user setting key.
continue
diff --git a/store/db/postgres/user_setting.go b/store/db/postgres/user_setting.go
index 71c5fd3fa..09078f154 100644
--- a/store/db/postgres/user_setting.go
+++ b/store/db/postgres/user_setting.go
@@ -3,6 +3,7 @@ package postgres
import (
"context"
"database/sql"
+ "strconv"
"strings"
"github.com/pkg/errors"
@@ -36,6 +37,8 @@ func (d *DB) UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting)
valueString = upsert.GetMemoVisibility()
} else if upsert.Key == storepb.UserSettingKey_USER_SETTING_TELEGRAM_USER_ID {
valueString = upsert.GetTelegramUserId()
+ } else if upsert.Key == storepb.UserSettingKey_USER_SETTING_COMPACT_VIEW {
+ valueString = strconv.FormatBool(upsert.GetCompactView())
} else {
return nil, errors.Errorf("unknown user setting key: %s", upsert.Key.String())
}
@@ -106,6 +109,14 @@ func (d *DB) ListUserSettings(ctx context.Context, find *store.FindUserSetting)
userSetting.Value = &storepb.UserSetting_TelegramUserId{
TelegramUserId: valueString,
}
+ } else if userSetting.Key == storepb.UserSettingKey_USER_SETTING_COMPACT_VIEW {
+ compactView, err := strconv.ParseBool(valueString)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse compact view value: %s", valueString)
+ }
+ userSetting.Value = &storepb.UserSetting_CompactView{
+ CompactView: compactView,
+ }
} else {
// Skip unknown user setting key.
continue
diff --git a/store/db/sqlite/user_setting.go b/store/db/sqlite/user_setting.go
index 833072ddf..f95322f14 100644
--- a/store/db/sqlite/user_setting.go
+++ b/store/db/sqlite/user_setting.go
@@ -3,6 +3,7 @@ package sqlite
import (
"context"
"database/sql"
+ "strconv"
"strings"
"github.com/pkg/errors"
@@ -36,6 +37,8 @@ func (d *DB) UpsertUserSetting(ctx context.Context, upsert *storepb.UserSetting)
valueString = upsert.GetMemoVisibility()
} else if upsert.Key == storepb.UserSettingKey_USER_SETTING_TELEGRAM_USER_ID {
valueString = upsert.GetTelegramUserId()
+ } else if upsert.Key == storepb.UserSettingKey_USER_SETTING_COMPACT_VIEW {
+ valueString = strconv.FormatBool(upsert.GetCompactView())
} else {
return nil, errors.Errorf("unknown user setting key: %s", upsert.Key.String())
}
@@ -106,6 +109,14 @@ func (d *DB) ListUserSettings(ctx context.Context, find *store.FindUserSetting)
userSetting.Value = &storepb.UserSetting_TelegramUserId{
TelegramUserId: valueString,
}
+ } else if userSetting.Key == storepb.UserSettingKey_USER_SETTING_COMPACT_VIEW {
+ compactView, err := strconv.ParseBool(valueString)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse compact view value: %s", valueString)
+ }
+ userSetting.Value = &storepb.UserSetting_CompactView{
+ CompactView: compactView,
+ }
} else {
// Skip unknown user setting key.
continue