Skip to content

Commit

Permalink
Merge pull request #1017 from nextcloud/fix-safari
Browse files Browse the repository at this point in the history
Fix safari
  • Loading branch information
tacruc authored Mar 24, 2023
2 parents 52a66d6 + a262835 commit c03c51d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
6 changes: 6 additions & 0 deletions lib/Service/MyMapsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ private function node2MyMap($node, $userFolder):array{
return $MyMap;
}

/**
* @param $userId
* @return array
* @throws NoUserException
* @throws NotPermittedException
*/
public function getAllMyMaps($userId){
$userFolder = $this->root->getUserFolder($userId);
$MyMaps = [];
Expand Down
5 changes: 2 additions & 3 deletions src/components/map/ContactsLayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Vue2LeafletMarkerCluster from 'vue2-leaflet-markercluster'
import ContactLayer from './ContactLayer'
import optionsController from '../../optionsController'
import {getToken, isPublic} from "../../utils/common";
import {splitByNonEscapedComma} from "../../utils";
const CONTACT_MARKER_VIEW_SIZE = 40
Expand Down Expand Up @@ -63,9 +64,7 @@ export default {
return this.contacts.filter((c) => {
if (c.GROUPS) {
try {
const cGroups = c.GROUPS.split(/(?<!\\),/).map((name) => {
return name.replace('\\,', ',')
})
const cGroups = splitByNonEscapedComma(c.GROUPS)
for (let i = 0; i < cGroups.length; i++) {
// if at least in one enabled group
if (this.groups[cGroups[i]].enabled) {
Expand Down
4 changes: 2 additions & 2 deletions src/report-error-map-action.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

OCA.Maps.registerMapsAction({
OCA.Maps?.registerMapsAction({
label: t('maps', 'Report Error'),
icon: 'icon-alert-outline',
callback: (location) => {
const url = `https://www.openstreetmap.org/note/new?lat=${location.latitude}&lon=${location.longitude}#map=18/${location.latitude}/${location.longitude}`
window.open(url, '_blank').focus()
window.open(url, '_blank')?.focus()
},
})
16 changes: 16 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ function dirname(path) {
return path.replace(/\\/g, '/').replace(/\/[^\/]*$/, '');
}

function splitByNonEscapedComma(str) {
// As safari doesn't support lookbehind we need to work with reversed strings
return str.split('')
.reverse()
.join('')
.split(/,(?!(?:(?:\\\\)*\\(?!\\)))/)
.map((g) => {
return g.replaceAll(',\\',',')
.replaceAll('\\\\','\\')
.split('')
.reverse()
.join('')
}).reverse()
}

function Timer(callback, mydelay) {
var timerId,
start,
Expand Down Expand Up @@ -382,6 +397,7 @@ export const accented = {
export {
basename,
dirname,
splitByNonEscapedComma,
Timer,
getLetterColor,
hslToRgb,
Expand Down
11 changes: 3 additions & 8 deletions src/views/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,10 @@ import AppNavigationTracksItem from '../components/AppNavigationTracksItem'
import AppNavigationDevicesItem from '../components/AppNavigationDevicesItem'
import AppNavigationMyMapsItem from '../components/AppNavigationMyMapsItem'
import optionsController from '../optionsController'
import { getLetterColor, hslToRgb, Timer, getDeviceInfoFromUserAgent2, isComputer, isPhone } from '../utils'
import { getLetterColor, hslToRgb, Timer, getDeviceInfoFromUserAgent2, isComputer, isPhone, splitByNonEscapedComma } from '../utils'
import { binSearch, getToken, isPublic } from '../utils/common'
import { poiSearchData } from '../utils/poiData'
import { processGpx } from '../tracksUtils'

import L from 'leaflet'
import { geoToLatLng, getFormattedADR } from '../utils/mapUtils'
import * as network from '../network'
Expand Down Expand Up @@ -1316,9 +1315,7 @@ export default {
const contactsInGroup = this.contacts.filter((c) => {
if (c.GROUPS) {
try {
const cGroups = c.GROUPS.split(/[^\\],/).map((name) => {
return name.replace('\\,', ',')
})
const cGroups = splitByNonEscapedComma(c.GROUPS)
for (let i = 0; i < cGroups.length; i++) {
// if at least in one enabled group
if (cGroups[i] === group) {
Expand Down Expand Up @@ -1399,9 +1396,7 @@ export default {
c.groupList = []
if (c.GROUPS) {
try {
const cGroups = c.GROUPS.split(/(?<!\\),/).map((name) => {
return name.replace('\\,', ',')
})
const cGroups = splitByNonEscapedComma(c.GROUPS)
if (cGroups.length > 0) {
cGroups.forEach((g) => {
c.groupList.push(g)
Expand Down

0 comments on commit c03c51d

Please sign in to comment.