Skip to content

Commit 9d66e05

Browse files
Merge branch 'main' into main
2 parents c4fef58 + 3a828a6 commit 9d66e05

File tree

18 files changed

+796
-986
lines changed

18 files changed

+796
-986
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ jobs:
123123
124124
# Upload 'linkstack.zip'
125125
gh release upload "${GITHUB_REF##*/}" "linkstack.zip" --clobber -R "$REPO_NAME"
126+
127+
# Mark the release as the latest
128+
gh release edit "${GITHUB_REF##*/}" --title="${GITHUB_REF##*/}" -R "$REPO_NAME"
126129
fi
127130
128131
- name: Update version.json

app/Http/Controllers/LinkTypeViewController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ public function getParamForm($typeid, $linkId = 0)
3838

3939
if (!empty($linkType) && $linkType->typename === 'predefined') {
4040
// get buttons list if showing predefined form
41-
$buttons = Button::select('name')->orderBy('name', 'asc')->get();
41+
$buttons = Button::select()->orderBy('name', 'asc')->get();
4242
foreach ($buttons as $btn) {
4343
$data['buttons'][] = [
4444
'name' => $btn->name,
45-
'title' => ucwords($btn->name),
45+
'title' => $btn->alt,
46+
'exclude' => $btn->exclude,
4647
'selected' => (is_object($data['params']) && $data['params']->button === $btn->name)
4748
];
4849
}

app/Http/Controllers/UserController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public function saveLink(request $request)
219219
$button = Button::where('name', $request->button)->first();
220220

221221
if ($button && empty($LinkTitle))
222-
$LinkTitle = ucwords($button->name);
222+
$LinkTitle = $button->alt;
223223

224224
if ($linkType->typename == 'video' && empty($LinkTitle)) {
225225
$embed = OEmbed::get($LinkURL);

app/Models/UserData.php

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Models;
44

55
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Support\Facades\Cache;
67

78
class UserData extends Model
89
{
@@ -11,7 +12,7 @@ class UserData extends Model
1112

1213
public static function saveData($userId, $key, $value)
1314
{
14-
$userData = self::where('id', $userId)->first();
15+
$userData = self::getCachedUserData($userId);
1516

1617
if (!$userData) {
1718
return "null";
@@ -22,35 +23,51 @@ public static function saveData($userId, $key, $value)
2223

2324
$userData->image = json_encode($data);
2425
$userData->save();
26+
27+
self::cacheUserData($userId, $userData);
2528
}
2629

2730
public static function getData($userId, $key)
2831
{
29-
$userData = self::where('id', $userId)->first();
30-
32+
$userData = self::getCachedUserData($userId);
33+
3134
if (!$userData || !$userData->image) {
3235
return "null";
3336
}
34-
37+
3538
$data = json_decode($userData->image, true) ?? [];
36-
39+
3740
return isset($data[$key]) ? $data[$key] : null;
3841
}
3942

4043
public static function removeData($userId, $key)
4144
{
42-
$userData = self::where('id', $userId)->first();
43-
45+
$userData = self::getCachedUserData($userId);
46+
4447
if (!$userData || !$userData->image) {
4548
return "null";
4649
}
47-
50+
4851
$data = json_decode($userData->image, true) ?? [];
49-
52+
5053
if (isset($data[$key])) {
5154
unset($data[$key]);
5255
$userData->image = json_encode($data);
5356
$userData->save();
57+
58+
self::cacheUserData($userId, $userData);
5459
}
5560
}
61+
62+
private static function getCachedUserData($userId)
63+
{
64+
return Cache::remember('user_data_' . $userId, now()->addMinutes(10), function () use ($userId) {
65+
return self::where('id', $userId)->first();
66+
});
67+
}
68+
69+
private static function cacheUserData($userId, $userData)
70+
{
71+
Cache::put('user_data_' . $userId, $userData, now()->addMinutes(10));
72+
}
5673
}

config/config-legends.json

Lines changed: 0 additions & 256 deletions
This file was deleted.

database/migrations/2021_03_17_044922_create_buttons_table.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ public function up()
1616
Schema::create('buttons', function (Blueprint $table) {
1717
$table->id();
1818
$table->string('name');
19+
$table->string('alt')->nullable();
20+
$table->boolean('exclude')->default(false);
21+
$table->string('group')->nullable();
22+
$table->boolean('mb')->default(false);
1923
$table->timestamps();
2024
});
2125
}

0 commit comments

Comments
 (0)