Skip to content

Commit

Permalink
Merge pull request #41 from litencatt/fix-slack-submit-search-result
Browse files Browse the repository at this point in the history
Set filter for slack submit result search
  • Loading branch information
litencatt committed Dec 17, 2023
2 parents 9aa92e1 + 2de3db1 commit f002d09
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,11 +578,14 @@ app.view("search-db-modal", async ({ ack, view, client, logger }) => {
const metaData = JSON.parse(view.private_metadata) as MetaData
console.dir({ metaData }, { depth: null })

const res = await notion.client.databases.query({
const params = {
database_id: metaData.selected_db_id,
// filter: metaData.filters as QueryDatabaseParameters["filter"],
page_size: 10,
})
}
if (metaData.filters != null) {
params["filter"] = metaData.filters as QueryDatabaseParameters["filter"]
}
const res = await notion.client.databases.query(params)
const urls = await notion.getPageUrls(res)
if (urls.length == 0) {
urls.push("No Results")
Expand All @@ -605,7 +608,7 @@ app.view("search-db-modal", async ({ ack, view, client, logger }) => {
type: "section",
text: {
type: "mrkdwn",
text: "フィルター:\n```" + JSON.stringify(metaData.filters) + "```",
text: "Filter:\n```" + JSON.stringify(metaData.filters) + "```",
},
},
{
Expand All @@ -615,7 +618,7 @@ app.view("search-db-modal", async ({ ack, view, client, logger }) => {
type: "section",
text: {
type: "mrkdwn",
text: "*検索結果*:\n" + urls.join("\n"),
text: "*Search Result*:\n" + urls.join("\n"),
},
},
],
Expand Down
4 changes: 2 additions & 2 deletions src/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const modalButtonMessage = (message_ts: string) => {
type: "button",
text: {
type: "plain_text",
text: "モーダルを開いて検索する",
text: "Open modal",
},
action_id: "open-modal-button",
},
Expand Down Expand Up @@ -61,7 +61,7 @@ export const searchDbView = (metaData: any, data: any[]) => {
},
label: {
type: "plain_text",
text: "DB選択",
text: "Select DB",
},
},
],
Expand Down

0 comments on commit f002d09

Please sign in to comment.