Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce warning message for Safari 13 and below (#18258)
Discourse will be dropping support for these browsers in early 2023. https://meta.discourse.org/t/224747
- Loading branch information
1 parent
4af080d
commit 3904c23
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
app/assets/javascripts/discourse/app/initializers/safari-13-deprecation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import I18n from "I18n"; | ||
import { withPluginApi } from "discourse/lib/plugin-api"; | ||
|
||
function setupMessage(api) { | ||
const isSafari = navigator.vendor === "Apple Computer, Inc."; | ||
if (!isSafari) { | ||
return; | ||
} | ||
|
||
let safariMajorVersion = navigator.userAgent.match(/Version\/(\d+)\./)?.[1]; | ||
safariMajorVersion = safariMajorVersion | ||
? parseInt(safariMajorVersion, 10) | ||
: null; | ||
|
||
if (safariMajorVersion && safariMajorVersion <= 13) { | ||
api.addGlobalNotice( | ||
I18n.t("safari_13_warning"), | ||
"browser-deprecation-warning", | ||
{ dismissable: true, dismissDuration: moment.duration(1, "week") } | ||
); | ||
} | ||
} | ||
|
||
export default { | ||
name: "safari-13-deprecation", | ||
|
||
initialize() { | ||
withPluginApi("0.8.37", setupMessage); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3904c23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit has been mentioned on Discourse Meta. There might be relevant details there:
https://meta.discourse.org/t/maintaining-support-for-ios-12-5-until-january-2023/224747/21