refactor(geoip): reconcile geoip system (#31)
This commit is contained in:
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2026 Fluxer Contributors
|
||||
*
|
||||
* This file is part of Fluxer.
|
||||
*
|
||||
* Fluxer is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Fluxer is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
)
|
||||
|
||||
var allowedChannels = []string{"stable", "canary"}
|
||||
|
||||
func parseChannel() string {
|
||||
raw := os.Getenv("BUILD_CHANNEL")
|
||||
if raw != "" && slices.Contains(allowedChannels, raw) {
|
||||
return raw
|
||||
}
|
||||
return "stable"
|
||||
}
|
||||
|
||||
func main() {
|
||||
channel := parseChannel()
|
||||
|
||||
cwd, _ := os.Getwd()
|
||||
targetPath := filepath.Join(cwd, "..", "src-electron", "common", "build-channel.ts")
|
||||
|
||||
fileContent := fmt.Sprintf(`/*
|
||||
* This file is generated by scripts/cmd/set-build-channel.
|
||||
* DO NOT EDIT MANUALLY.
|
||||
*/
|
||||
|
||||
export type BuildChannel = 'stable' | 'canary';
|
||||
|
||||
const DEFAULT_BUILD_CHANNEL = '%s' as BuildChannel;
|
||||
|
||||
const envChannel = process.env.BUILD_CHANNEL?.toLowerCase();
|
||||
export const BUILD_CHANNEL = (envChannel === 'canary' ? 'canary' : DEFAULT_BUILD_CHANNEL) as BuildChannel;
|
||||
export const IS_CANARY = BUILD_CHANNEL === 'canary';
|
||||
export const CHANNEL_DISPLAY_NAME = BUILD_CHANNEL;
|
||||
`, channel)
|
||||
|
||||
if err := os.WriteFile(targetPath, []byte(fileContent), 0644); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error writing file: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Wrote %s with channel '%s'\n", targetPath, channel)
|
||||
}
|
||||
@@ -97,6 +97,9 @@ const AuthSession: React.FC<AuthSessionProps> = observer(
|
||||
const platformLabel =
|
||||
authSession.clientPlatform === 'Fluxer Desktop' ? t`Fluxer Desktop` : authSession.clientPlatform;
|
||||
|
||||
const hasLocation = Boolean(authSession.clientLocation);
|
||||
const locationRowVisible = hasLocation || !isCurrent;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={clsx(styles.authSession, selectionMode && !isCurrent && styles.authSessionSelectable)}
|
||||
@@ -114,17 +117,17 @@ const AuthSession: React.FC<AuthSessionProps> = observer(
|
||||
{platformLabel}
|
||||
</span>
|
||||
|
||||
<div className={styles.authSessionLocation}>
|
||||
<span className={styles.locationText}>{authSession.clientLocation}</span>
|
||||
{!isCurrent && (
|
||||
<>
|
||||
<span aria-hidden className={styles.locationSeparator} />
|
||||
{locationRowVisible && (
|
||||
<div className={styles.authSessionLocation}>
|
||||
{hasLocation && <span className={styles.locationText}>{authSession.clientLocation}</span>}
|
||||
{!isCurrent && hasLocation && <span aria-hidden className={styles.locationSeparator} />}
|
||||
{!isCurrent && (
|
||||
<span className={styles.lastUsed}>
|
||||
{DateUtils.getShortRelativeDateString(authSession.approxLastUsedAt ?? new Date(0))}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ export type AuthSession = Readonly<{
|
||||
approx_last_used_at: string | null;
|
||||
client_os: string;
|
||||
client_platform: string;
|
||||
client_location: string;
|
||||
client_location: string | null;
|
||||
}>;
|
||||
|
||||
export class AuthSessionRecord {
|
||||
@@ -30,7 +30,7 @@ export class AuthSessionRecord {
|
||||
readonly approxLastUsedAt: Date | null;
|
||||
readonly clientOs: string;
|
||||
readonly clientPlatform: string;
|
||||
readonly clientLocation: string;
|
||||
readonly clientLocation: string | null;
|
||||
|
||||
constructor(data: AuthSession) {
|
||||
this.id = data.id;
|
||||
|
||||
Reference in New Issue
Block a user