Skip to content

Commit

Permalink
fix: localization before modal shown
Browse files Browse the repository at this point in the history
Fixes #391
  • Loading branch information
arildm committed Sep 16, 2024
1 parent 4597a78 commit 4efb290
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions app/scripts/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ angular.module("korpApp").component("header", {
"$uibModal",
"$rootScope",
"$scope",
"$timeout",
"utils",
function ($location, $uibModal, $rootScope, $scope, utils) {
function ($location, $uibModal, $rootScope, $scope, $timeout, utils) {
const $ctrl = this

$scope.lang = $rootScope.lang
Expand Down Expand Up @@ -160,16 +161,14 @@ angular.module("korpApp").component("header", {
$rootScope.show_modal = false

let modal = null

utils.setupHash($rootScope, {
key: "display",
scope_name: "show_modal",
post_change(val) {
if (val) {
showAbout()
} else {
if (modal != null) {
modal.close()
}
if (val) showAbout()
else {
modal?.close()
modal = null
}
},
Expand All @@ -181,18 +180,17 @@ angular.module("korpApp").component("header", {

const modalScope = $rootScope.$new(true)
modalScope.clickX = () => closeModals()
var showAbout = function () {
const params = {
template: require("../../markup/about.html"),
scope: modalScope,
windowClass: "about",
}
modal = $uibModal.open(params)

modal.result.then(
() => closeModals(),
() => closeModals()
)
function showAbout() {
// $timeout is used to let localization happen before modal is shown (if loaded with "display=about")
$timeout(() => {
modal = $uibModal.open({
template: require("../../markup/about.html"),
scope: modalScope,
windowClass: "about",
})
modal.result.catch(() => closeModals())
})
}

const N_VISIBLE = settings["visible_modes"]
Expand Down

0 comments on commit 4efb290

Please sign in to comment.