Skip to content

Commit

Permalink
Fixed occasional flickering of dismissed announcement bar
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Feb 26, 2023
1 parent 920b913 commit 9b581ae
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 22 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion material/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.3e1761d0.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.ce72ebac.min.js' | url }}"></script>
{% for path in config.extra_javascript %}
<script src="{{ path | url }}"></script>
{% endfor %}
Expand Down
29 changes: 27 additions & 2 deletions material/partials/languages/zh-TW.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,57 @@
This file was automatically generated - do not edit
-#}
{% macro t(key) %}{{ {
"language": "zh-Hant",
"language": "zh-TW",
"action.edit": "編輯此頁",
"action.skip": "跳轉到",
"action.view": "查看此頁原始碼",
"announce.dismiss": "不再顯示此訊息",
"blog.archive": "封存",
"blog.categories": "分類",
"blog.categories.in": "於",
"blog.continue": "繼續閱讀",
"blog.draft": "草稿",
"blog.index": "回到主頁",
"blog.meta": "元數據",
"blog.references": "相關連結",
"clipboard.copy": "複製",
"clipboard.copied": "已複製",
"consent.accept": "同意",
"consent.manage": "管理設定",
"consent.reject": "拒絕",
"footer": "頁腳",
"footer.next": "下一頁",
"footer.previous": "上一頁",
"header": "頁首",
"meta.comments": "留言",
"meta.source": "來源",
"nav": "導覽列",
"readtime.one": "需要 1 分鐘閱讀時間",
"readtime.other": "需要 # 分鐘閱讀時間",
"rss.created": "RSS 訂閱",
"rss.updated": "RSS 訂閱內容已更新",
"search": "搜尋",
"search.config.lang": "ja",
"search.config.pipeline": "stemmer",
"search.config.separator": "[\\s\\- 、。,.?;]+",
"search.placeholder": "搜尋",
"search.share": "分享",
"search.reset": "清除",
"search.result.initializer": "正在初始化搜尋引擎",
"search.result.placeholder": "打字進行搜尋",
"search.result.none": "沒有符合的項目",
"search.result.one": "找到 1 個符合的項目",
"search.result.other": "找到 # 個符合的項目",
"search.result.more.one": "此頁尚有 1 個符合的項目",
"search.result.more.other": "此頁尚有 # 個符合的項目",
"search.result.term.missing": "缺少字詞",
"select.language": "選擇語言",
"select.version": "選擇版本",
"source": "前往倉庫",
"source.file.contributors": "貢獻者",
"source.file.date.created": "建立日期",
"source.file.date.updated": "最後更新",
"toc": "目錄"
"tabs": "標籤",
"toc": "目錄",
"top": "回到頂端"
}[key] }}{% endmacro %}
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ theme:
name: material
custom_dir: material/.overrides
features:
# - announce.dismiss
- announce.dismiss
- content.action.edit
- content.action.view
- content.code.annotate
Expand Down
17 changes: 5 additions & 12 deletions src/assets/javascripts/components/announce/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
finalize,
fromEvent,
map,
startWith,
tap
} from "rxjs"

Expand Down Expand Up @@ -86,18 +85,12 @@ export function mountAnnounce(
/* Mount component on subscription */
return defer(() => {
const push$ = new Subject<Announce>()
push$
.pipe(
startWith({ hash: __md_get<number>("__announce") })
)
.subscribe(({ hash }) => {
if (hash && hash === (__md_get<number>("__announce") ?? hash)) {
el.hidden = true
push$.subscribe(({ hash }) => {
el.hidden = true

/* Persist preference in local storage */
__md_set<number>("__announce", hash)
}
})
/* Persist preference in local storage */
__md_set<number>("__announce", hash)
})

/* Create and return component */
return watchAnnounce(el)
Expand Down

0 comments on commit 9b581ae

Please sign in to comment.